Modified: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java 
(original)
+++ 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java 
Tue Feb 21 22:06:48 2006
@@ -1,322 +1,324 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * 
- * Licensed 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 schema.annotations;
-
-import org.apache.xerces.xs.XSAnnotation;
-import org.apache.xerces.xs.XSAttributeUse;
-import org.apache.xerces.xs.XSComplexTypeDefinition;
-import org.apache.xerces.xs.XSImplementation;
-import org.apache.xerces.xs.XSLoader;
-import org.apache.xerces.xs.XSModel;
-import org.apache.xerces.xs.XSObjectList;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-
-/**
- * Tests methods getAnnotations on XSAttributeUse XSModel components.
- * 
- * @version $Id: $
- */
-public class XSAttributeUseAnnotationsTest extends TestCase {
-
-    /**
-     * Members that are initialized by setUp() and cleaned up by tearDown().
-     * <p>
-     * 
-     * Note that setUp() and tearDown() are called for <em>each</em> test.
-     * Different tests do <em>not</em> share the same instance member.
-     */
-    private XSLoader fSchemaLoader;
-
-    private DOMConfiguration fConfig;
-
-    /**
-     * This method is called before every test case method, to set up the test
-     * fixture.
-     */
-    protected void setUp() {
-        try {
-            // get DOM Implementation using DOM Registry
-            System.setProperty(DOMImplementationRegistry.PROPERTY,
-                    "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
-            DOMImplementationRegistry registry = DOMImplementationRegistry
-                    .newInstance();
-
-            XSImplementation impl = (XSImplementation) registry
-                    .getDOMImplementation("XS-Loader");
-
-            fSchemaLoader = impl.createXSLoader(null);
-
-            fConfig = fSchemaLoader.getConfig();
-
-            // set validation feature
-            fConfig.setParameter("validate", Boolean.TRUE);
-
-        } catch (Exception e) {
-            fail("Expecting a NullPointerException");
-            System.err.println("SETUP FAILED: XSAttributeUseAnnotationsTest");
-        }
-    }
-
-    /**
-     * This method is called before every test case method, to tears down the
-     * test fixture.
-     */
-    protected void tearDown() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-    }
-
-    /**
-     * Test #1.
-     */
-    public void testAttrUseNoAnnotations() {
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 0, annotations.getLength());
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 0, annotations.getLength());
-
-        // attr grp ref
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 0, annotations.getLength());
-    }
-
-    /**
-     * Test #2.
-     */
-    public void testAttrUseNoSynthAnnotations() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 0, annotations.getLength());
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 0, annotations.getLength());
-
-        // attr grp ref
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 0, annotations.getLength());
-    }
-
-    /**
-     * Test #3
-     */
-    public void testAttrUseSynthAnnotations() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 1, annotations.getLength());
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 1, annotations.getLength());
-
-        // attr grp ref
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 0, annotations.getLength());
-
-    }
-
-    /**
-     * Test #4.
-     */
-    public void testAttrUseAnnotations() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest02.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 1, annotations.getLength());
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 1, annotations.getLength());
-
-        // attr grp ref
-        // The attribute in the group has an annotation element
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 1, annotations.getLength());
-    }
-
-    /**
-     * Test #5.
-     */
-    public void testAttrUseAnnotationsSynthetic() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest02.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 1, annotations.getLength());
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 1, annotations.getLength());
-
-        // attr grp ref
-        // The attribute in the group has an annotation element
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 1, annotations.getLength());
-    }
-
-    /**
-     * Test #6.
-     */
-    public void testWildAttrUseAnnotationsSynthetic() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest03.xsd"));
-
-        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
-                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
-
-        XSObjectList attrUses = ct.getAttributeUses();
-
-        // Attr ref
-        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
-        XSObjectList annotations = attr.getAnnotations();
-        assertEquals("REF", 1, annotations.getLength());
-
-        XSAnnotation annotation = attr.getAttrDeclaration().getAnnotation();
-        String expected = "<annotation sn:att=\"ATT1\"  id=\"ANNOT1\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
-                + "<appinfo>APPINFO1</appinfo>" + "</annotation>";
-        assertEquals("REF_STRING", trim(expected), trim(annotation
-                .getAnnotationString()));
-
-        annotations = attr.getAttrDeclaration().getAnnotations();
-        assertEquals(
-                "REF_STRING_ANNOTATIONS",
-                trim(expected),
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-
-        // local attr
-        attr = (XSAttributeUse) attrUses.item(1);
-        annotations = attr.getAnnotations();
-        assertEquals("LOCAL", 1, annotations.getLength());
-
-        annotation = attr.getAttrDeclaration().getAnnotation();
-        expected = "<annotation sn:att=\"ATT11\"  id=\"ANNOT6\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
-                + "<appinfo>APPINFO6</appinfo>" + "</annotation>";
-        assertEquals("LOCAL_STRING", trim(expected), trim(annotation
-                .getAnnotationString()));
-
-        annotations = attr.getAttrDeclaration().getAnnotations();
-        assertEquals(
-                "LOCAL_STRING_ANNOTATIONS",
-                trim(expected),
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-
-        // attr grp ref
-        // The attribute in the group has an annotation element
-        attr = (XSAttributeUse) attrUses.item(2);
-        annotations = attr.getAnnotations();
-        assertEquals("GROUP", 1, annotations.getLength());
-
-        annotation = attr.getAttrDeclaration().getAnnotation();
-        expected = "<annotation id=\"ANNOT3\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
-                + "<appinfo>APPINFO3</appinfo>" + "</annotation>";
-        assertEquals("GROUP_STRING", trim(expected), trim(annotation
-                .getAnnotationString()));
-
-        annotations = attr.getAttrDeclaration().getAnnotations();
-        assertEquals(
-                "GROUP_STRING_ANNOTATIONS",
-                trim(expected),
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-
-    }
-
-    public static void main(String args[]) {
-        junit.textui.TestRunner.run(XSAttributeUseAnnotationsTest.class);
-    }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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 schema.annotations;
+
+import org.apache.xerces.xs.XSAnnotation;
+import org.apache.xerces.xs.XSAttributeUse;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSImplementation;
+import org.apache.xerces.xs.XSLoader;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSObjectList;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+/**
+ * Tests methods getAnnotations on XSAttributeUse XSModel components.
+ * 
+ * @author Neil Delima, IBM
+ * @version $Id$
+ */
+public class XSAttributeUseAnnotationsTest extends TestCase {
+
+    /**
+     * Members that are initialized by setUp() and cleaned up by tearDown().
+     * <p>
+     * 
+     * Note that setUp() and tearDown() are called for <em>each</em> test.
+     * Different tests do <em>not</em> share the same instance member.
+     */
+    private XSLoader fSchemaLoader;
+
+    private DOMConfiguration fConfig;
+
+    /**
+     * This method is called before every test case method, to set up the test
+     * fixture.
+     */
+    protected void setUp() {
+        try {
+            // get DOM Implementation using DOM Registry
+            System.setProperty(DOMImplementationRegistry.PROPERTY,
+                    "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
+            DOMImplementationRegistry registry = DOMImplementationRegistry
+                    .newInstance();
+
+            XSImplementation impl = (XSImplementation) registry
+                    .getDOMImplementation("XS-Loader");
+
+            fSchemaLoader = impl.createXSLoader(null);
+
+            fConfig = fSchemaLoader.getConfig();
+
+            // set validation feature
+            fConfig.setParameter("validate", Boolean.TRUE);
+
+        } catch (Exception e) {
+            fail("Expecting a NullPointerException");
+            System.err.println("SETUP FAILED: XSAttributeUseAnnotationsTest");
+        }
+    }
+
+    /**
+     * This method is called before every test case method, to tears down the
+     * test fixture.
+     */
+    protected void tearDown() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+    }
+
+    /**
+     * Test #1.
+     */
+    public void testAttrUseNoAnnotations() {
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 0, annotations.getLength());
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 0, annotations.getLength());
+
+        // attr grp ref
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 0, annotations.getLength());
+    }
+
+    /**
+     * Test #2.
+     */
+    public void testAttrUseNoSynthAnnotations() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 0, annotations.getLength());
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 0, annotations.getLength());
+
+        // attr grp ref
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 0, annotations.getLength());
+    }
+
+    /**
+     * Test #3
+     */
+    public void testAttrUseSynthAnnotations() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest01.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 1, annotations.getLength());
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 1, annotations.getLength());
+
+        // attr grp ref
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 0, annotations.getLength());
+
+    }
+
+    /**
+     * Test #4.
+     */
+    public void testAttrUseAnnotations() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest02.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 1, annotations.getLength());
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 1, annotations.getLength());
+
+        // attr grp ref
+        // The attribute in the group has an annotation element
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 1, annotations.getLength());
+    }
+
+    /**
+     * Test #5.
+     */
+    public void testAttrUseAnnotationsSynthetic() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest02.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 1, annotations.getLength());
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 1, annotations.getLength());
+
+        // attr grp ref
+        // The attribute in the group has an annotation element
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 1, annotations.getLength());
+    }
+
+    /**
+     * Test #6.
+     */
+    public void testWildAttrUseAnnotationsSynthetic() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                
.loadURI(getResourceURL("XSAttributeUseAnnotationsTest03.xsd"));
+
+        XSComplexTypeDefinition ct = (XSComplexTypeDefinition) model
+                .getTypeDefinition("CT", "XSAttributeUseAnnotationsTest");
+
+        XSObjectList attrUses = ct.getAttributeUses();
+
+        // Attr ref
+        XSAttributeUse attr = (XSAttributeUse) attrUses.item(0);
+        XSObjectList annotations = attr.getAnnotations();
+        assertEquals("REF", 1, annotations.getLength());
+
+        XSAnnotation annotation = attr.getAttrDeclaration().getAnnotation();
+        String expected = "<annotation sn:att=\"ATT1\"  id=\"ANNOT1\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
+                + "<appinfo>APPINFO1</appinfo>" + "</annotation>";
+        assertEquals("REF_STRING", trim(expected), trim(annotation
+                .getAnnotationString()));
+
+        annotations = attr.getAttrDeclaration().getAnnotations();
+        assertEquals(
+                "REF_STRING_ANNOTATIONS",
+                trim(expected),
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+
+        // local attr
+        attr = (XSAttributeUse) attrUses.item(1);
+        annotations = attr.getAnnotations();
+        assertEquals("LOCAL", 1, annotations.getLength());
+
+        annotation = attr.getAttrDeclaration().getAnnotation();
+        expected = "<annotation sn:att=\"ATT11\"  id=\"ANNOT6\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
+                + "<appinfo>APPINFO6</appinfo>" + "</annotation>";
+        assertEquals("LOCAL_STRING", trim(expected), trim(annotation
+                .getAnnotationString()));
+
+        annotations = attr.getAttrDeclaration().getAnnotations();
+        assertEquals(
+                "LOCAL_STRING_ANNOTATIONS",
+                trim(expected),
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+
+        // attr grp ref
+        // The attribute in the group has an annotation element
+        attr = (XSAttributeUse) attrUses.item(2);
+        annotations = attr.getAnnotations();
+        assertEquals("GROUP", 1, annotations.getLength());
+
+        annotation = attr.getAttrDeclaration().getAnnotation();
+        expected = "<annotation id=\"ANNOT3\" 
xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSAttributeUseAnnotationsTest\" xmlns:sn=\"SyntheticAnnotationNS\" > 
"
+                + "<appinfo>APPINFO3</appinfo>" + "</annotation>";
+        assertEquals("GROUP_STRING", trim(expected), trim(annotation
+                .getAnnotationString()));
+
+        annotations = attr.getAttrDeclaration().getAnnotations();
+        assertEquals(
+                "GROUP_STRING_ANNOTATIONS",
+                trim(expected),
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+
+    }
+
+    public static void main(String args[]) {
+        junit.textui.TestRunner.run(XSAttributeUseAnnotationsTest.class);
+    }
+}

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd 
(original)
+++ 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd 
Tue Feb 21 22:06:48 2006
@@ -1,23 +1,23 @@
-<?xml version="1.0"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema";
-    targetNamespace="XSAttributeUseAnnotationsTest"
-    xmlns:sv="XSAttributeUseAnnotationsTest"
-    xmlns:sn="SyntheticAnnotationNS">
-
-    <attribute name="attr1" type="string" sn:att="ATT1"></attribute>
-    <attributeGroup name="AG" sn:att="AG1">
-        <attribute name="attr3" type="string"></attribute>
-    </attributeGroup>
-
-    <complexType name="CT">
-        <sequence>
-            <element name="elString" type="string" />
-        </sequence>
-        <attribute ref="sv:attr1" sn:att="ATT2"/>
-        <attribute name="attr2" sn:att="ATT3"/>
-        <attributeGroup ref="sv:AG" sn:att="AG2"/>
-    </complexType>
-
-    <element name="root" type="sv:CT" />
-
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema";
+    targetNamespace="XSAttributeUseAnnotationsTest"
+    xmlns:sv="XSAttributeUseAnnotationsTest"
+    xmlns:sn="SyntheticAnnotationNS">
+
+    <attribute name="attr1" type="string" sn:att="ATT1"></attribute>
+    <attributeGroup name="AG" sn:att="AG1">
+        <attribute name="attr3" type="string"></attribute>
+    </attributeGroup>
+
+    <complexType name="CT">
+        <sequence>
+            <element name="elString" type="string" />
+        </sequence>
+        <attribute ref="sv:attr1" sn:att="ATT2"/>
+        <attribute name="attr2" sn:att="ATT3"/>
+        <attributeGroup ref="sv:AG" sn:att="AG2"/>
+    </complexType>
+
+    <element name="root" type="sv:CT" />
+
 </schema>

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest01.xsd
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd 
(original)
+++ 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd 
Tue Feb 21 22:06:48 2006
@@ -1,50 +1,50 @@
-<?xml version="1.0"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema";
-    targetNamespace="XSAttributeUseAnnotationsTest"
-    xmlns:sv="XSAttributeUseAnnotationsTest"
-    xmlns:sn="SyntheticAnnotationNS">
-
-    <attribute name="attr1" type="string" sn:att="ATT1">
-        <annotation id="ANNOT1">
-            <appinfo>APPINFOA</appinfo>
-        </annotation>
-    </attribute>
-
-    <attributeGroup name="AG" sn:att="AG1">
-        <annotation id="ANNOT2">
-            <appinfo>APPINFOA</appinfo>
-        </annotation>
-        <attribute name="attr3" type="string">
-            <annotation id="ANNOT3">
-                <appinfo>APPINFOA</appinfo>
-            </annotation>
-        </attribute>
-    </attributeGroup>
-
-    <complexType name="CT">
-        <annotation id="ANNOT4">
-            <appinfo>APPINFOA</appinfo>
-        </annotation>
-        <sequence>
-            <element name="elString" type="string" />
-        </sequence>
-        <attribute ref="sv:attr1" sn:att="ATT2">
-            <annotation id="ANNOT5">
-                <appinfo>APPINFOA</appinfo>
-            </annotation>
-        </attribute>
-        <attribute name="attr2" sn:att="ATT11">
-            <annotation id="ANNOT6">
-                <appinfo>APPINFOA</appinfo>
-            </annotation>
-        </attribute>
-        <attributeGroup ref="sv:AG" sn:att="AG2">
-                   <annotation id="ANNOT7">
-                <appinfo>APPINFOA</appinfo>
-            </annotation>
-        </attributeGroup>
-    </complexType>
-
-    <element name="root" type="sv:CT" />
-
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema";
+    targetNamespace="XSAttributeUseAnnotationsTest"
+    xmlns:sv="XSAttributeUseAnnotationsTest"
+    xmlns:sn="SyntheticAnnotationNS">
+
+    <attribute name="attr1" type="string" sn:att="ATT1">
+        <annotation id="ANNOT1">
+            <appinfo>APPINFOA</appinfo>
+        </annotation>
+    </attribute>
+
+    <attributeGroup name="AG" sn:att="AG1">
+        <annotation id="ANNOT2">
+            <appinfo>APPINFOA</appinfo>
+        </annotation>
+        <attribute name="attr3" type="string">
+            <annotation id="ANNOT3">
+                <appinfo>APPINFOA</appinfo>
+            </annotation>
+        </attribute>
+    </attributeGroup>
+
+    <complexType name="CT">
+        <annotation id="ANNOT4">
+            <appinfo>APPINFOA</appinfo>
+        </annotation>
+        <sequence>
+            <element name="elString" type="string" />
+        </sequence>
+        <attribute ref="sv:attr1" sn:att="ATT2">
+            <annotation id="ANNOT5">
+                <appinfo>APPINFOA</appinfo>
+            </annotation>
+        </attribute>
+        <attribute name="attr2" sn:att="ATT11">
+            <annotation id="ANNOT6">
+                <appinfo>APPINFOA</appinfo>
+            </annotation>
+        </attribute>
+        <attributeGroup ref="sv:AG" sn:att="AG2">
+                   <annotation id="ANNOT7">
+                <appinfo>APPINFOA</appinfo>
+            </annotation>
+        </attributeGroup>
+    </complexType>
+
+    <element name="root" type="sv:CT" />
+
 </schema>

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest02.xsd
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd 
(original)
+++ 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd 
Tue Feb 21 22:06:48 2006
@@ -1,51 +1,51 @@
-<?xml version="1.0"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema";
-    targetNamespace="XSAttributeUseAnnotationsTest"
-    xmlns:sv="XSAttributeUseAnnotationsTest"
-    xmlns:sn="SyntheticAnnotationNS">
-
-    <attribute name="attr1" type="string" sn:att="ATT1">
-        <annotation id="ANNOT1">
-            <appinfo>APPINFO1</appinfo>
-        </annotation>
-    </attribute>
-
-    <attributeGroup name="AG" sn:att="AG1">
-        <annotation id="ANNOT2">
-            <appinfo>APPINFO2</appinfo>
-        </annotation>
-        <attribute name="attr3" type="string">
-            <annotation id="ANNOT3">
-                <appinfo>APPINFO3</appinfo>
-            </annotation>
-        </attribute>
-    </attributeGroup>
-
-    <complexType name="CT">
-        <annotation id="ANNOT4">
-            <appinfo>APPINFO4</appinfo>
-        </annotation>
-        <sequence>
-            <element name="elString" type="string" />
-        </sequence>
-        <attribute ref="sv:attr1" sn:att="ATT2">
-            <annotation id="ANNOT5">
-                <appinfo>APPINFO5</appinfo>
-            </annotation>
-        </attribute>
-        <attribute name="attr2" sn:att="ATT11">
-            <annotation id="ANNOT6">
-                <appinfo>APPINFO6</appinfo>
-            </annotation>
-        </attribute>
-        <attributeGroup ref="sv:AG" sn:att="AG2">
-            <annotation id="ANNOT7">
-                <appinfo>APPINFO7</appinfo>
-            </annotation>
-        </attributeGroup>
-        
-    </complexType>
-
-    <element name="root" type="sv:CT" />
-
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema";
+    targetNamespace="XSAttributeUseAnnotationsTest"
+    xmlns:sv="XSAttributeUseAnnotationsTest"
+    xmlns:sn="SyntheticAnnotationNS">
+
+    <attribute name="attr1" type="string" sn:att="ATT1">
+        <annotation id="ANNOT1">
+            <appinfo>APPINFO1</appinfo>
+        </annotation>
+    </attribute>
+
+    <attributeGroup name="AG" sn:att="AG1">
+        <annotation id="ANNOT2">
+            <appinfo>APPINFO2</appinfo>
+        </annotation>
+        <attribute name="attr3" type="string">
+            <annotation id="ANNOT3">
+                <appinfo>APPINFO3</appinfo>
+            </annotation>
+        </attribute>
+    </attributeGroup>
+
+    <complexType name="CT">
+        <annotation id="ANNOT4">
+            <appinfo>APPINFO4</appinfo>
+        </annotation>
+        <sequence>
+            <element name="elString" type="string" />
+        </sequence>
+        <attribute ref="sv:attr1" sn:att="ATT2">
+            <annotation id="ANNOT5">
+                <appinfo>APPINFO5</appinfo>
+            </annotation>
+        </attribute>
+        <attribute name="attr2" sn:att="ATT11">
+            <annotation id="ANNOT6">
+                <appinfo>APPINFO6</appinfo>
+            </annotation>
+        </attribute>
+        <attributeGroup ref="sv:AG" sn:att="AG2">
+            <annotation id="ANNOT7">
+                <appinfo>APPINFO7</appinfo>
+            </annotation>
+        </attributeGroup>
+        
+    </complexType>
+
+    <element name="root" type="sv:CT" />
+
 </schema>

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSAttributeUseAnnotationsTest03.xsd
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java 
(original)
+++ xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java 
Tue Feb 21 22:06:48 2006
@@ -1,254 +1,256 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * 
- * Licensed 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 schema.annotations;
-
-import org.apache.xerces.xs.XSAnnotation;
-import org.apache.xerces.xs.XSElementDeclaration;
-import org.apache.xerces.xs.XSImplementation;
-import org.apache.xerces.xs.XSLoader;
-import org.apache.xerces.xs.XSModel;
-import org.apache.xerces.xs.XSObjectList;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-
-/**
- * Tests methods getAnnotation and getAnnotations on XSElementDeclaration
- * XSModel components.
- * 
- * @version $Id: $
- */
-public class XSElementAnnotationsTest extends TestCase {
-
-    /**
-     * Members that are initialized by setUp() and cleaned up by tearDown().
-     * <p>
-     * 
-     * Note that setUp() and tearDown() are called for <em>each</em> test.
-     * Different tests do <em>not</em> share the same instance member.
-     */
-    private XSLoader fSchemaLoader;
-
-    private DOMConfiguration fConfig;
-
-    /**
-     * This method is called before every test case method, to set up the test
-     * fixture.
-     */
-    protected void setUp() {
-        try {
-            // get DOM Implementation using DOM Registry
-            System.setProperty(DOMImplementationRegistry.PROPERTY,
-                    "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
-            DOMImplementationRegistry registry = DOMImplementationRegistry
-                    .newInstance();
-
-            XSImplementation impl = (XSImplementation) registry
-                    .getDOMImplementation("XS-Loader");
-
-            fSchemaLoader = impl.createXSLoader(null);
-
-            fConfig = fSchemaLoader.getConfig();
-
-            // set validation feature
-            fConfig.setParameter("validate", Boolean.TRUE);
-
-        } catch (Exception e) {
-            fail("Expecting a NullPointerException");
-            System.err.println("SETUP FAILED: XSElementTest");
-        }
-    }
-
-    /**
-     * This method is called before every test case method, to tears down the
-     * test fixture.
-     */
-    protected void tearDown() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-    }
-
-    /**
-     * Test #1.
-     */
-    public void testElem1Annotation() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem1",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertNull("TEST1_NO_ANNOTATION", annotation);
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals("TEST1_NO_ANNOTATIONS", 0, annotations.getLength());
-    }
-
-    /**
-     * Test #2.
-     */
-    public void testElem2Annotation() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem2",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertNull("TEST2_NO_ANNOTATION", annotation);
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals("TEST2_NO_ANNOTATIONS", 0, annotations.getLength());
-    }
-
-    /**
-     * Test #3.
-     */
-    public void testElem2SynthAnnotation() {
-        String expected = trim("<annotation sn:att=\"SYNTH\" "
-                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; "
-                + "xmlns:sv=\"XSElement\" xmlns:sn=\"SyntheticAnnotation\" >"
-                + "<documentation>SYNTHETIC_ANNOTATION</documentation>"
-                + "</annotation>");
-
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem2",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertEquals("TEST3_ANNOTATION", expected, trim(annotation
-                .getAnnotationString()));
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals(
-                "TEST3_ANNOTATIONS",
-                expected,
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-    }
-
-    /**
-     * Test #4.
-     */
-    public void testElem3Annotation() {
-        String expected = trim("<annotation id=\"ANNOT1\" "
-                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSElement\" "
-                + "xmlns:sn=\"SyntheticAnnotation\" >" + "</annotation>");
-
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.FALSE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem3",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertEquals("TEST3_ANNOTATION", expected, trim(annotation
-                .getAnnotationString()));
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals(
-                "TEST3_ANNOTATIONS",
-                expected,
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-    }
-
-    /**
-     * Test #5.
-     */
-    public void testElem4Annotation() {
-        String expected = trim("<annotation sn:att=\"SYNTH\"  id=\"ANNOT2\" "
-                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSElement\" "
-                + "xmlns:sn=\"SyntheticAnnotation\" >" + "</annotation>");
-
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem4",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertEquals("TEST4_NO_SYNTH_ANNOTATION", expected, trim(annotation
-                .getAnnotationString()));
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals(
-                "TEST4_NO_SYNTH_ANNOTATIONS",
-                expected,
-                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
-    }
-
-    /**
-     * Test #6.
-     */
-    public void testElem5Annotation() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem5",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertNull("TEST5_NO_ANNOTATION", annotation);
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals("TEST5_NO_ANNOTATIONS", 0, annotations.getLength());
-    }
-
-    /**
-     * Test #6.
-     */
-    public void testElem6Annotation() {
-        fConfig
-                .setParameter(
-                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
-                        Boolean.TRUE);
-
-        XSModel model = fSchemaLoader
-                .loadURI(getResourceURL("XSElementTest01.xsd"));
-        XSElementDeclaration elem = model.getElementDeclaration("elem6",
-                "XSElement");
-
-        XSAnnotation annotation = elem.getAnnotation();
-        assertNull("TEST5_NO_ANNOTATION", annotation);
-        XSObjectList annotations = elem.getAnnotations();
-        assertEquals("TEST5_NO_ANNOTATIONS", 0, annotations.getLength());
-    }
-
-    public static void main(String args[]) {
-        junit.textui.TestRunner.run(XSElementAnnotationsTest.class);
-    }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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 schema.annotations;
+
+import org.apache.xerces.xs.XSAnnotation;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSImplementation;
+import org.apache.xerces.xs.XSLoader;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSObjectList;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+/**
+ * Tests methods getAnnotation and getAnnotations on XSElementDeclaration
+ * XSModel components.
+ * 
+ * @author Neil Delima, IBM
+ * @version $Id$
+ */
+public class XSElementAnnotationsTest extends TestCase {
+
+    /**
+     * Members that are initialized by setUp() and cleaned up by tearDown().
+     * <p>
+     * 
+     * Note that setUp() and tearDown() are called for <em>each</em> test.
+     * Different tests do <em>not</em> share the same instance member.
+     */
+    private XSLoader fSchemaLoader;
+
+    private DOMConfiguration fConfig;
+
+    /**
+     * This method is called before every test case method, to set up the test
+     * fixture.
+     */
+    protected void setUp() {
+        try {
+            // get DOM Implementation using DOM Registry
+            System.setProperty(DOMImplementationRegistry.PROPERTY,
+                    "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
+            DOMImplementationRegistry registry = DOMImplementationRegistry
+                    .newInstance();
+
+            XSImplementation impl = (XSImplementation) registry
+                    .getDOMImplementation("XS-Loader");
+
+            fSchemaLoader = impl.createXSLoader(null);
+
+            fConfig = fSchemaLoader.getConfig();
+
+            // set validation feature
+            fConfig.setParameter("validate", Boolean.TRUE);
+
+        } catch (Exception e) {
+            fail("Expecting a NullPointerException");
+            System.err.println("SETUP FAILED: XSElementTest");
+        }
+    }
+
+    /**
+     * This method is called before every test case method, to tears down the
+     * test fixture.
+     */
+    protected void tearDown() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+    }
+
+    /**
+     * Test #1.
+     */
+    public void testElem1Annotation() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem1",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertNull("TEST1_NO_ANNOTATION", annotation);
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals("TEST1_NO_ANNOTATIONS", 0, annotations.getLength());
+    }
+
+    /**
+     * Test #2.
+     */
+    public void testElem2Annotation() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem2",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertNull("TEST2_NO_ANNOTATION", annotation);
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals("TEST2_NO_ANNOTATIONS", 0, annotations.getLength());
+    }
+
+    /**
+     * Test #3.
+     */
+    public void testElem2SynthAnnotation() {
+        String expected = trim("<annotation sn:att=\"SYNTH\" "
+                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; "
+                + "xmlns:sv=\"XSElement\" xmlns:sn=\"SyntheticAnnotation\" >"
+                + "<documentation>SYNTHETIC_ANNOTATION</documentation>"
+                + "</annotation>");
+
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem2",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertEquals("TEST3_ANNOTATION", expected, trim(annotation
+                .getAnnotationString()));
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals(
+                "TEST3_ANNOTATIONS",
+                expected,
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+    }
+
+    /**
+     * Test #4.
+     */
+    public void testElem3Annotation() {
+        String expected = trim("<annotation id=\"ANNOT1\" "
+                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSElement\" "
+                + "xmlns:sn=\"SyntheticAnnotation\" >" + "</annotation>");
+
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.FALSE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem3",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertEquals("TEST3_ANNOTATION", expected, trim(annotation
+                .getAnnotationString()));
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals(
+                "TEST3_ANNOTATIONS",
+                expected,
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+    }
+
+    /**
+     * Test #5.
+     */
+    public void testElem4Annotation() {
+        String expected = trim("<annotation sn:att=\"SYNTH\"  id=\"ANNOT2\" "
+                + "xmlns=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:sv=\"XSElement\" "
+                + "xmlns:sn=\"SyntheticAnnotation\" >" + "</annotation>");
+
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem4",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertEquals("TEST4_NO_SYNTH_ANNOTATION", expected, trim(annotation
+                .getAnnotationString()));
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals(
+                "TEST4_NO_SYNTH_ANNOTATIONS",
+                expected,
+                trim(((XSAnnotation) 
annotations.item(0)).getAnnotationString()));
+    }
+
+    /**
+     * Test #6.
+     */
+    public void testElem5Annotation() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem5",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertNull("TEST5_NO_ANNOTATION", annotation);
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals("TEST5_NO_ANNOTATIONS", 0, annotations.getLength());
+    }
+
+    /**
+     * Test #6.
+     */
+    public void testElem6Annotation() {
+        fConfig
+                .setParameter(
+                        
"http://apache.org/xml/features/generate-synthetic-annotations";,
+                        Boolean.TRUE);
+
+        XSModel model = fSchemaLoader
+                .loadURI(getResourceURL("XSElementTest01.xsd"));
+        XSElementDeclaration elem = model.getElementDeclaration("elem6",
+                "XSElement");
+
+        XSAnnotation annotation = elem.getAnnotation();
+        assertNull("TEST5_NO_ANNOTATION", annotation);
+        XSObjectList annotations = elem.getAnnotations();
+        assertEquals("TEST5_NO_ANNOTATIONS", 0, annotations.getLength());
+    }
+
+    public static void main(String args[]) {
+        junit.textui.TestRunner.run(XSElementAnnotationsTest.class);
+    }
+}

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/trunk/tests/schema/annotations/XSElementAnnotationsTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd
URL: 
http://svn.apache.org/viewcvs/xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd?rev=379699&r1=379698&r2=379699&view=diff
==============================================================================
--- xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd (original)
+++ xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd Tue Feb 21 
22:06:48 2006
@@ -1,36 +1,36 @@
-<?xml version="1.0"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema";
-    targetNamespace="XSElement" xmlns:sv="XSElement"
-    xmlns:sn="SyntheticAnnotation">
-
-    <element name="elem1">
-        <complexType>
-            <sequence>
-                <element name="elString" type="string" />
-            </sequence>
-        </complexType>
-    </element>
-
-    <element name="elem2" sn:att="SYNTH" />
-
-    <element name="elem3">
-        <annotation id="ANNOT1"></annotation>
-    </element>
-
-    <element name="elem4" sn:att="SYNTH" nillable="true">
-        <annotation id="ANNOT2"></annotation>
-    </element>
-
-    <element name="elem5" substitutionGroup="sv:elem4"/>
-
-    <element name="elem6">
-        <complexType>
-           <annotation id="ANNOT3"></annotation>
-            <simpleContent>
-                <annotation id="ANNOT4"></annotation>
-                <extension base="string"></extension>
-            </simpleContent>
-        </complexType>
-    </element>
-    
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema";
+    targetNamespace="XSElement" xmlns:sv="XSElement"
+    xmlns:sn="SyntheticAnnotation">
+
+    <element name="elem1">
+        <complexType>
+            <sequence>
+                <element name="elString" type="string" />
+            </sequence>
+        </complexType>
+    </element>
+
+    <element name="elem2" sn:att="SYNTH" />
+
+    <element name="elem3">
+        <annotation id="ANNOT1"></annotation>
+    </element>
+
+    <element name="elem4" sn:att="SYNTH" nillable="true">
+        <annotation id="ANNOT2"></annotation>
+    </element>
+
+    <element name="elem5" substitutionGroup="sv:elem4"/>
+
+    <element name="elem6">
+        <complexType>
+           <annotation id="ANNOT3"></annotation>
+            <simpleContent>
+                <annotation id="ANNOT4"></annotation>
+                <extension base="string"></extension>
+            </simpleContent>
+        </complexType>
+    </element>
+    
 </schema>

Propchange: xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/trunk/tests/schema/annotations/XSElementTest01.xsd
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to