1818import com .google .common .io .ByteSource ;
1919import org .junit .jupiter .api .Test ;
2020
21- import java .io .InputStream ;
22-
2321import static com .google .common .base .Charsets .UTF_8 ;
2422import static org .assertj .core .api .Assertions .assertThat ;
2523import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -34,11 +32,10 @@ void loadInvalidXML() {
3432 parse ("<root><unclosedTag></root>" );
3533
3634 fail ("Should not have accepted invalid xml" );
37- }
38- catch (NX .Ex ex ) {
35+ } catch (NX .Ex ex ) {
3936 assertThat (ex )
40- .as ("Expected exception" )
41- .hasMessage ("Failed to initialize xml cursor" );
37+ .as ("Expected exception" )
38+ .hasMessage ("Failed to initialize xml cursor" );
4239 }
4340 }
4441
@@ -48,23 +45,21 @@ void loadInvalidXMLFromBytes() {
4845 parse (ByteSource .wrap ("<root><unclosedTag></root>" .getBytes (UTF_8 )));
4946
5047 fail ("Should not have accepted invalid xml" );
51- }
52- catch (NX .Ex ex ) {
48+ } catch (NX .Ex ex ) {
5349 assertThat (ex )
54- .as ("Expected exception" )
55- .hasMessage ("Failed to initialize xml cursor" );
50+ .as ("Expected exception" )
51+ .hasMessage ("Failed to initialize xml cursor" );
5652 }
5753 }
5854
5955 @ Test
6056 void readingNodeWithDuplicateAttributeTriggersException () {
6157 try {
6258 parse ("<people><person name='First' name='Second' /></people>" );
63- }
64- catch (NX .Ex ex ) {
59+ } catch (NX .Ex ex ) {
6560 assertThat (ex .getCause ().getCause ())
66- .as ("Expected exception" )
67- .hasMessageContaining ("Attribute \" name\" was already specified for element \" person\" " );
61+ .as ("Expected exception" )
62+ .hasMessageContaining ("Attribute \" name\" was already specified for element \" person\" " );
6863 }
6964 }
7065
@@ -76,28 +71,4 @@ void loadValidXML() {
7671 assertEquals ("root" , cursor .name ());
7772 }
7873
79- @ Test
80- void failingToReadFromByteSource () {
81- try {
82- parse (new ByteSource () {
83-
84- @ Override
85- public InputStream openStream () {
86- throw new IllegalStateException ("Oups..." );
87- }
88-
89- });
90- }
91- catch (NX .Ex ex ) {
92- assertThat (ex )
93- .as ("Expected exception" )
94- .hasMessage ("Failed to initialize xml cursor" );
95-
96- assertThat (ex .getCause ())
97- .as ("Cause of the expected exception" )
98- .isInstanceOf (IllegalStateException .class )
99- .hasMessage ("Oups..." );
100- }
101- }
102-
10374}
0 commit comments