1 package tests;
2
3 import junit.framework.TestCase;
4
5 import javax.xml.namespace.QName;
6 import javax.xml.transform.stream.StreamSource;
7 import java.io.InputStream;
8 import java.io.FileInputStream;
9
10 import org.apache.ws.commons.schema.*;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class AttributeRefTest extends TestCase {
30
31 public void testAttRefsWithNS() throws Exception{
32 QName TYPE_QNAME = new QName("http://tempuri.org/attribute",
33 "TestAttributeReferenceType");
34
35
36 InputStream is = new FileInputStream(Resources.asURI("attributref.xsd"));
37 XmlSchemaCollection schema = new XmlSchemaCollection();
38 XmlSchema s = schema.read(new StreamSource(is), null);
39
40 XmlSchemaComplexType typeByName = (XmlSchemaComplexType)s.getTypeByName(TYPE_QNAME);
41 assertNotNull(typeByName);
42
43 XmlSchemaAttribute item = (XmlSchemaAttribute)typeByName.getAttributes().getItem(0);
44 QName qName = item.getRefName();
45 assertNotNull(qName);
46
47 String namspace = qName.getNamespaceURI();
48 assertEquals("http://tempuri.org/attribute",namspace);
49 }
50
51
52 }