File: SimpleGlobals.java

package info (click to toggle)
libjibx1.2-java 1.2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,260 kB
  • sloc: java: 75,013; xml: 14,068; makefile: 17
file content (118 lines) | stat: -rw-r--r-- 4,714 bytes parent folder | download | duplicates (9)
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

package org.jibx.schema.elements;

import org.jibx.schema.SchemaTestBase;

/**
 * Test handling of simple schemas with only global elements or attributes and
 * no nested structure.
 */
public class SimpleGlobals extends SchemaTestBase
{
    public static final String SIMPLE_ELEMENT_BLANK_SCHEMA =
        "<schema xmlns='http://www.w3.org/2001/XMLSchema'>\n" +
        "  <element name='simple' type='string'/>\n" +
        "</schema>";
        
    public static final String SIMPLE_ATTRIBUTE_BLANK_SCHEMA =
        "<schema xmlns='http://www.w3.org/2001/XMLSchema'>\n" +
        "  <attribute name='simple' type='string'/>\n" +
        "</schema>";
        
    public static final String SIMPLE_ELEMENT_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <element name='simple' type='string'/>\n" +
        "</schema>";
        
    public static final String SIMPLE_ATTRIBUTE_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <attribute name='simple' type='string'/>\n" +
        "</schema>";
    
    public static final String COMPLEX_ELEMENT_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <element name='simple' type='string' substitutionGroup='subs' nillable='true' default='abc' final='#all' block='extension restriction'>\n" +
        "    <annotation>\n" +
        "      <documentation>this should mean something</documentation>\n" +
        "    </annotation>\n" +
        "  </element>\n" +
        "</schema>";
        
    public static final String COMPLEX_ATTRIBUTE_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <attribute name='simple1' type='int'>\n" +
        "    <annotation>\n" +
        "      <documentation>this should mean something</documentation>\n" +
        "    </annotation>\n" +
        "  </attribute>\n" +
        "  <attribute name='simple2' type='int' default='5'/>\n" +
        "</schema>";
    
    public static final String COMPLEX_ELEMENT_ERROR_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <element name='simple' form='unqualified' minOccurs='0' maxOccurs='1' substitutionGroup='subs' nillable='true' default='abc' final='#all' block='extension restriction'/>\n" +
        "</schema>";
    
    public static final String COMPLEX_ATTRIBUTE_ERROR_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <attribute name='simple1' form='qualified' use='optional' type='int'/>\n" +
        "</schema>";
    
    public static final String ELEMENT_TYPE_REFERENCE_ERROR_SCHEMA =
        "<schema targetNamespace='urn:anything'" +
        "    xmlns='http://www.w3.org/2001/XMLSchema'" +
        "    elementFormDefault='qualified'>\n" +
        "  <element name='simple' type='unknown'/>\n" +
        "</schema>";
    
    public void testSimpleElementBlank() throws Exception {
        runNoErrors(SIMPLE_ELEMENT_BLANK_SCHEMA);
    }
    
    public void testSimpleAttributeBlank() throws Exception {
        runNoErrors(SIMPLE_ATTRIBUTE_BLANK_SCHEMA);
    }
    
    public void testSimpleElement() throws Exception {
        runNoErrors(SIMPLE_ELEMENT_SCHEMA);
    }
    
    public void testSimpleAttribute() throws Exception {
        runNoErrors(SIMPLE_ATTRIBUTE_SCHEMA);
    }
    
    public void testComplexElement() throws Exception {
        runNoErrors(COMPLEX_ELEMENT_SCHEMA);
    }
    
    public void testComplexAttribute() throws Exception {
        runNoErrors(COMPLEX_ATTRIBUTE_SCHEMA);
    }
    
    public void testComplexElementError() throws Exception {
        runOneError(COMPLEX_ELEMENT_ERROR_SCHEMA,
            "Invalid attributes on global <element> not reported");
    }
    
    public void testComplexAttributeError() throws Exception {
        runOneError(COMPLEX_ATTRIBUTE_ERROR_SCHEMA,
            "Invalid attributes on global <attribute> not reported");
    }
    
    public void testElementTypeReferenceError() throws Exception {
        runOneError(ELEMENT_TYPE_REFERENCE_ERROR_SCHEMA,
            "Undefined type reference on <element> not reported");
    }
}