KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > addressing > EndpointReferenceTypeTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16  
17 package org.apache.axis2.addressing;
18
19 import junit.framework.TestCase;
20
21 import javax.xml.namespace.QName JavaDoc;
22
23
24 public class EndpointReferenceTypeTest extends TestCase {
25
26     EndpointReference endpointReference;
27     private String JavaDoc headerType = AddressingConstants.WSA_FROM;
28     private String JavaDoc address = "htttp://wwww.openource.lk/~chinthaka";
29
30     public static void main(String JavaDoc[] args) {
31         junit.textui.TestRunner.run(EndpointReferenceTypeTest.class);
32     }
33
34     /*
35      * @see TestCase#setUp()
36      */

37     protected void setUp() throws Exception JavaDoc {
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 JavaDoc 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 JavaDoc portType = new QName JavaDoc("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 JavaDoc("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 JavaDoc value = retrievedAnyContentType.getReferenceValue(new QName JavaDoc("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 JavaDoc("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 JavaDoc value = retrievedAnyContentType.getReferenceValue(new QName JavaDoc("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 JavaDoc("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 JavaDoc("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