File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed 
src/test/java/pl/wavesoftware/eid/exceptions Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ package  pl .wavesoftware .eid .exceptions ;
2+ 
3+ import  org .hamcrest .CoreMatchers ;
4+ import  org .junit .Rule ;
5+ import  org .junit .Test ;
6+ import  org .junit .rules .ExpectedException ;
7+ 
8+ import  javax .xml .bind .JAXBException ;
9+ import  java .util .UnknownFormatConversionException ;
10+ 
11+ import  static  org .hamcrest .Matchers .containsString ;
12+ import  static  org .hamcrest .Matchers .is ;
13+ import  static  org .junit .internal .matchers .ThrowableMessageMatcher .hasMessage ;
14+ 
15+ /** 
16+  * @author Krzysztof Suszyński <[email protected] > 17+  * @since 2015-10-07 
18+  */ 
19+ @ SuppressWarnings ("ConstantConditions" )
20+ public  class  EidRuntimeExceptionTest  {
21+ 
22+     @ Rule 
23+     public  ExpectedException  thrown  = ExpectedException .none ();
24+ 
25+     @ Test 
26+     public  void  testGetMessage () {
27+         // then 
28+         thrown .expect (EidRuntimeException .class );
29+         thrown .expectCause (CoreMatchers .<Throwable >instanceOf (JAXBException .class ));
30+         thrown .expectCause (hasMessage (is ((String ) null )));
31+         thrown .expectMessage (containsString ("20151007:212217" ));
32+         thrown .expectMessage (containsString ("javax.xml.bind.JAXBException\n  - with linked exception:\n "  +
33+                 "[java.util.UnknownFormatConversionException: Conversion = 'Invalid for unit test']" ));
34+ 
35+         // given 
36+         String  message  = null ;
37+         Throwable  original  = new  UnknownFormatConversionException ("Invalid for unit test" );
38+         JAXBException  cause  = new  JAXBException (message );
39+         cause .setLinkedException (original );
40+         throw  new  EidRuntimeException ("20151007:212217" , cause );
41+     }
42+ 
43+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments