summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/xsd/XSDComplexTypeTest.java
blob: ad1b446c3a11e9e4b6913cd2023101b9c1210901 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
package test.sdo21.tests.xsd;

import java.util.List;
import java.io.IOException;

import commonj.sdo.Type;
import commonj.sdo.Property;
import commonj.sdo.DataObject;

import org.junit.Test;
import static org.junit.Assert.*;

public class XSDComplexTypeTest extends XSDBaseTestCase {

  /**
   * <complexType> containing other elements.
   *
   * @throws Exception
   */
  @Test
  public void testTC128ComplexTypeWithElement() throws Exception {

    // parse the schema
    List types = define("/complexType/cT_01.xsd");

    Type type = (Type) types.get(0);
    assertFalse(type.isSequenced());
    assertFalse(type.isOpen());
    assertFalse(type.isDataType());
    assertFalse(type.isAbstract());
    assertEquals("cT_01", type.getName());

    assertPropertyExists(type, "id", "Int", false, false);
    assertPropertyExists(type, "name", "String", false, false);
  }

  /**
   * <complexType> with abstract="true".
   *
   * @throws Exception
   */
  @Test public void testTC129ComplexTypeAbstractTrue() throws Exception {

    List types = define("/complexType/cT_02.xsd");

    Type type = (Type) types.get(0);
    assertFalse(type.isSequenced());
    assertEquals("cT_02", type.getName());
    assertTrue(type.isAbstract());

    assertPropertyExists(type, "id", "Int", false, false);
    assertFalse(type.getProperty("id").isReadOnly() );
    assertPropertyExists(type, "name", "String", false, false);
    assertFalse(type.getProperty("name").isReadOnly() );
  }

  /**
   * <complexType> extending another <complexType>.
   *
   * @throws Exception
   */
  @Test public void testTC130ComplexTypeExtendingComplexType() throws Exception {

    List types = define("/complexType/cT_03.xsd");
    assertTrue(types.size() >= 2);

    // parent
    Type parentType = getType(types, "cT_03_parent");

    List properties = parentType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p1 = (Property) properties.get(0);

    assertEquals("id", p1.getName());
    assertEquals("Int", p1.getType().getName());

    // child
    Type childType = getType(types, "cT_03_child");

    List baseTypes = childType.getBaseTypes();
    assertEquals(1, baseTypes.size());
    Type baseType = (Type) baseTypes.get(0);
    assertEquals("cT_03_parent", baseType.getName());

    properties = childType.getProperties();
    assertEquals(2, properties.size());
    assertEquals(1, childType.getDeclaredProperties().size() );

    //verify name and type of Properties
    // base properties appear first, derived properties are appended
    Property childTypeProp1 = (Property) properties.get(0);
    assertEquals("id", childTypeProp1.getName());
    assertEquals("Int", childTypeProp1.getType().getName());

    Property childTypeProp2 = (Property) properties.get(1);
    assertEquals("name", childTypeProp2.getName());
    assertEquals("String", childTypeProp2.getType().getName());
  }

  /**
   * <complexType> derived from <complexType> with block="#all" (should not affect SDO Types generated).
   *
   * @throws Exception
   */
  @Test public void testTC131ComplexTypeBlockAll() throws Exception {
    List types = define("/complexType/cT_04.xsd");
    assertTrue(types.size() >= 2);

    // parent
    Type parentType = getType(types, "cT_04_parent");

    List properties = parentType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p1 = (Property) properties.get(0);

    assertEquals("id", p1.getName());
    assertEquals("Int", p1.getType().getName());

    // child
    Type childType = getType(types, "cT_04_child");

    List baseTypes = childType.getBaseTypes();
    assertEquals(1, baseTypes.size());
    Type baseType = (Type) baseTypes.get(0);
    assertEquals("cT_04_parent", baseType.getName());

    properties = childType.getProperties();
    assertEquals(2, properties.size());
    assertEquals(1, childType.getDeclaredProperties().size() );

    //verify name and type of Properties
    // base properties appear first, derived properties are appended
    Property childTypeProp1 = (Property) properties.get(0);
    assertEquals("id", childTypeProp1.getName());
    assertEquals("Int", childTypeProp1.getType().getName());

    Property childTypeProp2 = (Property) properties.get(1);
    assertEquals("name", childTypeProp2.getName());
    assertEquals("String", childTypeProp2.getType().getName());
  }

  /**
   * <complexType> containing <group> containing <sequence>.
   *
   * @throws Exception
   */
  @Test public void testTC132ComplexTypeGroupWithSequence() throws Exception {
    List types = define("/complexType/cT_05.xsd");

    Type type = (Type) types.get(0);
    assertEquals("cT_05", type.getName());
    assertFalse(type.isAbstract());

    assertPropertyExists(type, "id", "Int", false, false);
    assertFalse(type.getProperty("id").isReadOnly());
    assertPropertyExists(type, "name", "String", false, false);
    assertFalse(type.getProperty("name").isReadOnly());
  }

  /**
   * <element> name="cT_06" containing anonymous <complexType>.
   *
   * @throws Exception
   */
  @Test public void testTC133ComplexTypeAnonymous() throws Exception {
    List types = define("/complexType/cT_06.xsd");

    // The spec maps the name of anonymous types to the name
    // of their enclosing element. This is a broken method however,
    // as it can conflict with same named types and other same
    // named elements with anonymous types. So currently we are
    // intentially non-compliant. using unique names for
    // anonymous types

    Property property = typeHelper.getOpenContentProperty( "http://www.example.com/xsd/6/",
                                                         "cT_06" );
    Type type = property.getType();
    assertFalse(type.isAbstract());
    assertFalse(type.isSequenced());

    assertPropertyExists(type, "id", "Int", false, false);
    assertFalse(type.getProperty("id").isReadOnly());
    assertPropertyExists(type, "name", "String", false, false);
    assertFalse(type.getProperty("name").isReadOnly());
  }

  /**
   * <complexType> with name.
   *
   * @throws Exception
   */
  @Test public void testTC134ComplexTypeNamed() throws Exception {
    List types = define("/complexType/cT_07.xsd");

    Type type = (Type) types.get(0);
    assertEquals("cT_07", type.getName());
    assertFalse(type.isAbstract());
    assertFalse(type.isSequenced());

    assertPropertyExists(type, "id", "Int", false, false);
    assertFalse(type.getProperty("id").isReadOnly());
    assertPropertyExists(type, "name", "String", false, false);
    assertFalse(type.getProperty("name").isReadOnly());
  }

  /**
   * <complexType> with final="true" containing <complexContent> containing <extension> of a <complexType> with abstract="true".
   *
   * @throws Exception
   */
  @Test public void testTC136ComplexTypeExtendAbstractTrue() throws Exception {
    List types = define("/complexType/cT_09.xsd");
    assertTrue(types.size() >= 2);

    // parent
    Type parentType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_parent");

    List properties = parentType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p1 = (Property) properties.get(0);

    assertEquals("id", p1.getName());
    assertEquals("Int", p1.getType().getName());

    // child
    Type childType = typeHelper.getType("http://www.example.com/xsd/9/", "cT_09_child");

    List baseTypes = childType.getBaseTypes();
    assertEquals(1, baseTypes.size());
    Type baseType = (Type) baseTypes.get(0);
    assertEquals("cT_09_parent", baseType.getName());

    properties = childType.getDeclaredProperties();
    assertEquals(1, properties.size());
    assertEquals(2, childType.getProperties().size() );

    Property p2 = (Property) properties.get(0);

    assertEquals("name", p2.getName());
    assertEquals("String", p2.getType().getName());
  }

  /**
   * <complexType> containing <complexContent> containing <restriction> of a <complexType> with abstract="true".
   *
   * @throws Exception
   */
  @Test public void testTC137ComplexTypeExtendWithRestriction() throws Exception {
    List types = define("/complexType/cT_10.xsd");
    assertTrue(types.size() >= 2);

    // parent
    Type parentType = getType(types, "cT_10_parent");

    List properties = parentType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p1 = (Property) properties.get(0);
    assertEquals("id", p1.getName());
    assertEquals("Int", p1.getType().getName());

    // child
    Type childType = getType(types, "cT_10_child");

    List baseTypes = childType.getBaseTypes();
    assertEquals(1, baseTypes.size());
    Type baseType = (Type) baseTypes.get(0);
    assertEquals("cT_10_parent", baseType.getName());

    properties = childType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p2 = (Property) properties.get(0);
    assertEquals("name", p2.getName());
    assertEquals("String", p2.getType().getName());
  }

  /**
   * <complexType> containing <complexContent> containing <extension> of a <complexType> with abstract="true".
   *
   * @throws Exception
   */
  @Test public void testTC138ComplexTypeExtend() throws Exception {
    List types = define("/complexType/cT_11.xsd");
    assertTrue(types.size() >= 2);

    // parent
    Type parentType = getType(types, "cT_11_parent");

    List properties = parentType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p1 = (Property) properties.get(0);

    assertEquals("id", p1.getName());
    assertEquals("Int", p1.getType().getName());

    // child
    Type childType = getType(types, "cT_11_child");

    List baseTypes = childType.getBaseTypes();
    assertEquals(1, baseTypes.size());
    Type baseType = (Type) baseTypes.get(0);
    assertEquals("cT_11_parent", baseType.getName());

    properties = childType.getDeclaredProperties();
    assertEquals(1, properties.size());

    Property p2 = (Property) properties.get(0);

    assertEquals("name", p2.getName());
    assertEquals("String", p2.getType().getName());
  }

  /**
   * <complexType> containing <simpleContent> containing <extension>.
   *
   * @throws Exception
   */
  @Test public void testTC143ComplexTypeSimpleContent() throws Exception {
    List types = define("/complexType/cT_18.xsd");

    Type type = typeHelper.getType("http://www.example.com/xsd/18/", "cT_18");

    // 10.8. Corner cases
    // ...
    // 5. In some cases it is not possible to maintain an SDO base
    //    relationship when one exists in schema. This can happen for
    //    example when complex types extend simple types
    //
    // So a complexType extending a simple type doesn't have an SDO
    // base type set

    List baseTypes = type.getBaseTypes();
    assertEquals(0, baseTypes.size());

    // however complex types with simple content get a special
    // property named "value" to represent their content
    // p100, box 3 of the latest C++ 2.1 draft
    // Complex Type extending a SimpleType
    // <complexType name=[NAME]>
    // <simpleContent>
    // <extension
    // base=[BASE]/>
    // </simpleContent>
    // </complexType>
    //
    // Type name=[NAME]
    // uri=[URI]
    // Property:
    // name="value" type=[BASE]
    // Properties are created for attribute
    // declarations.

    Property valueProperty = type.getProperty("value");
    Type valueType = valueProperty.getType();
    assertEquals("String", valueType.getName());
    assertEquals("commonj.sdo", valueType.getURI());
  }

  /**
   * <complexType> containing <simpleContent> containing <extension> containing <attribute>.
   *
   * @throws Exception
   */
  @Test public void test_cT_19() throws Exception {
    List types = define("/complexType/cT_19.xsd");

    // parent
    Type type = getType(types, "cT_19");

    // 10.8. Corner cases
    // ...
    // 5. In some cases it is not possible to maintain an SDO base
    //    relationship when one exists in schema. This can happen for
    //    example when complex types extend simple types
    //
    // So a complexType extending a simple type doesn't have an SDO
    // base type set

    List baseTypes = type.getBaseTypes();
    assertEquals(0, baseTypes.size());

    List properties = type.getDeclaredProperties();
    assertEquals(2, properties.size());

    Property p1 = type.getProperty( "lang" );
    assertEquals("String", p1.getType().getName());

    // however complex types with simple content get a special
    // property named "value" to represent their content
    // p100, box 3 of the latest C++ 2.1 draft
    // Complex Type extending a SimpleType
    // <complexType name=[NAME]>
    // <simpleContent>
    // <extension
    // base=[BASE]/>
    // </simpleContent>
    // </complexType>
    //
    // Type name=[NAME]
    // uri=[URI]
    // Property:
    // name="value" type=[BASE]
    // Properties are created for attribute
    // declarations.

    Property valueProperty = type.getProperty("value");
    Type valueType = valueProperty.getType();
    assertEquals("String", valueType.getName());
    assertEquals("commonj.sdo", valueType.getURI());
  }

  /**
   * <complexType> containing <simpleContent> containing <extension> containing <attribute>.
   *
   * @throws Exception
   */
  @Test public void test_cT_22() throws Exception {
    List types = define("/complexType/cT_22.xsd");

    Type type = getType(types, "cT_22");
    assertFalse(type.isSequenced());

    // 10.8. Corner cases
    // ...
    // 5. In some cases it is not possible to maintain an SDO base
    //    relationship when one exists in schema. This can happen for
    //    example when complex types extend simple types
    //
    // So a complexType extending a simple type doesn't have an SDO
    // base type set

    List baseTypes = type.getBaseTypes();
    assertEquals(0, baseTypes.size());

    List properties = type.getDeclaredProperties();
    assertEquals(2, properties.size());

    Property p1 = type.getProperty( "lang" );
    assertEquals("String", p1.getType().getName());

    // however complex types with simple content get a special
    // property named "value" to represent their content
    // p100, box 3 of the latest C++ 2.1 draft
    // Complex Type extending a SimpleType
    // <complexType name=[NAME]>
    // <simpleContent>
    // <extension
    // base=[BASE]/>
    // </simpleContent>
    // </complexType>
    //
    // Type name=[NAME]
    // uri=[URI]
    // Property:
    // name="value" type=[BASE]
    // Properties are created for attribute
    // declarations.

    Property valueProperty = type.getProperty("value");
    Type valueType = valueProperty.getType();
    assertEquals("String", valueType.getName());
    assertEquals("commonj.sdo", valueType.getURI());
  }

  /**
   * <complexType> containing <simpleContent> containing <extension> containing <attribute>
   * containing <simpleType> containing <restriction>.
   *
   * @throws Exception
   */
  @Test public void test_cT_23() throws Exception {
    List types = define("/complexType/cT_23.xsd");
    // two types are output the one for the complex type
    // and the simple type
    assertTrue(types.size() >= 2);
    Type type = getType(types, "cT_23");
    assertFalse(type.isSequenced());

    // 10.8. Corner cases
    // ...
    // 5. In some cases it is not possible to maintain an SDO base
    //    relationship when one exists in schema. This can happen for
    //    example when complex types extend simple types
    //
    // So a complexType extending a simple type doesn't have an SDO
    // base type set

    List baseTypes = type.getBaseTypes();
    assertEquals(0, baseTypes.size());

    List properties = type.getDeclaredProperties();
    assertEquals(2, properties.size());

    Property p1 = type.getProperty( "lang" );
    assertNotNull( p1 );

    // the actual type here for the lang attribute will be
    // the anonymous simple type, which as it's base will
    // be commonj.sdo#String
    Type langBaseType = (Type)p1.getType().getBaseTypes().get(0);
    assertEquals("String", langBaseType.getName());

    // however complex types with simple content get a special
    // property named "value" to represent their content
    // p100, box 3 of the latest C++ 2.1 draft
    // Complex Type extending a SimpleType
    // <complexType name=[NAME]>
    // <simpleContent>
    // <extension
    // base=[BASE]/>
    // </simpleContent>
    // </complexType>
    //
    // Type name=[NAME]
    // uri=[URI]
    // Property:
    // name="value" type=[BASE]
    // Properties are created for attribute
    // declarations.

    Property valueProperty = type.getProperty("value");
    Type valueType = valueProperty.getType();
    assertEquals("String", valueType.getName());
    assertEquals("commonj.sdo", valueType.getURI());
  }

  /**
   * <complexType> containing <all> containing <element> with minOccurs="1", maxOccurs="1".
   *
   * @throws Exception
   */
  @Test public void testTC300ComplexTypeContainingAllGroupWithElements() throws Exception {
    List types = define("/complexType/cT_24.xsd");
    Type type = getType(types, "cT_24");
    assertPropertyExists(type, "p1", "String", false, false);
  }

  /**
   * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="1".
   *
   * @throws Exception
   */
  @Test public void test_cT_25() throws Exception {
    List types = define("/complexType/cT_25.xsd");
    Type type = getType(types, "cT_25");
    assertPropertyExists(type, "p1", "String", false, false);
  }

  /**
   * <complexType> containing <sequence> containing <element> with minOccurs="0", maxOccurs="unbounded".
   *
   * @throws Exception
   */
  @Test public void test_cT_26() throws Exception {
    List types = define("/complexType/cT_26.xsd");
    Type type = getType(types, "cT_26");
    assertPropertyExists(type, "p1", "String", false, true);
  }

  /**
   * <complexType> containing <sequence> containing <element> with minOccurs="1", maxOccurs="unbounded".
   *
   * @throws Exception
   */
  @Test public void testTC299ComplexTypeContainingUnboundedElement() throws Exception {
    List types = define("/complexType/cT_27.xsd");
    Type type = typeHelper.getType("http://www.example.com/xsd/27/", "cT_27");
    assertPropertyExists(type, "p1", "String", false, true);
  }

  /**
   * <complexType> containing an <element> for each XSD type supported by SDO.
   *
   * @throws Exception
   */
  @Test public void testTC297ComplexTypeContainingElementsOfAllTypes() throws Exception {
    List types = define("/complexType/cT_28.xsd");

    Type type = getType(types, "cT_28");
    assertFalse(type.isSequenced());
    assertEquals( 44, type.getProperties().size() );
    assertPropertyExists(type, "type_date", "YearMonthDay", false, false);
    assertPropertyExists(type, "type_dateTime", "DateTime", false, false);
    assertPropertyExists(type, "type_decimal", "Decimal", false, false);
    assertPropertyExists(type, "type_double", "Double", false, false);
    assertPropertyExists(type, "type_duration", "Duration", false, false);
    assertPropertyExists(type, "type_float", "Float", false, false);
    assertPropertyExists(type, "type_gDay", "Day", false, false);
    assertPropertyExists(type, "type_gMonth", "Month", false, false);
    assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false);
    assertPropertyExists(type, "type_gYear", "Year", false, false);
    assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false);
    assertPropertyExists(type, "type_int", "Int", false, false);
    assertPropertyExists(type, "type_integer", "Integer", false, false);
    assertPropertyExists(type, "type_long", "Long", false, false);
    assertPropertyExists(type, "type_negativeInteger", "Integer", false, false);
    assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false);
    assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false);
    assertPropertyExists(type, "type_positiveInteger", "Integer", false, false);
    assertPropertyExists(type, "type_short", "Short", false, false);
    assertPropertyExists(type, "type_string", "String", false, false);
    assertPropertyExists(type, "type_time", "Time", false, false);
    assertPropertyExists(type, "type_unsignedByte", "Short", false, false);
    assertPropertyExists(type, "type_unsignedInt", "Long", false, false);
    assertPropertyExists(type, "type_unsignedLong", "Integer", false, false);
    assertPropertyExists(type, "type_unsignedShort", "Int", false, false);
    assertPropertyExists(type, "type_anyType", "DataObject", true, false);
    assertPropertyExists(type, "type_anyURI", "URI", false, false);
    assertPropertyExists(type, "type_base64Binary", "Bytes", false, false);
    assertPropertyExists(type, "type_byte", "Byte", false, false);
    assertPropertyExists(type, "type_ENTITY", "String", false, false);
    assertPropertyExists(type, "type_hexBinary", "Bytes", false, false);
    assertPropertyExists(type, "type_ID", "String", false, false);
    assertPropertyExists(type, "type_IDREF", "String", false, false);
    assertPropertyExists(type, "type_language", "String", false, false);
    assertPropertyExists(type, "type_Name", "String", false, false);
    assertPropertyExists(type, "type_NCName", "String", false, false);
    assertPropertyExists(type, "type_QName", "URI", false, false);
    assertPropertyExists(type, "type_token", "String", false, false);
    assertPropertyExists(type, "type_NMTOKEN", "String", false, false);
    assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false);
    assertPropertyExists(type, "type_IDREFS", "Strings", false, false);
    assertPropertyExists(type, "type_ENTITIES", "Strings", false, false);
    assertPropertyExists(type, "type_anySimpleType", "Object", false, false);
  }

  /**
   * <complexType> containing an <attribute> for each XSD type supported by SDO.
   *
   * @throws Exception
   */
  @Test public void test_cT_29() throws Exception {
    List types = define("/complexType/cT_29.xsd");

    Type type = getType(types, "cT_29");
    assertFalse(type.isSequenced());
    assertPropertyExists(type, "type_date", "YearMonthDay", false, false);
    assertPropertyExists(type, "type_dateTime", "DateTime", false, false);
    assertPropertyExists(type, "type_decimal", "Decimal", false, false);
    assertPropertyExists(type, "type_double", "Double", false, false);
    assertPropertyExists(type, "type_duration", "Duration", false, false);
    assertPropertyExists(type, "type_float", "Float", false, false);
    assertPropertyExists(type, "type_gDay", "Day", false, false);
    assertPropertyExists(type, "type_gMonth", "Month", false, false);
    assertPropertyExists(type, "type_gMonthDay", "MonthDay", false, false);
    assertPropertyExists(type, "type_gYear", "Year", false, false);
    assertPropertyExists(type, "type_gYearMonth", "YearMonth", false, false);
    assertPropertyExists(type, "type_int", "Int", false, false);
    assertPropertyExists(type, "type_integer", "Integer", false, false);
    assertPropertyExists(type, "type_long", "Long", false, false);
    assertPropertyExists(type, "type_negativeInteger", "Integer", false, false);
    assertPropertyExists(type, "type_nonNegativeInteger", "Integer", false, false);
    assertPropertyExists(type, "type_nonPositiveInteger", "Integer", false, false);
    assertPropertyExists(type, "type_positiveInteger", "Integer", false, false);
    assertPropertyExists(type, "type_short", "Short", false, false);
    assertPropertyExists(type, "type_string", "String", false, false);
    assertPropertyExists(type, "type_time", "Time", false, false);
    assertPropertyExists(type, "type_unsignedByte", "Short", false, false);
    assertPropertyExists(type, "type_unsignedInt", "Long", false, false);
    assertPropertyExists(type, "type_unsignedLong", "Integer", false, false);
    assertPropertyExists(type, "type_unsignedShort", "Int", false, false);
    assertPropertyExists(type, "type_anyURI", "URI", false, false);
    assertPropertyExists(type, "type_base64Binary", "Bytes", false, false);
    assertPropertyExists(type, "type_byte", "Byte", false, false);
    assertPropertyExists(type, "type_ENTITIES", "Strings", false, false);
    assertPropertyExists(type, "type_ENTITY", "String", false, false);
    assertPropertyExists(type, "type_hexBinary", "Bytes", false, false);
    assertPropertyExists(type, "type_ID", "String", false, false);
    assertPropertyExists(type, "type_IDREF", "String", false, false);
    assertPropertyExists(type, "type_IDREFS", "Strings", false, false);
    assertPropertyExists(type, "type_language", "String", false, false);
    assertPropertyExists(type, "type_Name", "String", false, false);
    assertPropertyExists(type, "type_NMTOKEN", "String", false, false);
    assertPropertyExists(type, "type_NMTOKENS", "Strings", false, false);
    assertPropertyExists(type, "type_QName", "URI", false, false);
    assertPropertyExists(type, "type_token", "String", false, false);
    assertPropertyExists(type, "type_NCName", "String", false, false);
    assertPropertyExists(type, "type_anySimpleType", "Object", false, false);
  }

  /**
   * <complexType> containing a <sequence> which contains a <group> reference and an <element>. The <group>
   * also contains a <sequence>.
   *
   * @throws Exception
   */
  @Test public void test_cT_30() throws Exception {
    List types = define("/complexType/cT_30.xsd");

    Type type = getType(types, "cT_30");
    assertFalse(type.isSequenced());
    assertPropertyExists(type, "p1", "String", false, false);
    assertPropertyExists(type, "p2", "String", false, false);
    assertPropertyExists(type, "p3", "Int", false, false);
  }

  /**
   * <complexContent> using <extension> to extend another <complexContent>. The derived <complexContent>
   * references a <group> which contains a <sequence>.
   *
   * @throws Exception
   */
  @Test public void test_cT_31() throws Exception {
    List types = define("/complexType/cT_31.xsd");
    assertTrue(types.size() >= 2);

    Type type = getType(types, "cT_31");
    assertFalse(type.isSequenced());
    assertPropertyExists(type, "p1", "String", false, false);
    assertPropertyExists(type, "p2", "String", false, false);
    assertPropertyExists(type, "p3", "Int", false, false);
    assertPropertyExists(type, "p4", "String", false, false);
    assertPropertyExists(type, "p5", "String", false, false);
  }

  /**
   * <complexType> with mixed="true". Must create SDO Type with sequenced="true".
   *
   * @throws Exception
   */
  @Test public void test_cT_42() throws Exception {
    List types = define("/complexType/cT_42.xsd");

    Type type = getType(types, "cT_42");
    assertTrue(type.isSequenced());
    assertPropertyExists(type, "id", "Int", false, false);
    assertPropertyExists(type, "name", "String", false, false);
  }


  /**
   * <complexType> containing <any> with maxOccurs="unbounded". Should map to SDO Type with
   * sequenced="true" and no declared properties.
   *
   * @throws Exception
   */
  @Test public void test_cT_43() throws Exception {
    List types = define("/complexType/cT_43.xsd");

    Type type = getType(types, "cT_43");
    assertTrue(type.isOpen());
    assertEquals(0, type.getProperties().size());
  }

  /**
   * <complexType> containing <any> with maxOccurs="1". Should map to SDO Type with
   * sequenced="false" and no declared properties.
   *
   * @throws Exception
   */
  @Test public void test_cT_44() throws Exception {
    List types = define("/complexType/cT_44.xsd");

    Type type = getType(types, "cT_44");
    assertTrue(type.isOpen());
    assertFalse(type.isSequenced());
    assertEquals(0, type.getProperties().size());
  }

  /**
   * <complexType> containing <anyAttribute> . Should map to SDO Type with
   * no declared properties.
   *
   * @throws Exception
   */
  @Test public void test_cT_45() throws Exception {
    List types = define("/complexType/cT_45.xsd");

    Type type = getType(types, "cT_45");
    assertTrue(type.isOpen());
    assertFalse(type.isSequenced());
    assertEquals(0, type.getProperties().size());
  }

  /**
   * <complexType> containing element with nillable="true"
   *
   * @throws Exception
   */
  @Test public void test_cT_46() throws Exception {

    List types = define("/complexType/cT_46.xsd");

    Type type = (Type) types.get(0);
    assertFalse(type.isSequenced());
    assertFalse(type.isOpen());
    assertFalse(type.isDataType());
    assertFalse(type.isAbstract());
    assertEquals("cT_46", type.getName());

    assertPropertyExists(type, "id", "Int", false, false);
    assertPropertyExists(type, "name", "String", false, false);

    assertEquals( false, type.getProperty("id").isNullable() );
    assertEquals( true, type.getProperty("name").isNullable() );
  }

  /**
   * <complexType> containing an anySimpletype element
   *
   * @throws Exception
   */
  @Test public void testTC298ComplexTypeSetAnySimpleTypeWithStringValue() throws Exception {
    List types = define("/complexType/cT_47.xsd");

    DataObject dobj = getScope().getDataFactory().create( "http://www.example.com/xsd/47/", "cT_47" );
    Property p = dobj.getProperty( "type_anySimpleType" );
    assertNotNull( p );

    assertEquals( "commonj.sdo", p.getType().getURI() );
    assertEquals( "Object", p.getType().getName() );

    dobj.set( "type_anySimpleType", "foo" );
    assertEquals( "foo", dobj.get( "type_anySimpleType") );
  }

  @Test public void test_cT_48() throws IOException {
    List types = define("/complexType/cT_48.xsd");
    assertTrue(types.size() >= 4);

    Type t1 = getType(types, "complextype1");
    Property p1 = t1.getProperty("person");
    assertNotNull(p1);

    Type t2 = getType(types, "complextype2");
    Property p2 = t2.getProperty("person");
    assertNotNull(p2);

    // although the 2.1 spec says that the name of the anonymous types should be the same as the name of the
    // enclosing element or attribute, this would result in a name clash so we need to ensure that the type
    // names are not the same
    String typeName1 = p1.getType().getName();
    String typeName2 = p2.getType().getName();
    assertFalse( typeName1.equals(typeName2) );
  }

}