PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/ojc-core/hl7bc/hl7bcimpl/test/com/sun/jbi/hl7bc/EndpointImplTest.java

https://bitbucket.org/pymma/openesb-components
Java | 334 lines | 183 code | 64 blank | 87 comment | 0 complexity | a74f2278e65e7adfbfd1f9db9aba6089 MD5 | raw file
  1. /*
  2. * BEGIN_HEADER - DO NOT EDIT
  3. *
  4. * The contents of this file are subject to the terms
  5. * of the Common Development and Distribution License
  6. * (the "License"). You may not use this file except
  7. * in compliance with the License.
  8. *
  9. * You can obtain a copy of the license at
  10. * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
  11. * See the License for the specific language governing
  12. * permissions and limitations under the License.
  13. *
  14. * When distributing Covered Code, include this CDDL
  15. * HEADER in each file and include the License file at
  16. * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
  17. * If applicable add the following below this CDDL HEADER,
  18. * with the fields enclosed by brackets "[]" replaced with
  19. * your own identifying information: Portions Copyright
  20. * [year] [name of copyright owner]
  21. */
  22. /*
  23. * @(#)EndpointImplTest.java
  24. *
  25. * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
  26. *
  27. * END_HEADER - DO NOT EDIT
  28. */
  29. package com.sun.jbi.hl7bc;
  30. import junit.framework.*;
  31. import com.sun.jbi.eManager.provider.EndpointStatus;
  32. import com.sun.jbi.hl7bc.Endpoint.EndpointType;
  33. import com.sun.jbi.hl7bc.Endpoint.EndpointState;
  34. import com.sun.jbi.hl7bc.extensions.HL7Address;
  35. import com.sun.jbi.hl7bc.extensions.HL7Binding;
  36. import com.sun.jbi.hl7bc.extensions.HL7Operation;
  37. import com.sun.jbi.hl7bc.extensions.HL7Input;
  38. import com.sun.jbi.hl7bc.extensions.HL7Output;
  39. import com.sun.jbi.hl7bc.extensions.HL7ProtocolProperties;
  40. import java.util.HashMap;
  41. import java.util.Map;
  42. import java.util.List;
  43. import java.util.ArrayList;
  44. import javax.jbi.servicedesc.ServiceEndpoint;
  45. import javax.wsdl.Definition;
  46. import javax.xml.namespace.QName;
  47. import com.ibm.wsdl.DefinitionImpl;
  48. import org.w3c.dom.Document;
  49. import org.jmock.*;
  50. /**
  51. * @author Raghunadh
  52. */
  53. public class EndpointImplTest extends MockObjectTestCase {
  54. EndpointImpl instance = null;
  55. public EndpointImplTest(String testName) {
  56. super(testName);
  57. }
  58. protected void setUp() throws Exception {
  59. instance = new EndpointImpl();
  60. }
  61. protected void tearDown() throws Exception {
  62. }
  63. public static Test suite() {
  64. TestSuite suite = new TestSuite(EndpointImplTest.class);
  65. return suite;
  66. }
  67. /**
  68. * Test of setServiceName and getServiceName method, of class com.sun.jbi.hl7bc.EndpointImpl.
  69. */
  70. public void testSetGetServiceName() {
  71. System.out.println("Testing setServiceName and getServiceName");
  72. QName expResult = new QName("http://my-hl7bc-test/mynamespace", "myHL7Service");
  73. instance.setServiceName(new QName("http://my-hl7bc-test/mynamespace", "myHL7Service"));
  74. QName result = instance.getServiceName();
  75. assertEquals(expResult, result);
  76. System.out.println("Successfully tested setServiceName and getServiceName");
  77. }
  78. /**
  79. * Test of setEndpointName and getEndpointName method, of class com.sun.jbi.hl7bc.EndpointImpl.
  80. */
  81. public void testSetGetEndpointName() {
  82. System.out.println("Testing setEndpointName and getEndpointName");
  83. String expResult = "myHL7TestPort";
  84. instance.setEndpointName(expResult);
  85. String result = instance.getEndpointName();
  86. assertEquals(expResult, result);
  87. System.out.println("Successfully tested setEndpointName and getEndpointName");
  88. }
  89. /**
  90. * Test of setDefinition and getDefinition method, of class com.sun.jbi.hl7bc.EndpointImpl.
  91. */
  92. public void testSetGetDefinition() {
  93. System.out.println("Testing setDefinition and getDefinition");
  94. QName definitionQName = new QName("serviceDefinition");
  95. Mock definitionMock = mock (Definition.class);
  96. definitionMock.stubs().method("getQName").will(returnValue(definitionQName));
  97. Definition expResult = (Definition)definitionMock.proxy();
  98. instance.setDefinition(expResult);
  99. Definition result = instance.getDefinition();
  100. assertEquals(expResult.getQName(), result.getQName());
  101. System.out.println("Successfully tested setDefinition and getDefinition");
  102. }
  103. /**
  104. * Test of setState and getState method, of class com.sun.jbi.hl7bc.EndpointImpl.
  105. */
  106. public void testSetGetState() {
  107. System.out.println("Testing setState and getState");
  108. int expResult = Endpoint.EndpointState.SHUTDOWN;
  109. instance.setState(expResult);
  110. int result = instance.getState();
  111. assertEquals(expResult, result);
  112. System.out.println("Successfully tested setState and getState");
  113. }
  114. /**
  115. * Test of setEndpointStatus and getEndpointStatus method, of class
  116. * com.sun.jbi.hl7bc.EndpointImpl.
  117. */
  118. public void testSetGetEndpointStatus() {
  119. System.out.println("Testing setEndpointStatus and getEndpointStatus");
  120. Mock endpointStatusMock = mock (EndpointStatus.class);
  121. EndpointStatus expResult = (EndpointStatus)endpointStatusMock.proxy();
  122. instance.setEndpointStatus(expResult);
  123. EndpointStatus result = instance.getEndpointStatus();
  124. assertEquals(expResult, result);
  125. System.out.println("Successfully tested setEndpointStatus and getEndpointStatus");
  126. }
  127. /**
  128. * Test of setEndpointType and getEndpointType method, of class com.sun.jbi.hl7bc.EndpointImpl.
  129. */
  130. public void testSetGetEndpointType() {
  131. System.out.println("Testing setEndpointType and getEndpointType");
  132. int expResult = Endpoint.EndpointType.OUTBOUND;
  133. instance.setEndpointType(expResult);
  134. int result = instance.getEndpointType();
  135. assertEquals(expResult, result);
  136. System.out.println("Successfully tested setEndpointType and getEndpointType");
  137. }
  138. /**
  139. * Test of setServiceEndpoint and getServiceEndpoint method, of class
  140. * com.sun.jbi.hl7bc.EndpointImpl.
  141. */
  142. public void testSetGetServiceEndpoint() {
  143. System.out.println("Testing setServiceEndpoint and getServiceEndpoint");
  144. Mock serviceEndpointMock = mock(ServiceEndpoint.class);
  145. ServiceEndpoint expResult = (ServiceEndpoint)serviceEndpointMock.proxy();
  146. instance.setServiceEndpoint(expResult);
  147. ServiceEndpoint result = instance.getServiceEndpoint();
  148. assertEquals(expResult, result);
  149. System.out.println("Successfully tested setServiceEndpoint and getServiceEndpoint");
  150. }
  151. /**
  152. * Test of setServiceDescription and getServiceDescription method, of class
  153. * com.sun.jbi.hl7bc.EndpointImpl.
  154. */
  155. public void testSetServiceDescription() {
  156. System.out.println("Testing setServiceDescription and getServiceDescription");
  157. Mock domMock = mock(Document.class);
  158. Document expResult = (Document)domMock.proxy();
  159. instance.setServiceDescription(expResult);
  160. Document result = instance.getServiceDescription();
  161. assertEquals(expResult, result);
  162. System.out.println("Successfully tested setServiceDescription and getServiceDescription");
  163. }
  164. /**
  165. * Test of setHL7Address and getHL7Address method, of class com.sun.jbi.hl7bc.EndpointImpl.
  166. */
  167. public void testSetGetHL7Address() {
  168. System.out.println("Testing setHL7Address and getHL7Address");
  169. String locationURL = "hl7://localhost:4040";
  170. HL7Address expResult = new HL7Address();
  171. expResult.setHL7ServerLocationURL(locationURL);
  172. instance.setHL7Address(expResult);
  173. HL7Address result = instance.getHL7Address();
  174. assertEquals(expResult.getHL7ServerLocationURL(), result.getHL7ServerLocationURL());
  175. System.out.println("Successfully tested setHL7Address and getHL7Address");
  176. }
  177. /**
  178. * Test of setHL7ProtocolProperties and getHL7ProtocolProperties method, of class
  179. * com.sun.jbi.hl7bc.EndpointImpl.
  180. */
  181. public void testSetGetHL7ProtocolProperties() {
  182. System.out.println("Testing setHL7ProtocolProperties and getHL7ProtocolProperties");
  183. HL7ProtocolProperties expResult = new HL7ProtocolProperties();
  184. expResult.setStartBlockChar(new Byte("24"));
  185. instance.setHL7ProtocolProperties(expResult);
  186. HL7ProtocolProperties result = instance.getHL7ProtocolProperties();
  187. assertTrue(result instanceof HL7ProtocolProperties);
  188. assertEquals(expResult.getStartBlockChar().byteValue(), result.getStartBlockChar().byteValue());
  189. System.out.println("Successfully tested HL7ProtocolProperties and getHL7ProtocolProperties");
  190. }
  191. /**
  192. * Test of setHL7Binding and getHL7Binding method, of class com.sun.jbi.hl7bc.EndpointImpl.
  193. */
  194. public void testSetGetHL7Binding() {
  195. System.out.println("Testing setHL7Binding and getHL7Binding");
  196. instance.setHL7Binding(new HL7Binding());
  197. HL7Binding result = instance.getHL7Binding();
  198. assertTrue(result instanceof HL7Binding);
  199. System.out.println("Successfully tested setHL7Binding and getHL7Binding");
  200. }
  201. /**
  202. * Test of setHL7Operations and getHL7Operations method, of class
  203. * com.sun.jbi.hl7bc.EndpointImpl.
  204. */
  205. public void testSetGetHL7Operations() {
  206. System.out.println("Testing setHL7Operations and getHL7Operations");
  207. Map val = new HashMap();
  208. val.put(new QName("http://some-url", "operation1"), new HL7Operation());
  209. val.put(new QName("http://some-url", "operation2"), new HL7Operation());
  210. instance.setHL7Operations(val);
  211. Map result = instance.getHL7Operations();
  212. assertTrue(result instanceof Map);
  213. assertEquals(val, result);
  214. System.out.println("Successfully tested setHL7Operations and getHL7Operations");
  215. }
  216. /**
  217. * Test of setHL7OperationInput and getHL7OperationInput method, of class
  218. * com.sun.jbi.hl7bc.EndpointImpl.
  219. */
  220. public void testSetGetHL7OperationInput() {
  221. System.out.println("Testing setHL7OperationInput and getHL7OperationInput");
  222. HL7Operation hl7OP = new HL7Operation();
  223. HL7Input hl7In = new HL7Input();
  224. instance.setHL7OperationInput(hl7OP, hl7In);
  225. HL7Input result = (HL7Input) instance.getHL7OperationInput(hl7OP);
  226. assertEquals(hl7In, result);
  227. System.out.println("Successfully tested setHL7OperationInput and getHL7OperationInput");
  228. }
  229. /**
  230. * Test of setHL7OperationOutput and getHL7OperationOutput method, of class
  231. * com.sun.jbi.hl7bc.EndpointImpl.
  232. */
  233. public void testSetGetHL7OperationOutput() {
  234. System.out.println("Testing setHL7OperationOutput and getHL7OperationOutput");
  235. HL7Operation hl7OP = new HL7Operation();
  236. HL7Output hl7Out = new HL7Output();
  237. instance.setHL7OperationOutput(hl7OP, hl7Out);
  238. HL7Output result = (HL7Output) instance.getHL7OperationOutput(hl7OP);
  239. assertEquals(hl7Out, result);
  240. System.out.println("Successfully tested setHL7OperationOutput and getHL7OperationOutput");
  241. }
  242. /**
  243. * Test of setOperationMsgExchangePattern and getOperationMsgExchangePattern method, of class
  244. * com.sun.jbi.hl7bc.EndpointImpl.
  245. */
  246. public void testSetGetOperationMsgExchangePattern() {
  247. System.out.println("Testing setOperationMsgExchangePattern and getOperationMsgExchangePattern");
  248. Map val = new HashMap();
  249. val.put(QName.valueOf("operation1"), "inonly");
  250. val.put(QName.valueOf("operation2"), "inout");
  251. instance.setOperationMsgExchangePattern(val);
  252. Map result = instance.getOperationMsgExchangePattern();
  253. assertTrue(result instanceof Map);
  254. assertEquals(val, result);
  255. System.out.println("Successfully tested setOperationMsgExchangePattern and getOperationMsgExchangePattern");
  256. }
  257. /**
  258. * Test of setXsdsList and getXsdsList method, of class com.sun.jbi.hl7bc.EndpointImpl.
  259. */
  260. public void testSetGetXsdsList() {
  261. System.out.println("Testing setXsdsList and getXsdsList");
  262. List xsds = new ArrayList();
  263. xsds.add("ACK.xsd");
  264. xsds.add("ADT_A49.xsd");
  265. instance.setXsdsList(xsds);
  266. List result = instance.getXsdsList();
  267. assertEquals(xsds, result);
  268. System.out.println("Successfully tested setXsdsList and getXsdsList");
  269. }
  270. }