@Test public void testOneWay() throws Exception { assertFalse(operationInfo.isOneWay()); MessageInfo inputMessage = operationInfo.createMessage( new QName("http://apache.org/hello_world_soap_http", "testInputMessage"), MessageInfo.Type.INPUT); operationInfo.setInput("input", inputMessage); assertTrue(operationInfo.isOneWay()); }
@Test public void testName() throws Exception { assertNull(operationInfo.getInterface()); assertEquals("operationTest", operationInfo.getName().getLocalPart()); operationInfo.setName(new QName("urn:test:ns", "operationTest2")); assertEquals("operationTest2", operationInfo.getName().getLocalPart()); try { operationInfo.setName(null); fail("should catch IllegalArgumentException since name is null"); } catch (NullPointerException e) { assertEquals(e.getMessage(), "Operation Name cannot be null."); } }
@Test public void testFault() throws Exception { assertEquals(operationInfo.getFaults().size(), 0); QName faultName = new QName("urn:test:ns", "fault"); operationInfo.addFault( faultName, new QName("http://apache.org/hello_world_soap_http", "faultMessage")); assertEquals(operationInfo.getFaults().size(), 1); FaultInfo fault = operationInfo.getFault(faultName); assertNotNull(fault); assertEquals(fault.getFaultName().getLocalPart(), "fault"); assertEquals(fault.getName().getLocalPart(), "faultMessage"); assertEquals(fault.getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http"); operationInfo.removeFault(faultName); assertEquals(operationInfo.getFaults().size(), 0); try { operationInfo.addFault(null, null); fail("should get NullPointerException"); } catch (NullPointerException e) { assertEquals("Fault Name cannot be null.", e.getMessage()); } try { operationInfo.addFault(faultName, null); operationInfo.addFault(faultName, null); fail("should get IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals( e.getMessage(), "A fault with name [{urn:test:ns}fault] already exists in this operation"); } }
private void initMessagesMap() { messages = new ConcurrentHashMap<NamedID, MessageInfo>(16, 0.75f, 2); for (OperationInfo operation : getInterface().getOperations()) { if (operation.getInput() != null) { messages.put(operation.getInput().getName(), operation.getInput()); } if (operation.getOutput() != null) { messages.put(operation.getOutput().getName(), operation.getOutput()); } } }
@Test public void testOutput() throws Exception { assertFalse(operationInfo.hasOutput()); MessageInfo outputMessage = operationInfo.createMessage( new QName("http://apache.org/hello_world_soap_http", "testOutputMessage"), MessageInfo.Type.OUTPUT); operationInfo.setOutput("output", outputMessage); assertTrue(operationInfo.hasOutput()); outputMessage = operationInfo.getOutput(); assertEquals("testOutputMessage", outputMessage.getName().getLocalPart()); assertEquals( "http://apache.org/hello_world_soap_http", outputMessage.getName().getNamespaceURI()); assertEquals(operationInfo.getOutputName(), "output"); }