PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/testing/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/JavaFirstTestCase.java

https://github.com/vorburger/tuscany-sca-2.x
Java | 123 lines | 78 code | 17 blank | 28 comment | 0 complexity | a1f3b64b49316e4b8b4f044e79759a02 MD5 | raw file
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.apache.tuscany.sca.binding.ws.launcher.base;
  20. import static org.junit.Assert.assertEquals;
  21. import static org.junit.Assert.assertTrue;
  22. import static org.junit.Assert.fail;
  23. import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
  24. import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
  25. import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
  26. import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
  27. import org.apache.tuscany.sca.node.Contribution;
  28. import org.apache.tuscany.sca.node.Node;
  29. import org.apache.tuscany.sca.node.NodeFactory;
  30. import org.junit.After;
  31. import org.junit.Before;
  32. import org.junit.Ignore;
  33. import org.junit.Test;
  34. public class JavaFirstTestCase {
  35. private Node node;
  36. private HelloWorldServiceLauncher externalService;
  37. private HelloWorldClientLauncher externalClient;
  38. @Before
  39. public void setUp() throws Exception {
  40. // Start the external service
  41. externalService = new HelloWorldServiceLauncher();
  42. externalService.createService();
  43. // Start the SCA contribution
  44. node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-java-first/target/itest-ws-contribution-java-first.jar"));
  45. node.start();
  46. // start the external client
  47. try {
  48. externalClient = new HelloWorldClientLauncher();
  49. externalClient.createClient();
  50. } catch (Exception ex) {
  51. ex.printStackTrace();
  52. throw ex;
  53. }
  54. }
  55. /*
  56. @Test
  57. public void testWait() throws Exception {
  58. System.out.println("Press a key");
  59. System.in.read();
  60. }
  61. */
  62. @Test
  63. public void testGetGreetings() throws Exception {
  64. assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
  65. }
  66. @Test
  67. public void testGetGreetingsException() throws Exception {
  68. try {
  69. externalClient.getGreetingsException("Fred");
  70. } catch (Exception ex) {
  71. return;
  72. }
  73. fail("expecting exception");
  74. }
  75. @Test
  76. public void testGetGreetingsComplex() throws Exception {
  77. Foo f = new Foo();
  78. Bar b1 = new Bar();
  79. b1.setS("petra");
  80. b1.setX(1);
  81. b1.setY(new Integer(2));
  82. b1.setB(Boolean.TRUE);
  83. Bar b2 = new Bar();
  84. b2.setS("beate");
  85. b2.setX(3);
  86. b2.setY(new Integer(4));
  87. b2.setB(Boolean.FALSE);
  88. f.getBars().add(b1);
  89. f.getBars().add(b2);
  90. Foo f2 = externalClient.getGreetingsComplex(f);
  91. assertEquals("petra", f2.getBars().get(0).getS());
  92. assertEquals(1, f2.getBars().get(0).getX());
  93. assertEquals(2, f2.getBars().get(0).getY().intValue());
  94. assertTrue(f2.getBars().get(0).isB());
  95. assertEquals("simon", f2.getBars().get(2).getS());
  96. assertEquals(7, f2.getBars().get(2).getX());
  97. assertEquals(8, f2.getBars().get(2).getY().intValue());
  98. assertTrue(f2.getBars().get(2).isB().booleanValue());
  99. }
  100. @After
  101. public void tearDown() throws Exception {
  102. node.stop();
  103. externalClient.destroyClient();
  104. externalService.destoryService();
  105. }
  106. }