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

https://github.com/vorburger/tuscany-sca-2.x · Java · 112 lines · 75 code · 16 blank · 21 comment · 0 complexity · 4a9bafb77bffc488d8980a5cd9954c04 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 CallbackPromotionTestCase {
  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-callback-promotion/target/itest-ws-contribution-callback-promotion.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. @Test
  56. @Ignore
  57. public void testWait() throws Exception {
  58. System.out.println("Press a key");
  59. System.in.read();
  60. }
  61. @Test
  62. public void testGetGreetings() throws Exception {
  63. assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
  64. }
  65. @Test
  66. public void testGetGreetingsComplex() throws Exception {
  67. Foo f = new Foo();
  68. Bar b1 = new Bar();
  69. b1.setS("petra");
  70. b1.setX(1);
  71. b1.setY(new Integer(2));
  72. b1.setB(Boolean.TRUE);
  73. Bar b2 = new Bar();
  74. b2.setS("beate");
  75. b2.setX(3);
  76. b2.setY(new Integer(4));
  77. b2.setB(Boolean.FALSE);
  78. f.getBars().add(b1);
  79. f.getBars().add(b2);
  80. Foo f2 = externalClient.getGreetingsComplex(f);
  81. assertEquals("petra", f2.getBars().get(0).getS());
  82. assertEquals(1, f2.getBars().get(0).getX());
  83. assertEquals(2, f2.getBars().get(0).getY().intValue());
  84. assertTrue(f2.getBars().get(0).isB());
  85. assertEquals("simon", f2.getBars().get(2).getS());
  86. assertEquals(7, f2.getBars().get(2).getX());
  87. assertEquals(8, f2.getBars().get(2).getY().intValue());
  88. assertTrue(f2.getBars().get(2).isB().booleanValue());
  89. }
  90. @After
  91. public void tearDown() throws Exception {
  92. node.stop();
  93. externalClient.destroyClient();
  94. externalService.destoryService();
  95. }
  96. }