Examples of InlinedSchema


Examples of org.apache.woden.schema.InlinedSchema

/**
  * Test that the included schema document matches the expected value parsed from the WSDL.
  */
public void testCheckSchemaInclude()
{
   InlinedSchema schema1 = fInlinedSchemas[0];
   XmlSchema xmlSchema = schema1.getSchemaDefinition();
   assertEquals("Unexpected targetNamespace.", "http://example.org/getAccountDetails/", schema1.getNamespace().toString());
      
   XmlSchemaObjectCollection schemaIncludes = xmlSchema.getIncludes(); // returns both includes and imports
     Iterator schemaIterator = schemaIncludes.getIterator();
   while (schemaIterator.hasNext())
   {
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

  boolean isValid = true;
  int numInlineSchemas = schema.length;
  Hashtable schemas = new Hashtable();
  for(int i = 0; i < numInlineSchemas; i++)
  {
    InlinedSchema iSchema = schema[i];
    URI iSchemaNs = iSchema.getNamespace();
    // If the namespace isn't defined this assertion doesn't apply.
    if(iSchemaNs == null)
    continue;
    String ns = iSchemaNs.toString();
   
    if(schemas.containsKey(ns))
    {
    List schemaList = (List)schemas.get(ns);
    XmlSchemaObjectTable elements = iSchema.getSchemaDefinition().getElements();
    Iterator elementNames = elements.getNames();
    while(elementNames.hasNext())
    {
      QName elementName = (QName)elementNames.next();
      Iterator otherInlineSchemas = schemaList.iterator();
      while(otherInlineSchemas.hasNext())
      {
      if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getElementByName(elementName) != null)
      {
        // Duplicate element defined.
        errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073", new Object[]{elementName, ns}, ErrorReporter.SEVERITY_ERROR);
        isValid = false;
      }
      }
   
    }
   
    XmlSchemaObjectTable types = iSchema.getSchemaDefinition().getSchemaTypes();
    Iterator typeNames = types.getNames();
    while(typeNames.hasNext())
    {
      QName typeName = (QName)typeNames.next();
      Iterator otherInlineSchemas = schemaList.iterator();
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

/**
  * Test that the included schema document matches the expected value parsed from the WSDL.
  */
public void testCheckSchemaInclude()
{
   InlinedSchema schema1 = fInlinedSchemas[0];
   XmlSchema xmlSchema = schema1.getSchemaDefinition();
   assertEquals("Unexpected targetNamespace.", "http://example.org/getAccountDetails/", schema1.getNamespace().toString());
      
   XmlSchemaObjectCollection schemaIncludes = xmlSchema.getIncludes(); // returns both includes and imports
     Iterator schemaIterator = schemaIncludes.getIterator();
   while (schemaIterator.hasNext())
   {
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

    } catch (WSDLException e) {
        fail("Can't instantiate the WSDLFactory object.");
    }

  // Create a schema for use in the tests and add it to a types section.
    InlinedSchema schema = new InlinedSchemaImpl();
    XmlSchema xs1 = null;
    URI schemaNS = null;
  try
  {
      String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
              + "<complexType name=\"myType\">"    
              + "<sequence>"    
              + "<element  name=\"element\" type=\"string\"/>"     
              + "</sequence>"    
              + "</complexType>"
              + "<element name=\"myElement\" type=\"string\"/>"
              + "</schema>";
      DOMParser builder = new DOMParser();
    Reader reader = new StringReader(schemaString);
      XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
      builder.parse(is);
      Document schemaDoc1 = builder.getDocument();
      XmlSchemaCollection xsc = new XmlSchemaCollection();
      xs1 = xsc.read(schemaDoc1.getDocumentElement());
      schemaNS = new URI("http://www.sample.org");
      schema.setSchemaDefinition(xs1);
      schema.setNamespace(schemaNS);
      TypesElement types = factory.newDescription().addTypesElement();
      types.addSchema(schema);
  }
  catch(Exception e)
  {
    fail("An error occurred while creating the sample types section.");
  }
   
    // Test that a null namespace returns true.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, null, reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a null namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to a namespace that is defined inline
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been defined inline.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that is imported
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      ImportedSchema importedSchema = new ImportedSchemaImpl();
      importedSchema.setSchemaDefinition(xs1);
      importedSchema.setNamespace(schemaNS);
      typesImported.addSchema(importedSchema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to the XML Schema namespace does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(!val.testAssertionSchema1066(descElem, new QName(Constants.TYPE_XSD_2001, "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for the XML Schema namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that has not been defined inline or imported returns an error.
  // This test also checks that the method functions correctly with no defined types element.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(val.testAssertionSchema1066(descElem, new QName("http://www.sample2.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned true for a namespace that is not available..");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to an inline schema that does not define a
  // target namespace (the targetNamespace is null) does not return an
  // error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      InlinedSchema inlinedSchema = new InlinedSchemaImpl();
      typesImported.addSchema(inlinedSchema);
      InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
      inlinedSchema2.setNamespace(schemaNS);
      typesImported.addSchema(inlinedSchema2);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

      fInterfaceElement.setName(new NCName("interfaceName"));
      fServiceElement = fDescriptionElement.addServiceElement();
      fServiceElement.setName(new NCName("serviceName"));

        //Create a test schema
        InlinedSchema schema = new InlinedSchemaImpl();
        XmlSchema xs1 = null;
        URI schemaNS = null;

        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\">"
                    + "<element  name=\"myEd\" type=\"string\"/>"
                    + "<complexType name=\"myTypeDef\">"    
                    + "<sequence>"    
                    + "<element name=\"element\" type=\"string\"/>"     
                    + "</sequence>"    
                    + "</complexType>"
                    + "</schema>";
       
        DOMParser builder = new DOMParser();
        Reader reader = new StringReader(schemaString);
        XMLInputSource is = new XMLInputSource(null, null, null, reader, null);
        try {
            builder.parse(is);
        } catch(IOException e) {
            fail("There was an IOException whilst trying to parse the sample schema.");
        }
        Document schemaDoc1 = builder.getDocument();
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
     
        //Add it to the typesElement.
        TypesElement typesEl = fDescriptionElement.addTypesElement();
        typesEl.addSchema(schema);
       
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

        // Default case
        assertNull("When 'element' attribute is omitted, no ElementDeclaration should be present", msgRef.getElementDeclaration());
       
        // Test that the expected ElementDeclaration is returned
        TypesElement typesElement = fDescriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DOMParser builder = new DOMParser();
        Reader reader = new StringReader(schemaString);
        XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
        builder.parse(is)//throws IOException
        Document schemaDoc1 = builder.getDocument();
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
       
        fMessageReferenceElement.setElement(new QNameTokenUnion(elemQN));
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

        retrievedElement = messageReference.getXmlSchemaElement();
        assertNull("Should return null if 'element' attribute is #other", retrievedElement);

        // Case 4 - (with 'element' set to the qname of a schema element declaration)
        TypesElement typesElement = descriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DOMParser builder = new DOMParser();
        Reader reader = new StringReader(schemaString);
        XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
        builder.parse(is)//throws IOException
        Document schemaDoc1 = builder.getDocument();
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
        XmlSchemaElement expectedElement = xs1.getElementByName(elemQN);
       
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

        // Default case
        assertNull("When 'element' attribute is omitted, no ElementDeclaration should be present", fault.getElementDeclaration());
       
        // Test that the expected ElementDeclaration is returned
        TypesElement typesElement = fDescriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DOMParser builder = new DOMParser();
        Reader reader = new StringReader(schemaString);
        XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
        builder.parse(is)//throws IOException
        Document schemaDoc1 = builder.getDocument();
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
       
        fFaultElement.setElement(new QNameTokenUnion(elemQN));
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

        retrievedElement = faultElement.getXmlSchemaElement();
        assertNull("Should return null if 'element' attribute is #other", retrievedElement);

        // Case 4 - (with 'element' set to the qname of a schema element declaration)
        TypesElement typesElement = descriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DOMParser builder = new DOMParser();
        Reader reader = new StringReader(schemaString);
        XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
        builder.parse(is)//throws IOException
        Document schemaDoc1 = builder.getDocument();
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
        XmlSchemaElement expectedElement = xs1.getElementByName(elemQN);
       
View Full Code Here

Examples of org.apache.woden.schema.InlinedSchema

    } catch (WSDLException e) {
        fail("Can't instantiate the WSDLFactory object.");
    }

  // Create a schema for use in the tests and add it to a types section.
    InlinedSchema schema = new InlinedSchemaImpl();
    XmlSchema xs1 = null;
    URI schemaNS = null;
  try
  {
      String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
              + "<complexType name=\"myType\">"    
              + "<sequence>"    
              + "<element  name=\"element\" type=\"string\"/>"     
              + "</sequence>"    
              + "</complexType>"
              + "<element name=\"myElement\" type=\"string\"/>"
              + "</schema>";
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      DocumentBuilder builder=dbf.newDocumentBuilder();
    Reader reader = new StringReader(schemaString);
      InputSource is = new InputSource(reader);
      Document schemaDoc1 = builder.parse(is);
      XmlSchemaCollection xsc = new XmlSchemaCollection();
      xs1 = xsc.read(schemaDoc1.getDocumentElement());
      schemaNS = new URI("http://www.sample.org");
      schema.setSchemaDefinition(xs1);
      schema.setNamespace(schemaNS);
      TypesElement types = factory.newDescription().addTypesElement();
      types.addSchema(schema);
  }
  catch(Exception e)
  {
    fail("An error occurred while creating the sample types section.");
  }
   
    // Test that a null namespace returns true.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, null, reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a null namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to a namespace that is defined inline
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been defined inline.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that is imported
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      ImportedSchema importedSchema = new ImportedSchemaImpl();
      importedSchema.setSchemaDefinition(xs1);
      importedSchema.setNamespace(schemaNS);
      typesImported.addSchema(importedSchema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to the XML Schema namespace does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(!val.testAssertionSchema1066(descElem, new QName(Constants.TYPE_XSD_2001, "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for the XML Schema namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that has not been defined inline or imported returns an error.
  // This test also checks that the method functions correctly with no defined types element.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(val.testAssertionSchema1066(descElem, new QName("http://www.sample2.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned true for a namespace that is not available..");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to an inline schema that does not define a
  // target namespace (the targetNamespace is null) does not return an
  // error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      InlinedSchema inlinedSchema = new InlinedSchemaImpl();
      typesImported.addSchema(inlinedSchema);
      InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
      inlinedSchema2.setNamespace(schemaNS);
      typesImported.addSchema(inlinedSchema2);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.