butek 2002/10/11 06:12:01 Modified: java/test/wsdl/getPort GetPortTestCase.java getPort.wsdl Log: I added to the getPort test to test the generated getPort(QName, Class) and getPorts methods for multiple ports per service. Revision Changes Path 1.3 +98 -0 xml-axis/java/test/wsdl/getPort/GetPortTestCase.java Index: GetPortTestCase.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/getPort/GetPortTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GetPortTestCase.java 27 Mar 2002 18:36:48 -0000 1.2 +++ GetPortTestCase.java 11 Oct 2002 13:12:01 -0000 1.3 @@ -1,10 +1,22 @@ package test.wsdl.getPort; +import java.util.Iterator; + +import javax.xml.namespace.QName; + +import javax.xml.rpc.Service; import javax.xml.rpc.ServiceException; +import javax.xml.rpc.Stub; // This test makes sure that the getPort method works in various service classes. public class GetPortTestCase extends junit.framework.TestCase { + + private static final QName portOne = new QName("portOne"); + private static final QName portTwo = new QName("portTwo"); + private static final QName portTwoA = new QName("portTwoA"); + private static final QName portThree = new QName("portThree"); + public GetPortTestCase(String name) { super(name); } // ctor @@ -39,6 +51,22 @@ assertTrue("Wrong exception! " + se.getLinkedCause(), se.getLinkedCause() == null); } + + // Make sure we get the proper ports + try { + Stub one = (Stub) service.getPort(portOne, One.class); + Stub two = (Stub) service.getPort(portTwo, Two.class); + Stub three = (Stub) service.getPort(portThree, Three.class); + assertTrue("getPort(portOne) should be of type One, instead it is " + one.getClass().getName(), one instanceof One); + assertTrue("getPort(portOne) should have address http://localhost:8080/axis/services/portOne, instead it has " + one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portOne".equals(one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portTwo) should be of type Two, instead it is " + two.getClass().getName(), two instanceof Two); + assertTrue("getPort(portTwo) should have address http://localhost:8080/axis/services/portTwo, instead it has " + two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portTwo".equals(two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portThree) should be of type Three, instead it is " + three.getClass().getName(), three instanceof Three); + assertTrue("getPort(portThree) should have address http://localhost:8080/axis/services/portThree, instead it has " + three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portThree".equals(three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + } + catch (ServiceException se) { + fail("unexpected failure: " + se); + } } // testNormalService public void testDoublePortService1() { @@ -58,6 +86,22 @@ assertTrue("Wrong exception! " + se.getLinkedCause(), se.getLinkedCause() == null); } + + // Make sure we get the proper ports + try { + Stub one = (Stub) service.getPort(portOne, One.class); + Stub two = (Stub) service.getPort(portTwo, Two.class); + Stub three = (Stub) service.getPort(portTwoA, Three.class); + assertTrue("getPort(portOne) should be of type One, instead it is " + one.getClass().getName(), one instanceof One); + assertTrue("getPort(portOne) should have address http://localhost:8080/axis/services/portOne, instead it has " + one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portOne".equals(one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portTwo) should be of type Two, instead it is " + two.getClass().getName(), two instanceof Two); + assertTrue("getPort(portTwo) should have address http://localhost:8080/axis/services/portTwo, instead it has " + two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portTwo".equals(two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portTwoA) should be of type Two, instead it is " + three.getClass().getName(), three instanceof Two); + assertTrue("getPort(portThree) should have address http://localhost:8080/axis/services/portTwoA, instead it has " + three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portTwoA".equals(three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + } + catch (ServiceException se) { + fail("unexpected failure: " + se); + } } // testDoublePortService1 public void testDoublePortService2() { @@ -77,7 +121,61 @@ assertTrue("Wrong exception! " + se.getLinkedCause(), se.getLinkedCause() == null); } + + // Make sure we get the proper ports + try { + Stub one = (Stub) service.getPort(portOne, One.class); + Stub two = (Stub) service.getPort(portTwo, Two.class); + Stub three = (Stub) service.getPort(portThree, Three.class); + assertTrue("getPort(portOne) should be of type One, instead it is " + one.getClass().getName(), one instanceof One); + assertTrue("getPort(portOne) should have address http://localhost:8080/axis/services/portOne, instead it has " + one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portOne".equals(one._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portTwo) should be of type Two, instead it is " + two.getClass().getName(), two instanceof Two); + assertTrue("getPort(portTwo) should have address http://localhost:8080/axis/services/portTwo, instead it has " + two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portTwo".equals(two._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + assertTrue("getPort(portThree) should be of type One, instead it is " + three.getClass().getName(), three instanceof One); + assertTrue("getPort(portThree) should have address http://localhost:8080/axis/services/portFour, instead it has " + three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), "http://localhost:8080/axis/services/portFour".equals(three._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY))); + } + catch (ServiceException se) { + fail("unexpected failure: " + se); + } } // testDoublePortService2 + + public void testGetPorts() { + Service service = null; + try { + service = new EmptyLocator(); + verifyNumberOfPorts("Empty", service.getPorts(), 0); + } + catch (ServiceException se) { + fail("EmptyLocator.getPorts() should not have failed: " + se); + } + try { + service = new ServiceALocator(); + verifyNumberOfPorts("ServiceA", service.getPorts(), 3); + } + catch (ServiceException se) { + fail("ServiceA.getPorts() should not have failed: " + se); + } + try { + service = new ServiceBLocator(); + verifyNumberOfPorts("ServiceB", service.getPorts(), 3); + } + catch (ServiceException se) { + fail("ServiceB.getPorts() should not have failed: " + se); + } + try { + service = new ServiceCLocator(); + verifyNumberOfPorts("ServiceC", service.getPorts(), 3); + } + catch (ServiceException se) { + fail("ServiceC.getPorts() should not have failed: " + se); + } + } // testGetPorts + + private void verifyNumberOfPorts(String service, Iterator i, int shouldHave) { + int count = 0; + for (;i.hasNext();count++,i.next()); + assertTrue("Service " + service + " should have " + shouldHave + " ports but instead has " + count, shouldHave == count); + } // verifyNumberOfPorts } // class VerifyTestCase 1.2 +1 -1 xml-axis/java/test/wsdl/getPort/getPort.wsdl Index: getPort.wsdl =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/getPort/getPort.wsdl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- getPort.wsdl 21 Mar 2002 14:30:26 -0000 1.1 +++ getPort.wsdl 11 Oct 2002 13:12:01 -0000 1.2 @@ -55,7 +55,7 @@ <soap:address location="http://localhost:8080/axis/services/portTwo"/> </port> <port name="portTwoA" binding="tns:bindingTwo"> - <soap:address location="http://localhost:8080/axis/services/portTwo"/> + <soap:address location="http://localhost:8080/axis/services/portTwoA"/> </port> </service> <service name="serviceC">