Package org.apache.woden

Examples of org.apache.woden.WSDLFactory


   */
  protected void setUp() throws Exception {
    super.setUp();
        System.setProperty(ExtensionRegistry.REGISTRAR_PROPERTY,
                "testcase.extensions.foo.FooExtensionRegistrar");
        WSDLFactory factory = WSDLFactory.newInstance();
        fReader = factory.newWSDLReader();
        testErrorHandler = new TestErrorHandler();
        //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc.
        fReader.getErrorReporter().setErrorHandler(testErrorHandler);
       
       
View Full Code Here


        // create a reader (with specified implementation if given).
        try {
           //If an implementation name is given use that to test against, else use the default one.
           if (implName != null && !implName.equals("")) {
               logger.info("Using woden with implementation from " + implName);
               WSDLFactory factory = WSDLFactory.newInstance(implName);
               reader = factory.newWSDLReader();
           } else {
               logger.info("Using default woden implementation.");
               WSDLFactory factory = WSDLFactory.newInstance();
               reader = factory.newWSDLReader();
           }

        } catch (WSDLException e) {

            // fail if unable to create a reader
View Full Code Here

        Report reportWriter = Report.openReport(new File(reportLoc));
        reportWriter.beginWsdl(wsdlLoc);

        try {

            WSDLFactory factory = WSDLFactory.newInstance();
            WSDLReader reader = factory.newWSDLReader();

            // <-- enable WSDL 2.0 validation (optional)
            reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
           
            //Add errorHandler
View Full Code Here

     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        WSDLFactory factory = null;
        try {
            factory = WSDLFactory.newInstance();
        } catch (WSDLException e) {
            fail("Can't instantiate the WSDLFactory object.");
        }
        fDescriptionElement = factory.newDescription();
        fDescriptionElement.setTargetNamespace(URI.create(TNS));
        fInterfaceElement = fDescriptionElement.addInterfaceElement();
        fInterfaceElement.setName(new NCName(INTF_NAME));
        fInterfaceOperationElement = fInterfaceElement.addInterfaceOperationElement();
        fInterfaceOperationElement.setName(new NCName(OPER_NAME));
View Full Code Here

     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        WSDLFactory factory = null;
        try {
            factory = WSDLFactory.newInstance();
        } catch (WSDLException e) {
            fail("Can't instantiate the WSDLFactory object.");
        }
        fDescriptionElement = factory.newDescription();
        fDescriptionElement.setTargetNamespace(URI.create(TNS));
        fInterfaceElement = fDescriptionElement.addInterfaceElement();
        fInterfaceElement.setName(new NCName(INTF_NAME));
        fFaultElement = fInterfaceElement.addInterfaceFaultElement();
        fFaultElement.setName(new NCName(FAULT_NAME));
View Full Code Here

  catch(URISyntaxException e)
  {
    fail("There was a problem creating the test URIs: " + e);
  }

    WSDLFactory factory = null;
    try {
        factory = WSDLFactory.newInstance();
    } catch (WSDLException e) {
        fail("Can't instantiate the WSDLFactory object.");
    }
   
  // Test that a schema without any style defaults is valid.
  handler.reset();
    try
  {
      DescriptionElement desc = factory.newDescription();
      InterfaceElement interfaceElem = desc.addInterfaceElement();
    if(!val.testAssertionInterface1012(interfaceElem, reporter))
    {
      fail("The testAssertionInterface1012 method returned false for an interface that specifies no style defaults.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a schema with an absolute style default is valid.
  handler.reset();
  try
  {
          DescriptionElement desc = factory.newDescription();
      InterfaceElement interfaceElem = desc.addInterfaceElement();
    interfaceElem.addStyleDefaultURI(absoluteURI);
    if(!val.testAssertionInterface1012(interfaceElem, reporter))
    {
      fail("The testAssertionInterface1012 method returned false for an interface that specifies one absolute style default.");
    }
    }
  catch(WSDLException e)
  {
    fail("There was a problem running the test assertion method " + e);
    }
 
    // Test that a schema with a relative style default is not valid.
  handler.reset();
  try
  {
      DescriptionElement desc = factory.newDescription();
    InterfaceElement interfaceElem = desc.addInterfaceElement();
    interfaceElem.addStyleDefaultURI(relativeURI);
    if(val.testAssertionInterface1012(interfaceElem, reporter))
    {
      fail("The testAssertionInterface1012 method returned true for an interface that specifies one relative style default.");
    }
    }
  catch(WSDLException e)
  {
    fail("There was a problem running the test assertion method " + e);
    }
 
    // Test that a schema with an absolute style default and a relative sytle default is not valid.
  handler.reset();
  try
  {
      DescriptionElement desc = factory.newDescription();
      InterfaceElement interfaceElem = desc.addInterfaceElement();
    interfaceElem.addStyleDefaultURI(absoluteURI);
    interfaceElem.addStyleDefaultURI(relativeURI);
    if(val.testAssertionInterface1012(interfaceElem, reporter))
    {
      fail("The testAssertionInterface1012 method returned true for an interface that specifies an absolute style default and a relative style default.");
    }
    }
  catch(WSDLException e)
  {
    fail("There was a problem running the test assertion method " + e);
    }
 
    // Test that a schema with two relative style defaults returns two error messages
  handler.reset();
  try
  {
      DescriptionElement desc = factory.newDescription();
      InterfaceElement interfaceElem = desc.addInterfaceElement();
    interfaceElem.addStyleDefaultURI(relativeURI);
    interfaceElem.addStyleDefaultURI(relativeURI2);
    val.testAssertionInterface1012(interfaceElem, reporter);
    if(handler.numErrors != 2)
View Full Code Here

   * TODO: Implement tests for specific elements that contain invalid references.
   *       These tests should probably be contained in a test method for validateInterfaces, validateBindings, etc.
   */
  public void testTestAssertionSchema1066()
  {
    WSDLFactory factory = null;
    try {
        factory = WSDLFactory.newInstance();
    } 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);
View Full Code Here

TOP

Related Classes of org.apache.woden.WSDLFactory

Copyright © 2018 www.massapicom. 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.