27
27
import org .junit .jupiter .api .BeforeEach ;
28
28
import org .junit .jupiter .api .Test ;
29
29
30
- public class SimpleNamespaceContextTest {
30
+ class SimpleNamespaceContextTest {
31
31
32
32
private SimpleNamespaceContext context ;
33
33
34
34
@ BeforeEach
35
- public void setUp () throws Exception {
36
-
35
+ void setUp () {
37
36
context = new SimpleNamespaceContext ();
38
37
context .bindNamespaceUri ("prefix" , "namespaceURI" );
39
38
}
40
39
41
40
@ Test
42
- public void testGetNamespaceURI () {
41
+ void testGetNamespaceURI () {
43
42
44
- assertThat (context .getNamespaceURI (XMLConstants .DEFAULT_NS_PREFIX )).isEqualTo ( "" );
43
+ assertThat (context .getNamespaceURI (XMLConstants .DEFAULT_NS_PREFIX )).isEmpty ( );
45
44
46
45
String defaultNamespaceUri = "defaultNamespace" ;
47
46
context .bindNamespaceUri (XMLConstants .DEFAULT_NS_PREFIX , defaultNamespaceUri );
48
47
49
48
assertThat (context .getNamespaceURI (XMLConstants .DEFAULT_NS_PREFIX )).isEqualTo (defaultNamespaceUri );
50
49
assertThat (context .getNamespaceURI ("prefix" )).isEqualTo ("namespaceURI" );
51
- assertThat (context .getNamespaceURI ("unbound" )).isEqualTo ( "" );
50
+ assertThat (context .getNamespaceURI ("unbound" )).isEmpty ( );
52
51
assertThat (context .getNamespaceURI (XMLConstants .XML_NS_PREFIX )).isEqualTo (XMLConstants .XML_NS_URI );
53
52
assertThat (context .getNamespaceURI (XMLConstants .XMLNS_ATTRIBUTE )).isEqualTo (XMLConstants .XMLNS_ATTRIBUTE_NS_URI );
54
53
}
55
54
56
55
@ Test
57
- public void testGetPrefix () {
56
+ void testGetPrefix () {
58
57
59
58
context .bindDefaultNamespaceUri ("defaultNamespaceURI" );
60
59
@@ -66,7 +65,7 @@ public void testGetPrefix() {
66
65
}
67
66
68
67
@ Test
69
- public void testGetPrefixes () {
68
+ void testGetPrefixes () {
70
69
71
70
context .bindDefaultNamespaceUri ("defaultNamespaceURI" );
72
71
@@ -78,22 +77,18 @@ public void testGetPrefixes() {
78
77
}
79
78
80
79
@ Test
81
- public void unmodifiableGetPrefixes () {
82
-
83
- assertThatExceptionOfType (UnsupportedOperationException .class ).isThrownBy (() -> {
84
-
85
- String namespaceUri = "namespaceUri" ;
86
- context .bindNamespaceUri ("prefix1" , namespaceUri );
87
- context .bindNamespaceUri ("prefix2" , namespaceUri );
80
+ void unmodifiableGetPrefixes () {
81
+ String namespaceUri = "namespaceUri" ;
82
+ context .bindNamespaceUri ("prefix1" , namespaceUri );
83
+ context .bindNamespaceUri ("prefix2" , namespaceUri );
88
84
89
- Iterator <String > prefixes = context .getPrefixes (namespaceUri );
90
- prefixes .next ();
91
- prefixes .remove ();
92
- });
85
+ Iterator <String > prefixes = context .getPrefixes (namespaceUri );
86
+ prefixes .next ();
87
+ assertThatExceptionOfType (UnsupportedOperationException .class ).isThrownBy (prefixes ::remove );
93
88
}
94
89
95
90
@ Test
96
- public void testMultiplePrefixes () {
91
+ void testMultiplePrefixes () {
97
92
98
93
context .bindNamespaceUri ("prefix1" , "namespace" );
99
94
context .bindNamespaceUri ("prefix2" , "namespace" );
@@ -130,7 +125,7 @@ private void assertPrefixes(String namespaceUri, String prefix) {
130
125
}
131
126
132
127
@ Test
133
- public void testGetBoundPrefixes () {
128
+ void testGetBoundPrefixes () {
134
129
135
130
Iterator <String > iterator = context .getBoundPrefixes ();
136
131
@@ -144,15 +139,15 @@ public void testGetBoundPrefixes() {
144
139
}
145
140
146
141
@ Test
147
- public void testSetBindings () {
142
+ void testSetBindings () {
148
143
149
144
context .setBindings (Collections .singletonMap ("prefix" , "namespace" ));
150
145
151
146
assertThat (context .getNamespaceURI ("prefix" )).isEqualTo ("namespace" );
152
147
}
153
148
154
149
@ Test
155
- public void testRemoveBinding () {
150
+ void testRemoveBinding () {
156
151
157
152
context .clear ();
158
153
@@ -175,7 +170,7 @@ public void testRemoveBinding() {
175
170
}
176
171
177
172
@ Test
178
- public void testHasBinding () {
173
+ void testHasBinding () {
179
174
180
175
context .clear ();
181
176
@@ -190,7 +185,7 @@ public void testHasBinding() {
190
185
}
191
186
192
187
@ Test
193
- public void testDefaultNamespaceMultiplePrefixes () {
188
+ void testDefaultNamespaceMultiplePrefixes () {
194
189
195
190
String defaultNamespace = "http://springframework.org/spring-ws" ;
196
191
0 commit comments