1 package org.objectweb.celtix.systest.schema_validation; 2 3 import java.io.Serializable ; 4 import java.net.URL ; 5 import java.util.List ; 6 7 import javax.xml.namespace.QName ; 8 import javax.xml.ws.ProtocolException; 9 10 import junit.framework.Test; 11 import junit.framework.TestSuite; 12 13 import org.objectweb.celtix.systest.common.ClientServerSetupBase; 14 import org.objectweb.celtix.systest.common.ClientServerTestBase; 15 import org.objectweb.schema_validation.SchemaValidation; 16 import org.objectweb.schema_validation.SchemaValidationService; 17 import org.objectweb.schema_validation.types.ComplexStruct; 18 import org.objectweb.schema_validation.types.OccuringStruct; 19 20 public class ValidationClientServerTest extends ClientServerTestBase { 21 22 private final QName serviceName = new QName ("http://objectweb.org/schema_validation", 23 "SchemaValidationService"); 24 private final QName portName = new QName ("http://objectweb.org/schema_validation", 25 "SoapPort"); 26 27 public static Test suite() throws Exception { 28 TestSuite suite = new TestSuite(ValidationClientServerTest.class); 29 return new ClientServerSetupBase(suite) { 30 public void startServers() throws Exception { 31 assertTrue("server did not launch correctly", launchServer(ValidationServer.class)); 32 } 33 34 public void setUp() throws Exception { 35 URL url = getClass().getResource("celtix-config.xml"); 37 assertNotNull("cannot find test resource", url); 38 configFileName = url.toString(); 39 super.setUp(); 40 } 41 }; 42 } 43 44 public void testSchemaValidation() throws Exception { 47 URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl"); 48 assertNotNull(wsdl); 49 50 SchemaValidationService service = new SchemaValidationService(wsdl, serviceName); 51 assertNotNull(service); 52 53 SchemaValidation validation = service.getPort(portName, SchemaValidation.class); 54 55 ComplexStruct complexStruct = new ComplexStruct(); 56 complexStruct.setElem1("one"); 57 complexStruct.setElem3(3); 61 try { 62 validation.setComplexStruct(complexStruct); 63 fail("Set ComplexStruct hould have thrown ProtocolException"); 64 } catch (ProtocolException e) { 65 } 67 68 OccuringStruct occuringStruct = new OccuringStruct(); 69 List <Serializable > floatIntStringList = occuringStruct.getVarFloatAndVarIntAndVarString(); 72 floatIntStringList.add(new Integer (42)); 73 floatIntStringList.add(new Float (4.2f)); 74 floatIntStringList.add("Goofus and Gallant"); 75 try { 76 validation.setOccuringStruct(occuringStruct); 77 fail("Set OccuringStruct hould have thrown ProtocolException"); 78 } catch (ProtocolException e) { 79 } 81 82 try { 83 validation.getComplexStruct("Hello"); 85 } catch (ProtocolException e) { 89 } 91 92 try { 93 validation.getOccuringStruct("World"); 95 } catch (ProtocolException e) { 99 } 101 } 102 103 public static void main(String [] args) { 104 junit.textui.TestRunner.run(ValidationClientServerTest.class); 105 } 106 107 } 108 | Popular Tags |