1 16 17 package org.apache.axis2.addressing; 18 19 import junit.framework.TestCase; 20 21 import javax.xml.namespace.QName ; 22 23 24 public class EndpointReferenceTypeTest extends TestCase { 25 26 EndpointReference endpointReference; 27 private String headerType = AddressingConstants.WSA_FROM; 28 private String address = "htttp://wwww.openource.lk/~chinthaka"; 29 30 public static void main(String [] args) { 31 junit.textui.TestRunner.run(EndpointReferenceTypeTest.class); 32 } 33 34 37 protected void setUp() throws Exception { 38 super.setUp(); 39 endpointReference = new EndpointReference(headerType, address); 40 } 41 42 public void testGetAndSetMessageInformationHeaderType() { 43 assertEquals("MessageInformationHeaderType not set properly in the constructor", headerType, endpointReference.getMessageInformationHeaderType()); 44 45 endpointReference.setMessageInformationHeaderType(AddressingConstants.WSA_REPLY_TO); 46 assertEquals("MessageInformationHeaderType not set properly in the setter method", AddressingConstants.WSA_REPLY_TO, endpointReference.getMessageInformationHeaderType()); 47 } 48 49 public void testGetAndSetAddress() { 50 assertEquals("Address not set properly in the constructor", address, endpointReference.getAddress()); 51 52 String newAddress = "http://www.axis2.com"; 53 endpointReference.setAddress(newAddress); 54 assertEquals("Address not set properly in the setter method", newAddress, endpointReference.getAddress()); 55 } 56 57 public void testGetAndSetPortType() { 58 QName portType = new QName ("www.someport.com", "port"); 59 endpointReference.setInterfaceName(portType); 60 assertEquals("PortType not set/get properly", portType, endpointReference.getInterfaceName()); 61 } 62 63 public void testGetAndSetReferenceProperties() { 64 AnyContentType anyContentType = new AnyContentType(); 65 for (int i = 0; i < 10; i++) { 66 anyContentType.addReferenceValue(new QName ("http://www.opensouce.lk/" + i, "" + i), "value " + i * 100); 67 } 68 endpointReference.setReferenceProperties(anyContentType); 69 70 AnyContentType retrievedAnyContentType = endpointReference.getReferenceProperties(); 71 for (int i = 0; i < 10; i++) { 72 String value = retrievedAnyContentType.getReferenceValue(new QName ("http://www.opensouce.lk/" + i, "" + i)); 73 assertEquals("Input value differs from what is taken out from AnyContentType", value, "value " + i * 100); 74 } 75 76 } 77 78 public void testGetAndSetReferenceParameters() { 79 AnyContentType anyContentType = new AnyContentType(); 80 for (int i = 0; i < 10; i++) { 81 anyContentType.addReferenceValue(new QName ("http://www.opensouce.lk/" + i, "" + i), "value " + i * 50); 82 } 83 endpointReference.setReferenceParameters(anyContentType); 84 85 AnyContentType retrievedAnyContentType = endpointReference.getReferenceParameters(); 86 for (int i = 0; i < 10; i++) { 87 String value = retrievedAnyContentType.getReferenceValue(new QName ("http://www.opensouce.lk/" + i, "" + i)); 88 assertEquals("Input value differs from what is taken out from AnyContentType", value, "value " + i * 50); 89 } 90 } 91 92 public void testGetAndSetServiceName() { 93 ServiceName serviceName = new ServiceName(new QName ("www.someservicename.org", "service")); 94 endpointReference.setServiceName(serviceName); 95 ServiceName retrievedServiceName = endpointReference.getServiceName(); 96 assertEquals("ServiceName name has not been get/set properly", serviceName.getName(), retrievedServiceName.getName()); 97 98 serviceName = new ServiceName(new QName ("www.someservicename.org", "service"), "portName"); 99 endpointReference.setServiceName(serviceName); 100 retrievedServiceName = endpointReference.getServiceName(); 101 assertEquals("ServiceName name has not been get/set properly", serviceName.getName(), retrievedServiceName.getName()); 102 assertEquals("ServiceName portName has not been get/set properly", serviceName.getEndpointName(), retrievedServiceName.getEndpointName()); 103 } 104 105 } 106 | Popular Tags |