Improve UsesAugmentTest
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / UsesAugmentTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14
15 import java.util.Collection;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.common.QNameModule;
20 import org.opendaylight.yangtools.yang.common.Revision;
21 import org.opendaylight.yangtools.yang.common.XMLNamespace;
22 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
26 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
27 import org.opendaylight.yangtools.yang.model.api.Module;
28 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
29 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
30 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
31 import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
32 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
33 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
34
35 public class UsesAugmentTest {
36     private static final QNameModule UG = QNameModule.create(
37         XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:uses-grouping"), Revision.of("2013-07-30"));
38     private static final QNameModule GD = QNameModule.create(
39         XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:grouping-definitions"), Revision.of("2013-09-04"));
40
41     private static SchemaContext CONTEXT;
42
43     @BeforeClass
44     public static void beforeClass() throws Exception {
45         CONTEXT = TestUtils.loadModules("/grouping-test");
46     }
47
48     /*
49      * Structure of testing model:
50      *
51      * notification pcreq
52      * |-- leaf version (U)
53      * |-- leaf type (U)
54      * |-- list requests
55      * |-- |-- container rp
56      * |-- |-- |-- leaf priority (U)
57      * |-- |-- |-- container box (U)
58      * |-- |-- |-- |-- container order (A)
59      * |-- |-- |-- |-- |-- leaf delete (U)
60      * |-- |-- |-- |-- |-- |-- leaf setup (U)
61      * |-- |-- |-- leaf processing-rule (U)
62      * |-- |-- |-- leaf ignore (U)
63      * |-- |-- path-key-expansion
64      * |-- |-- |-- container path-key
65      * |-- |-- |-- |-- list path-keys (U)
66      * |-- |-- |-- |-- |-- leaf version (U)
67      * |-- |-- |-- |-- |-- leaf type (U)
68      * |-- |-- |-- |-- |-- leaf processing-rule (U)
69      * |-- |-- |-- |-- |-- leaf ignore (U)
70      * |-- |-- container segment-computation
71      * |-- |-- |-- container p2p
72      * |-- |-- |-- |-- container endpoints
73      * |-- |-- |-- |-- |-- leaf processing-rule (U)
74      * |-- |-- |-- |-- |-- leaf ignore (U)
75      * |-- |-- |-- |-- |-- container box (U)
76      * |-- |-- |-- |-- |-- choice address-family (U)
77      * |-- |-- |-- |-- |-- |-- case ipv4
78      * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv4-address
79      * |-- |-- |-- |-- |-- |-- case ipv6
80      * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv6-address
81      * |-- |-- |-- |-- container reported-route
82      * |-- |-- |-- |-- |-- container bandwidth
83      * |-- |-- |-- |-- |-- list subobjects(U)
84      * |-- |-- |-- |-- |-- leaf processing-rule (U)
85      * |-- |-- |-- |-- |-- leaf ignore (U)
86      * |-- |-- |-- |-- container bandwidth (U)
87      * |-- |-- |-- |-- |-- container bandwidth (U)
88      * |-- |-- |-- |-- |-- leaf processing-rule (U)
89      * |-- |-- |-- |-- |-- leaf ignore (U)
90      * |-- list svec
91      * |-- |-- list metric
92      * |-- |-- |-- leaf metric-type (U)
93      * |-- |-- |-- container box (U)
94      * |-- |-- |-- leaf processing-rule (U)
95      * |-- |-- |-- leaf ignore (U)
96      * |-- |-- leaf link-diverse (U)
97      * |-- |-- leaf processing-rule (U)
98      * |-- |-- leaf ignore (U)
99      *
100      * U = added by uses A = added by augment
101      *
102      * @throws Exception if exception occurs
103      */
104     @Test
105     public void testAugmentInUses() throws Exception {
106         final Module testModule = CONTEXT.findModules("uses-grouping").iterator().next();
107
108         // * notification pcreq
109         final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
110         assertEquals(1, notifications.size());
111         final NotificationDefinition pcreq = notifications.iterator().next();
112         assertNotNull(pcreq);
113         assertEquals(QName.create(UG, "pcreq"), pcreq.getQName());
114         Collection<? extends DataSchemaNode> childNodes = pcreq.getChildNodes();
115         assertEquals(4, childNodes.size());
116         // * |-- leaf version
117         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
118                 "version"));
119         assertNotNull(version);
120         assertEquals(QName.create(UG, "version"), version.getQName());
121         assertEquals(QName.create(UG, "version"), version.getType().getQName());
122         assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
123         assertTrue(version.isAddedByUses());
124         // * |-- leaf type
125         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
126                 "type"));
127         assertNotNull(type);
128         assertTrue(type.isAddedByUses());
129         assertEquals(QName.create(UG, "type"), type.getQName());
130         assertEquals(QName.create(GD, "int-ext"), type.getType().getQName());
131         final UnionTypeDefinition union = (UnionTypeDefinition) type.getType().getBaseType();
132         assertEquals(QName.create(GD, "union"), union.getQName());
133         assertEquals(2, union.getTypes().size());
134         // * |-- list requests
135         final ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName(QName.create(
136                 testModule.getQNameModule(), "requests"));
137         assertNotNull(requests);
138         assertEquals(QName.create(UG, "requests"), requests.getQName());
139         assertFalse(requests.isAddedByUses());
140         childNodes = requests.getChildNodes();
141         assertEquals(3, childNodes.size());
142         // * |-- |-- container rp
143         final ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
144                 testModule.getQNameModule(), "rp"));
145         assertNotNull(rp);
146         assertEquals(QName.create(UG, "rp"), rp.getQName());
147         assertFalse(rp.isAddedByUses());
148         childNodes = rp.getChildNodes();
149         assertEquals(4, childNodes.size());
150         // * |-- |-- |-- leaf processing-rule
151         LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName(QName.create(
152                 testModule.getQNameModule(), "processing-rule"));
153         assertNotNull(processingRule);
154         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
155         assertEquals(BaseTypes.booleanType(), processingRule.getType());
156         assertTrue(processingRule.isAddedByUses());
157         // * |-- |-- |-- leaf ignore
158         LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
159                 "ignore"));
160         assertNotNull(ignore);
161         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
162         assertEquals(BaseTypes.booleanType(), ignore.getType());
163         assertTrue(ignore.isAddedByUses());
164         // * |-- |-- |-- leaf priority
165         final LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName(QName.create(
166                 testModule.getQNameModule(), "priority"));
167         assertNotNull(priority);
168         assertEquals(QName.create(UG, "priority"), priority.getQName());
169         // TODO
170         // assertEquals(QName.create(UG, "uint8"), priority.getType().getQName());
171         assertEquals(BaseTypes.uint8Type(), priority.getType().getBaseType());
172         assertTrue(priority.isAddedByUses());
173         // * |-- |-- |-- container box
174         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
175                 "box"));
176         assertNotNull(box);
177         assertEquals(QName.create(UG, "box"), box.getQName());
178         assertTrue(box.isAddedByUses());
179         // * |-- |-- |-- |-- container order
180         final ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName(QName.create(
181                 testModule.getQNameModule(), "order"));
182         assertNotNull(order);
183         assertEquals(QName.create(UG, "order"), order.getQName());
184         assertTrue(order.isAddedByUses());
185         assertTrue(order.isAugmenting());
186         assertEquals(2, order.getChildNodes().size());
187         // * |-- |-- |-- |-- |-- leaf delete
188         final LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName(QName.create(
189                 testModule.getQNameModule(), "delete"));
190         assertNotNull(delete);
191         assertEquals(QName.create(UG, "delete"), delete.getQName());
192         assertEquals(BaseTypes.uint32Type(), delete.getType());
193         assertTrue(delete.isAddedByUses());
194         // * |-- |-- |-- |-- |-- leaf setup
195         final LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName(QName.create(
196                 testModule.getQNameModule(), "setup"));
197         assertNotNull(setup);
198         assertEquals(QName.create(UG, "setup"), setup.getQName());
199         assertEquals(BaseTypes.uint32Type(), setup.getType());
200         assertTrue(setup.isAddedByUses());
201         // * |-- |-- path-key-expansion
202         final ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
203                 testModule.getQNameModule(), "path-key-expansion"));
204         assertNotNull(pke);
205         assertEquals(QName.create(UG, "path-key-expansion"), pke.getQName());
206         assertFalse(pke.isAddedByUses());
207         // * |-- |-- |-- path-key
208         final ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName(QName.create(
209                 testModule.getQNameModule(), "path-key"));
210         assertNotNull(pathKey);
211         assertEquals(QName.create(UG, "path-key"), pathKey.getQName());
212         assertFalse(pathKey.isAddedByUses());
213         assertEquals(3, pathKey.getChildNodes().size());
214         // * |-- |-- |-- |-- leaf processing-rule
215         processingRule = (LeafSchemaNode) pathKey.getDataChildByName(QName.create(testModule.getQNameModule(),
216                 "processing-rule"));
217         assertNotNull(processingRule);
218         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
219         assertEquals(BaseTypes.booleanType(), processingRule.getType());
220         assertTrue(processingRule.isAddedByUses());
221         // * |-- |-- |-- |-- leaf ignore
222         ignore = (LeafSchemaNode) pathKey.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
223         assertNotNull(ignore);
224         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
225         assertEquals(BaseTypes.booleanType(), ignore.getType());
226         assertTrue(ignore.isAddedByUses());
227         // * |-- |-- |-- |-- list path-keys
228         final ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName(QName.create(
229                 testModule.getQNameModule(), "path-keys"));
230         assertNotNull(pathKeys);
231         assertEquals(QName.create(UG, "path-keys"), pathKeys.getQName());
232         assertTrue(pathKeys.isAddedByUses());
233         childNodes = pathKeys.getChildNodes();
234         assertEquals(2, childNodes.size());
235         // * |-- |-- |-- |-- |-- leaf version
236         version = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "version"));
237         assertNotNull(version);
238         assertEquals(QName.create(UG, "version"), version.getQName());
239         assertTrue(version.getType() instanceof Uint8TypeDefinition);
240         assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
241         assertTrue(version.isAddedByUses());
242         assertTrue(version.isAugmenting());
243         // * |-- |-- |-- |-- |-- leaf type
244         type = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "type"));
245         assertNotNull(type);
246         assertEquals(QName.create(UG, "type"), type.getQName());
247         assertTrue(type.getType() instanceof UnionTypeDefinition);
248         assertTrue(type.isAddedByUses());
249         assertTrue(type.isAugmenting());
250         // * |-- |-- container segment-computation
251         final ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
252                 testModule.getQNameModule(), "segment-computation"));
253         assertNotNull(sc);
254         assertEquals(QName.create(UG, "segment-computation"), sc.getQName());
255         assertFalse(sc.isAddedByUses());
256         // * |-- |-- |-- container p2p
257         final ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName(QName.create(
258                 testModule.getQNameModule(), "p2p"));
259         assertNotNull(p2p);
260         assertEquals(QName.create(UG, "p2p"), p2p.getQName());
261         assertFalse(p2p.isAddedByUses());
262         // * |-- |-- |-- |-- container endpoints
263         final ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
264                 testModule.getQNameModule(), "endpoints"));
265         assertNotNull(endpoints);
266         assertEquals(QName.create(UG, "endpoints"), endpoints.getQName());
267         assertFalse(endpoints.isAddedByUses());
268         // * |-- |-- |-- |-- |-- leaf processing-rule
269         processingRule = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(),
270                 "processing-rule"));
271         assertNotNull(processingRule);
272         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
273         assertEquals(BaseTypes.booleanType(), processingRule.getType());
274         assertTrue(processingRule.isAddedByUses());
275         // * |-- |-- |-- |-- |-- leaf ignore
276         ignore = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
277         assertNotNull(ignore);
278         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
279         assertEquals(BaseTypes.booleanType(), ignore.getType());
280         assertTrue(ignore.isAddedByUses());
281         // * |-- |-- |-- |-- |-- container box
282         box = (ContainerSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(), "box"));
283         assertNotNull(box);
284         assertEquals(QName.create(UG, "box"), box.getQName());
285         assertTrue(box.isAddedByUses());
286         // * |-- |-- |-- |-- |-- choice address-family
287         final ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName(QName.create(
288                 testModule.getQNameModule(), "address-family"));
289         assertNotNull(af);
290         assertEquals(QName.create(UG, "address-family"), af.getQName());
291         assertTrue(af.isAddedByUses());
292         // * |-- |-- |-- |-- container reported-route
293         final ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
294                 testModule.getQNameModule(), "reported-route"));
295         assertNotNull(reportedRoute);
296         assertEquals(QName.create(UG, "reported-route"), reportedRoute.getQName());
297         assertFalse(reportedRoute.isAddedByUses());
298         // * |-- |-- |-- |-- |-- leaf processing-rule
299         processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(),
300                 "processing-rule"));
301         assertNotNull(processingRule);
302         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
303         assertEquals(BaseTypes.booleanType(), processingRule.getType());
304         assertTrue(processingRule.isAddedByUses());
305         // * |-- |-- |-- |-- |-- leaf ignore
306         ignore = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
307         assertNotNull(ignore);
308         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
309         assertEquals(BaseTypes.booleanType(), ignore.getType());
310         assertTrue(ignore.isAddedByUses());
311         // * |-- |-- |-- |-- |-- list subobjects
312         final ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName(QName.create(
313                 testModule.getQNameModule(), "subobjects"));
314         assertNotNull(subobjects);
315         assertEquals(QName.create(UG, "subobjects"), subobjects.getQName());
316         assertTrue(subobjects.isAddedByUses());
317         // * |-- |-- |-- |-- |-- container bandwidth
318         ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName(QName.create(
319                 testModule.getQNameModule(), "bandwidth"));
320         assertNotNull(bandwidth);
321         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
322         assertFalse(bandwidth.isAddedByUses());
323         // * |-- |-- |-- |-- container bandwidth
324         bandwidth = (ContainerSchemaNode) p2p
325                 .getDataChildByName(QName.create(testModule.getQNameModule(), "bandwidth"));
326         assertNotNull(bandwidth);
327         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
328         assertTrue(bandwidth.isAddedByUses());
329         // * |-- |-- |-- |-- |-- leaf processing-rule
330         processingRule = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(),
331                 "processing-rule"));
332         assertNotNull(processingRule);
333         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
334         assertEquals(BaseTypes.booleanType(), processingRule.getType());
335         assertTrue(processingRule.isAddedByUses());
336         // * |-- |-- |-- |-- |-- leaf ignore
337         ignore = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
338         assertNotNull(ignore);
339         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
340         assertEquals(BaseTypes.booleanType(), ignore.getType());
341         assertTrue(ignore.isAddedByUses());
342         // * |-- |-- |-- |-- |-- container bandwidth
343         final ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName(QName.create(
344                 testModule.getQNameModule(), "bandwidth"));
345         assertNotNull(bandwidthInner);
346         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
347         assertTrue(bandwidthInner.isAddedByUses());
348         // * |-- list svec
349         final ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
350                 "svec"));
351         assertNotNull(svec);
352         assertEquals(QName.create(UG, "svec"), svec.getQName());
353         assertFalse(svec.isAddedByUses());
354         // * |-- |-- leaf link-diverse
355         final LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName(QName.create(
356                 testModule.getQNameModule(), "link-diverse"));
357         assertNotNull(linkDiverse);
358         assertEquals(QName.create(UG, "link-diverse"), linkDiverse.getQName());
359         assertEquals(BaseTypes.booleanType(), linkDiverse.getType().getBaseType());
360         assertTrue(linkDiverse.isAddedByUses());
361         // * |-- |-- leaf processing-rule
362         processingRule = (LeafSchemaNode) svec.getDataChildByName(QName.create(testModule.getQNameModule(),
363                 "processing-rule"));
364         assertNotNull(processingRule);
365         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
366         assertEquals(BaseTypes.booleanType(), processingRule.getType());
367         assertTrue(processingRule.isAddedByUses());
368         // * |-- |-- leaf ignore
369         ignore = (LeafSchemaNode) svec.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
370         assertNotNull(ignore);
371         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
372         assertEquals(BaseTypes.booleanType(), ignore.getType());
373         assertTrue(ignore.isAddedByUses());
374         // * |-- |-- list metric
375         final ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName(QName.create(
376                 testModule.getQNameModule(), "metric"));
377         assertNotNull(metric);
378         assertEquals(QName.create(UG, "metric"), metric.getQName());
379         assertFalse(metric.isAddedByUses());
380         // * |-- |-- |-- leaf metric-type
381         final LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName(QName.create(
382                 testModule.getQNameModule(), "metric-type"));
383         assertNotNull(metricType);
384         assertEquals(QName.create(UG, "metric-type"), metricType.getQName());
385         assertEquals(BaseTypes.uint8Type(), metricType.getType());
386         assertTrue(metricType.isAddedByUses());
387         // * |-- |-- |-- box
388         box = (ContainerSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(), "box"));
389         assertNotNull(box);
390         assertEquals(QName.create(UG, "box"), box.getQName());
391         assertTrue(box.isAddedByUses());
392         // * |-- |-- |-- leaf processing-rule
393         processingRule = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(),
394                 "processing-rule"));
395         assertNotNull(processingRule);
396         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
397         assertEquals(BaseTypes.booleanType(), processingRule.getType());
398         assertTrue(processingRule.isAddedByUses());
399         // * |-- |-- |-- leaf ignore
400         ignore = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
401         assertNotNull(ignore);
402         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
403         assertEquals(BaseTypes.booleanType(), ignore.getType());
404         assertTrue(ignore.isAddedByUses());
405     }
406
407     @Test
408     public void testTypedefs() throws Exception {
409         final Module testModule = CONTEXT.findModules("grouping-definitions").iterator().next();
410         final Collection<? extends TypeDefinition<?>> types = testModule.getTypeDefinitions();
411
412         TypeDefinition<?> intExt = null;
413         for (final TypeDefinition<?> td : types) {
414             if ("int-ext".equals(td.getQName().getLocalName())) {
415                 intExt = td;
416             }
417         }
418         assertNotNull(intExt);
419
420         assertEquals(QName.create(GD, "int-ext"), intExt.getQName());
421
422         final UnionTypeDefinition union = (UnionTypeDefinition) intExt.getBaseType();
423
424         TypeDefinition<?> uint8 = null;
425         TypeDefinition<?> pv = null;
426         for (final TypeDefinition<?> td : union.getTypes()) {
427             if ("uint8".equals(td.getQName().getLocalName())) {
428                 uint8 = td;
429             } else if ("protocol-version".equals(td.getQName().getLocalName())) {
430                 pv = td;
431             }
432         }
433         assertNotNull(uint8);
434         assertNotNull(pv);
435         assertEquals(QName.create(GD, "union"), union.getQName());
436     }
437 }