Examples of SchemaValidation


Examples of org.apache.schema_validation.SchemaValidation

        assertNotNull(wsdl);

        SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
        assertNotNull(service);

        SchemaValidation validation = service.getPort(portName, SchemaValidation.class);

        ComplexStruct complexStruct = new ComplexStruct();
        complexStruct.setElem1("one");
        // Don't initialize a member of the structure. 
        // Client side validation should throw an exception.
        // complexStruct.setElem2("two");
        complexStruct.setElem3(3);
        try {
            /*boolean result =*/
            validation.setComplexStruct(complexStruct);
            fail("Set ComplexStruct hould have thrown ProtocolException");
        } catch (WebServiceException e) {
            String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected.";
            assertTrue(e.getMessage(), e.getMessage().indexOf(expected) != -1);
        }

        OccuringStruct occuringStruct = new OccuringStruct();
        // Populate the list in the wrong order.
        // Client side validation should throw an exception.
        List<Serializable> floatIntStringList = occuringStruct.getVarFloatAndVarIntAndVarString();
        floatIntStringList.add(new Integer(42));
        floatIntStringList.add(new Float(4.2f));
        floatIntStringList.add("Goofus and Gallant");
        try {
            /*boolean result =*/
            validation.setOccuringStruct(occuringStruct);
            fail("Set OccuringStruct hould have thrown ProtocolException");
        } catch (WebServiceException e) {
            String expected = "'{\"http://apache.org/schema_validation/types\":varFloat}' is expected.";
            assertTrue(e.getMessage().indexOf(expected) != -1);
        }

        try {
            // The server will attempt to return an invalid ComplexStruct
            // When validation is disabled on the server side, we'll get the
            // exception while unmarshalling the invalid response.
            /*complexStruct =*/
            validation.getComplexStruct("Hello");
            fail("Get ComplexStruct should have thrown ProtocolException");
        } catch (WebServiceException e) {
            String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected.";
            assertTrue("Found message " + e.getMessage(),
                       e.getMessage().indexOf(expected) != -1);
        }

        try {
            // The server will attempt to return an invalid OccuringStruct
            // When validation is disabled on the server side, we'll get the
            // exception while unmarshalling the invalid response.
            /*occuringStruct =*/
            validation.getOccuringStruct("World");
            fail("Get OccuringStruct should have thrown ProtocolException");
        } catch (WebServiceException e) {
            String expected = "'{\"http://apache.org/schema_validation/types\":varFloat}' is expected.";
            assertTrue(e.getMessage().indexOf(expected) != -1);
        }
View Full Code Here

Examples of org.jboss.ws.annotation.SchemaValidation

      }
   }

   private void processSchemaValidation(Deployment dep, ServerEndpointMetaData sepMetaData, Class<?> sepClass)
   {
      SchemaValidation anFeature = sepClass.getAnnotation(SchemaValidation.class);
      SchemaValidationFeature feature = new SchemaValidationFeature(anFeature.enabled());

      String xsdLoc = anFeature.schemaLocation();
      if (xsdLoc.length() > 0)
      {
         if (dep instanceof ArchiveDeployment)
         {
            try
            {
               URL xsdURL = ((ArchiveDeployment)dep).getMetaDataFileURL(xsdLoc);
               xsdLoc = xsdURL.toExternalForm();
            }
            catch (IOException ex)
            {
               throw new WSException("Cannot load schema: " + xsdLoc, ex);
            }
         }
         feature.setSchemaLocation(xsdLoc);
      }

      Class handlerClass = anFeature.errorHandler();
      if (handlerClass != null)
      {
         try
         {
            ErrorHandler errorHandler = (ErrorHandler)handlerClass.newInstance();
View Full Code Here

Examples of org.jboss.ws.annotation.SchemaValidation

      }
   }

   private void processSchemaValidation(Deployment dep, ServerEndpointMetaData sepMetaData, Class<?> sepClass)
   {
      SchemaValidation anFeature = sepClass.getAnnotation(SchemaValidation.class);
      SchemaValidationFeature feature = new SchemaValidationFeature(anFeature.enabled());

      String xsdLoc = anFeature.schemaLocation();
      if (xsdLoc.length() > 0)
      {
         if (dep instanceof ArchiveDeployment)
         {
            try
            {
               URL xsdURL = ((ArchiveDeployment)dep).getMetaDataFileURL(xsdLoc);
               xsdLoc = xsdURL.toExternalForm();
            }
            catch (IOException ex)
            {
               throw new WSException("Cannot load schema: " + xsdLoc, ex);
            }
         }
         feature.setSchemaLocation(xsdLoc);
      }

      Class handlerClass = anFeature.errorHandler();
      if (handlerClass != null)
      {
         try
         {
            ErrorHandler errorHandler = (ErrorHandler)handlerClass.newInstance();
View Full Code Here

Examples of org.jboss.ws.annotation.SchemaValidation

      }
   }

   private void processSchemaValidation(Deployment dep, ServerEndpointMetaData sepMetaData, Class<?> sepClass)
   {
      SchemaValidation anFeature = sepClass.getAnnotation(SchemaValidation.class);
      SchemaValidationFeature feature = new SchemaValidationFeature(anFeature.enabled());

      String xsdLoc = anFeature.schemaLocation();
      if (xsdLoc.length() > 0)
      {
         if (dep instanceof ArchiveDeployment)
         {
            try
            {
               URL xsdURL = ((ArchiveDeployment)dep).getMetaDataFileURL(xsdLoc);
               xsdLoc = xsdURL.toExternalForm();
            }
            catch (IOException ex)
            {
               throw new WSException("Cannot load schema: " + xsdLoc, ex);
            }
         }
         feature.setSchemaLocation(xsdLoc);
      }

      Class handlerClass = anFeature.errorHandler();
      if (handlerClass != null)
      {
         try
         {
            ErrorHandler errorHandler = (ErrorHandler)handlerClass.newInstance();
View Full Code Here

Examples of org.objectweb.schema_validation.SchemaValidation

        assertNotNull(wsdl);
       
        SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
        assertNotNull(service);
       
        SchemaValidation validation = service.getPort(portName, SchemaValidation.class);

        ComplexStruct complexStruct = new ComplexStruct();
        complexStruct.setElem1("one");
        // Don't initialize a member of the structure.  Validation should throw
        // an exception.
        // complexStruct.setElem2("two");
        complexStruct.setElem3(3);
        try {      
            /*boolean result =*/ validation.setComplexStruct(complexStruct);
            fail("Set ComplexStruct hould have thrown ProtocolException");
        } catch (ProtocolException e) {
            //System.out.println(e.getMessage());
        }

        OccuringStruct occuringStruct = new OccuringStruct();
        // Populate the list in the wrong order.  Validation should throw
        // an exception.
        List<Serializable> floatIntStringList = occuringStruct.getVarFloatAndVarIntAndVarString();
        floatIntStringList.add(new Integer(42));
        floatIntStringList.add(new Float(4.2f));
        floatIntStringList.add("Goofus and Gallant");
        try {      
            /*boolean result =*/ validation.setOccuringStruct(occuringStruct);
            fail("Set OccuringStruct hould have thrown ProtocolException");
        } catch (ProtocolException e) {
            //System.out.println(e.getMessage());
        }

        try {
            // The server will attempt to return an invalid ComplexStruct
            /*complexStruct =*/ validation.getComplexStruct("Hello");
            // This would throw an exception if validation is disabled on
            // the server and enabled on the client.
            //fail("Get ComplexStruct should have thrown ProtocolException");
        } catch (ProtocolException e) {
            //System.out.println(e.getMessage());
        }
       
        try {
            // The server will attempt to return an invalid OccuringStruct
            /*occuringStruct =*/ validation.getOccuringStruct("World");
            // This would throw an exception if validation is disabled on
            // the server and enabled on the client.
            //fail("Get OccuringStruct should have thrown ProtocolException");
        } catch (ProtocolException e) {
            //System.out.println(e.getMessage());
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.