1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package tests;
20
21 import junit.framework.TestCase;
22 import org.apache.ws.commons.schema.*;
23
24 import javax.xml.namespace.QName;
25 import javax.xml.transform.stream.StreamSource;
26 import java.io.FileInputStream;
27 import java.io.InputStream;
28 import java.util.HashSet;
29 import java.util.Iterator;
30 import java.util.Set;
31
32 public class FacetsTest extends TestCase {
33
34
35
36
37
38
39 public void testLengthFacet() throws Exception {
40
41
42
43
44
45
46
47
48
49
50
51 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
52 "myZipCode");
53 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
54 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
55 schemaCol.read(new StreamSource(is), null);
56
57 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
58 assertNotNull(elem);
59 assertEquals("myZipCode", elem.getName());
60 assertEquals(new QName("http://soapinterop.org/types", "myZipCode"),
61 elem.getQName());
62 assertEquals(new QName("http://soapinterop.org/types", "zipCode"),
63 elem.getSchemaTypeName());
64
65 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
66
67 XmlSchemaSimpleTypeRestriction r =
68 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
69 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
70 r.getBaseTypeName());
71
72 XmlSchemaSimpleType xsst = r.getBaseType();
73 assertNull(xsst);
74
75 XmlSchemaObjectCollection collection = r.getFacets();
76 assertEquals(2, collection.getCount());
77
78 Set s = new HashSet();
79 s.add(XmlSchemaLengthFacet.class.getName());
80 s.add(XmlSchemaPatternFacet.class.getName());
81 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
82 Object o = i.next();
83 assertTrue(s.remove(o.getClass().getName()));
84 if (o instanceof XmlSchemaLengthFacet) {
85 assertEquals("5", ((XmlSchemaLengthFacet)o).getValue());
86 assertEquals(false, ((XmlSchemaLengthFacet)o).isFixed());
87 String toStr = ((XmlSchemaLengthFacet)o).toString("xsd", 1);
88 assertTrue("The toString(String, int) method did not contain "
89 + "\"length\", but did contain: " + toStr,
90 toStr.indexOf("length value=\"5\"") != -1);
91 } else if (o instanceof XmlSchemaPatternFacet) {
92 assertEquals("\\d{5}", ((XmlSchemaPatternFacet)o).getValue());
93 assertEquals(false, ((XmlSchemaPatternFacet)o).isFixed());
94 String toStr = ((XmlSchemaPatternFacet)o).toString("xsd", 1);
95 assertTrue("The toString(String, int) method did not contain "
96 + "\"pattern\", but did contain: " + toStr,
97 toStr.indexOf("pattern value=\"\\d{5}\"") != -1);
98 } else {
99 fail("Unexpected object encountered: " + o.getClass().getName());
100 }
101 }
102
103 assertTrue("The set should have been empty, but instead contained: "
104 + s + ".",
105 s.isEmpty());
106
107 }
108
109
110
111
112
113
114 public void testPatternFacet() throws Exception {
115
116
117
118
119
120
121
122
123
124
125 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
126 "myCreditCardNumber");
127 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
128 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
129 schemaCol.read(new StreamSource(is), null);
130
131 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
132 assertNotNull(elem);
133 assertEquals("myCreditCardNumber", elem.getName());
134 assertEquals(new QName("http://soapinterop.org/types", "myCreditCardNumber"),
135 elem.getQName());
136 assertEquals(new QName("http://soapinterop.org/types", "creditCardNumber"),
137 elem.getSchemaTypeName());
138
139 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
140
141 XmlSchemaSimpleTypeRestriction r =
142 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
143 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
144 r.getBaseTypeName());
145
146 XmlSchemaSimpleType xsst = r.getBaseType();
147 assertNull(xsst);
148
149 XmlSchemaObjectCollection collection = r.getFacets();
150 assertEquals(1, collection.getCount());
151
152 Set s = new HashSet();
153 s.add(XmlSchemaPatternFacet.class.getName());
154 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
155 Object o = i.next();
156 assertTrue(s.remove(o.getClass().getName()));
157 if (o instanceof XmlSchemaPatternFacet) {
158 assertEquals("\\d{15}", ((XmlSchemaPatternFacet)o).getValue());
159 assertEquals(false, ((XmlSchemaPatternFacet)o).isFixed());
160 String toStr = ((XmlSchemaPatternFacet)o).toString("xsd", 1);
161 assertTrue("The toString(String, int) method did not contain "
162 + "\"pattern\", but did contain: " + toStr,
163 toStr.indexOf("pattern value=\"\\d{15}\"") != -1);
164 } else {
165 fail("Unexpected object encountered: " + o.getClass().getName());
166 }
167 }
168
169 assertTrue("The set should have been empty, but instead contained: "
170 + s + ".",
171 s.isEmpty());
172
173 }
174
175
176
177
178
179
180 public void testTotalDigitsFacet() throws Exception {
181
182
183
184
185
186
187
188
189
190
191 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
192 "myAge");
193 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
194 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
195 schemaCol.read(new StreamSource(is), null);
196
197 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
198 assertNotNull(elem);
199 assertEquals("myAge", elem.getName());
200 assertEquals(new QName("http://soapinterop.org/types", "myAge"),
201 elem.getQName());
202 assertEquals(new QName("http://soapinterop.org/types", "age"),
203 elem.getSchemaTypeName());
204
205 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
206
207 XmlSchemaSimpleTypeRestriction r =
208 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
209 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"),
210 r.getBaseTypeName());
211
212 XmlSchemaSimpleType xsst = r.getBaseType();
213 assertNull(xsst);
214
215 XmlSchemaObjectCollection collection = r.getFacets();
216 assertEquals(1, collection.getCount());
217
218 Set s = new HashSet();
219 s.add(XmlSchemaTotalDigitsFacet.class.getName());
220 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
221 Object o = i.next();
222 assertTrue(s.remove(o.getClass().getName()));
223 if (o instanceof XmlSchemaTotalDigitsFacet) {
224 assertEquals("3", ((XmlSchemaTotalDigitsFacet)o).getValue());
225 assertEquals(false, ((XmlSchemaTotalDigitsFacet)o).isFixed());
226 String toStr = ((XmlSchemaTotalDigitsFacet)o).toString("xsd", 1);
227 assertTrue("The toString(String, int) method did not contain "
228 + "\"totalDigits\", but did contain: " + toStr,
229 toStr.indexOf("totalDigits value=\"3\"") != -1);
230 } else {
231 fail("Unexpected object encountered: " + o.getClass().getName());
232 }
233 }
234
235 assertTrue("The set should have been empty, but instead contained: "
236 + s + ".",
237 s.isEmpty());
238
239 }
240
241
242
243
244
245
246 public void testMinMaxInclusiveFacets() throws Exception {
247
248
249
250
251
252
253
254
255
256
257
258 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
259 "myDistance");
260 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
261 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
262 schemaCol.read(new StreamSource(is), null);
263
264 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
265 assertNotNull(elem);
266 assertEquals("myDistance", elem.getName());
267 assertEquals(new QName("http://soapinterop.org/types", "myDistance"),
268 elem.getQName());
269 assertEquals(new QName("http://soapinterop.org/types", "distance"),
270 elem.getSchemaTypeName());
271
272 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
273
274 XmlSchemaSimpleTypeRestriction r =
275 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
276 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
277 r.getBaseTypeName());
278
279 XmlSchemaSimpleType xsst = r.getBaseType();
280 assertNull(xsst);
281
282 XmlSchemaObjectCollection collection = r.getFacets();
283 assertEquals(2, collection.getCount());
284
285 Set s = new HashSet();
286 s.add(XmlSchemaMaxInclusiveFacet.class.getName());
287 s.add(XmlSchemaMinInclusiveFacet.class.getName());
288 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
289 Object o = i.next();
290 assertTrue(s.remove(o.getClass().getName()));
291 if (o instanceof XmlSchemaMaxInclusiveFacet) {
292 assertEquals("100", ((XmlSchemaMaxInclusiveFacet)o).getValue());
293 assertEquals(true, ((XmlSchemaMaxInclusiveFacet)o).isFixed());
294 String toStr = ((XmlSchemaMaxInclusiveFacet)o).toString("xsd", 1);
295 assertTrue("The toString(String, int) method did not contain "
296 + "\"maxInclusive\", but did contain: " + toStr,
297 toStr.indexOf("maxInclusive value=\"100\"") != -1);
298 } else if (o instanceof XmlSchemaMinInclusiveFacet) {
299 assertEquals("0", ((XmlSchemaMinInclusiveFacet)o).getValue());
300 assertEquals(false, ((XmlSchemaMinInclusiveFacet)o).isFixed());
301 String toStr = ((XmlSchemaMinInclusiveFacet)o).toString("xsd", 1);
302 assertTrue("The toString(String, int) method did not contain "
303 + "\"minInclusive\", but did contain: " + toStr,
304 toStr.indexOf("minInclusive value=\"0\"") != -1);
305 } else {
306 fail("Unexpected object encountered: " + o.getClass().getName());
307 }
308 }
309
310 assertTrue("The set should have been empty, but instead contained: "
311 + s + ".",
312 s.isEmpty());
313
314 }
315
316
317
318
319
320
321 public void testMinMaxExlusiveFacets() throws Exception {
322
323
324
325
326
327
328
329
330
331
332
333 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
334 "myWeight");
335 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
336 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
337 schemaCol.read(new StreamSource(is), null);
338
339 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
340 assertNotNull(elem);
341 assertEquals("myWeight", elem.getName());
342 assertEquals(new QName("http://soapinterop.org/types", "myWeight"),
343 elem.getQName());
344 assertEquals(new QName("http://soapinterop.org/types", "weight"),
345 elem.getSchemaTypeName());
346
347 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
348
349 XmlSchemaSimpleTypeRestriction r =
350 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
351 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
352 r.getBaseTypeName());
353
354 XmlSchemaSimpleType xsst = r.getBaseType();
355 assertNull(xsst);
356
357 XmlSchemaObjectCollection collection = r.getFacets();
358 assertEquals(2, collection.getCount());
359
360 Set s = new HashSet();
361 s.add(XmlSchemaMaxExclusiveFacet.class.getName());
362 s.add(XmlSchemaMinExclusiveFacet.class.getName());
363 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
364 Object o = i.next();
365 assertTrue(s.remove(o.getClass().getName()));
366 if (o instanceof XmlSchemaMaxExclusiveFacet) {
367 assertEquals("200", ((XmlSchemaMaxExclusiveFacet)o).getValue());
368 assertEquals(false, ((XmlSchemaMaxExclusiveFacet)o).isFixed());
369 String toStr = ((XmlSchemaMaxExclusiveFacet)o).toString("xsd", 1);
370 assertTrue("The toString(String, int) method did not contain "
371 + "\"maxExclusive\", but did contain: " + toStr,
372 toStr.indexOf("maxExclusive value=\"200\"") != -1);
373 } else if (o instanceof XmlSchemaMinExclusiveFacet) {
374 assertEquals("1", ((XmlSchemaMinExclusiveFacet)o).getValue());
375 assertEquals(false, ((XmlSchemaMinExclusiveFacet)o).isFixed());
376 String toStr = ((XmlSchemaMinExclusiveFacet)o).toString("xsd", 1);
377 assertTrue("The toString(String, int) method did not contain "
378 + "\"minExclusive\", but did contain: " + toStr,
379 toStr.indexOf("minExclusive value=\"1\"") != -1);
380 } else {
381 fail("Unexpected object encountered: " + o.getClass().getName());
382 }
383 }
384
385 assertTrue("The set should have been empty, but instead contained: "
386 + s + ".",
387 s.isEmpty());
388
389 }
390
391
392
393
394
395
396 public void testWhiteSpaceFacet() throws Exception {
397
398
399
400
401
402
403
404
405
406
407 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
408 "myWhiteSpace");
409 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
410 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
411 schemaCol.read(new StreamSource(is), null);
412
413 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
414 assertNotNull(elem);
415 assertEquals("myWhiteSpace", elem.getName());
416 assertEquals(new QName("http://soapinterop.org/types", "myWhiteSpace"),
417 elem.getQName());
418 assertEquals(new QName("http://soapinterop.org/types", "noWhiteSpace"),
419 elem.getSchemaTypeName());
420
421 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
422
423 XmlSchemaSimpleTypeRestriction r =
424 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
425 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "normalizedString"),
426 r.getBaseTypeName());
427
428 XmlSchemaSimpleType xsst = r.getBaseType();
429 assertNull(xsst);
430
431 XmlSchemaObjectCollection collection = r.getFacets();
432 assertEquals(1, collection.getCount());
433
434 Set s = new HashSet();
435 s.add(XmlSchemaWhiteSpaceFacet.class.getName());
436 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
437 Object o = i.next();
438 assertTrue(s.remove(o.getClass().getName()));
439 if (o instanceof XmlSchemaWhiteSpaceFacet) {
440 assertEquals("collapse", ((XmlSchemaWhiteSpaceFacet)o).getValue());
441 assertEquals(false, ((XmlSchemaWhiteSpaceFacet)o).isFixed());
442 String toStr = ((XmlSchemaWhiteSpaceFacet)o).toString("xsd", 1);
443 assertTrue("The toString(String, int) method did not contain "
444 + "\"minExclusive\", but did contain: " + toStr,
445 toStr.indexOf("whiteSpace value=\"collapse\"") != -1);
446 } else {
447 fail("Unexpected object encountered: " + o.getClass().getName());
448 }
449 }
450
451 assertTrue("The set should have been empty, but instead contained: "
452 + s + ".",
453 s.isEmpty());
454
455 }
456
457
458
459
460
461
462 public void testFractionDigitsFacet() throws Exception {
463
464
465
466
467
468
469
470
471
472
473
474 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
475 "myHeight");
476 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
477 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
478 schemaCol.read(new StreamSource(is), null);
479
480 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
481 assertNotNull(elem);
482 assertEquals("myHeight", elem.getName());
483 assertEquals(new QName("http://soapinterop.org/types", "myHeight"),
484 elem.getQName());
485 assertEquals(new QName("http://soapinterop.org/types", "height"),
486 elem.getSchemaTypeName());
487
488 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
489
490 XmlSchemaSimpleTypeRestriction r =
491 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
492 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"),
493 r.getBaseTypeName());
494
495 XmlSchemaSimpleType xsst = r.getBaseType();
496 assertNull(xsst);
497
498 XmlSchemaObjectCollection collection = r.getFacets();
499 assertEquals(2, collection.getCount());
500
501 Set s = new HashSet();
502 s.add(XmlSchemaFractionDigitsFacet.class.getName());
503 s.add(XmlSchemaTotalDigitsFacet.class.getName());
504 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
505 Object o = i.next();
506 assertTrue(s.remove(o.getClass().getName()));
507 if (o instanceof XmlSchemaFractionDigitsFacet) {
508 assertEquals("2", ((XmlSchemaFractionDigitsFacet)o).getValue());
509 assertEquals(false, ((XmlSchemaFractionDigitsFacet)o).isFixed());
510 String toStr = ((XmlSchemaFractionDigitsFacet)o).toString("xsd", 1);
511 assertTrue("The toString(String, int) method did not contain "
512 + "\"fractionDigits\", but did contain: " + toStr,
513 toStr.indexOf("fractionDigits value=\"2\"") != -1);
514 } else if (o instanceof XmlSchemaTotalDigitsFacet) {
515 assertEquals("3", ((XmlSchemaTotalDigitsFacet)o).getValue());
516 assertEquals(false, ((XmlSchemaTotalDigitsFacet)o).isFixed());
517 String toStr = ((XmlSchemaTotalDigitsFacet)o).toString("xsd", 1);
518 assertTrue("The toString(String, int) method did not contain "
519 + "\"totalDigits\", but did contain: " + toStr,
520 toStr.indexOf("totalDigits value=\"3\"") != -1);
521 } else {
522 fail("Unexpected object encountered: " + o.getClass().getName());
523 }
524 }
525
526 assertTrue("The set should have been empty, but instead contained: "
527 + s + ".",
528 s.isEmpty());
529
530 }
531
532
533
534
535
536
537 public void testMinMaxLengthFacets() throws Exception {
538
539
540
541
542
543
544
545
546
547
548
549 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
550 "myYardLength");
551 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
552 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
553 schemaCol.read(new StreamSource(is), null);
554
555 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
556 assertNotNull(elem);
557 assertEquals("myYardLength", elem.getName());
558 assertEquals(new QName("http://soapinterop.org/types", "myYardLength"),
559 elem.getQName());
560 assertEquals(new QName("http://soapinterop.org/types", "yardLength"),
561 elem.getSchemaTypeName());
562
563 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
564
565 XmlSchemaSimpleTypeRestriction r =
566 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
567 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger"),
568 r.getBaseTypeName());
569
570 XmlSchemaSimpleType xsst = r.getBaseType();
571 assertNull(xsst);
572
573 XmlSchemaObjectCollection collection = r.getFacets();
574 assertEquals(2, collection.getCount());
575
576 Set s = new HashSet();
577 s.add(XmlSchemaMinLengthFacet.class.getName());
578 s.add(XmlSchemaMaxLengthFacet.class.getName());
579 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
580 Object o = i.next();
581 assertTrue(s.remove(o.getClass().getName()));
582 if (o instanceof XmlSchemaMinLengthFacet) {
583 assertEquals("45", ((XmlSchemaMinLengthFacet)o).getValue());
584 assertEquals(false, ((XmlSchemaMinLengthFacet)o).isFixed());
585 String toStr = ((XmlSchemaMinLengthFacet)o).toString("xsd", 1);
586 assertTrue("The toString(String, int) method did not contain "
587 + "\"minExclusive\", but did contain: " + toStr,
588 toStr.indexOf("minLength value=\"45\"") != -1);
589 } else if (o instanceof XmlSchemaMaxLengthFacet) {
590 assertEquals("205", ((XmlSchemaMaxLengthFacet)o).getValue());
591 assertEquals(false, ((XmlSchemaMaxLengthFacet)o).isFixed());
592 String toStr = ((XmlSchemaMaxLengthFacet)o).toString("xsd", 1);
593 assertTrue("The toString(String, int) method did not contain "
594 + "\"maxLength\", but did contain: " + toStr,
595 toStr.indexOf("maxLength value=\"205\"") != -1);
596 } else {
597 fail("Unexpected object encountered: " + o.getClass().getName());
598 }
599 }
600
601 assertTrue("The set should have been empty, but instead contained: "
602 + s + ".",
603 s.isEmpty());
604
605 }
606
607
608
609
610
611
612 public void testEnumerationFacet() throws Exception {
613
614
615
616
617
618
619
620
621
622
623
624 QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
625 "layoutComponent");
626 InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
627 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
628 schemaCol.read(new StreamSource(is), null);
629
630 XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
631 assertNotNull(elem);
632 assertEquals("layoutComponent", elem.getName());
633 assertEquals(new QName("http://soapinterop.org/types", "layoutComponent"),
634 elem.getQName());
635 assertEquals(new QName("http://soapinterop.org/types", "layoutComponentType"),
636 elem.getSchemaTypeName());
637
638 XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
639
640 XmlSchemaSimpleTypeRestriction r =
641 (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
642 assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
643 r.getBaseTypeName());
644
645 XmlSchemaSimpleType xsst = r.getBaseType();
646 assertNull(xsst);
647
648 XmlSchemaObjectCollection collection = r.getFacets();
649 assertEquals(2, collection.getCount());
650
651 Set s = new HashSet();
652 s.add("Field");
653 s.add("Separator");
654 for (Iterator i = collection.getIterator(); i.hasNext(); ) {
655 XmlSchemaEnumerationFacet xsef = (XmlSchemaEnumerationFacet)i.next();
656 String value = (String)xsef.getValue();
657 assertTrue("Atempted to remove an enumeration with the value of "
658 + "\"" + value + "\", but the value was not in the set.",
659 s.remove(value));
660 String toStr = xsef.toString("xsd", 1);
661 if (value.equals("Field")) {
662 assertTrue("The toString(String, int) method did not contain "
663 + "\"enumeration\", but did contain: " + toStr,
664 toStr.indexOf("enumeration value=\"Field\"") != -1);
665 } else if (value.equals("Separator")) {
666 assertTrue("The toString(String, int) method did not contain "
667 + "\"enumeration\", but did contain: " + toStr,
668 toStr.indexOf("enumeration value=\"Separator\"") != -1);
669 }
670 }
671
672 assertTrue("The set should have been empty, but instead contained: "
673 + s + ".",
674 s.isEmpty());
675
676 }
677
678 }