PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ws/serviceref/ServiceRefTestCase.java

http://github.com/jbossas/jboss-as
Java | 124 lines | 76 code | 14 blank | 34 comment | 1 complexity | a8ed70475a9c430d70458f88879d24bb MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2011, Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.test.integration.ws.serviceref;
  23. import java.util.Hashtable;
  24. import java.util.Properties;
  25. import javax.naming.Context;
  26. import javax.naming.InitialContext;
  27. import org.jboss.arquillian.container.test.api.Deployment;
  28. import org.jboss.arquillian.container.test.api.RunAsClient;
  29. import org.jboss.arquillian.junit.Arquillian;
  30. import org.jboss.as.network.NetworkUtils;
  31. import org.jboss.as.test.shared.FileUtils;
  32. import org.jboss.as.test.shared.PropertiesValueResolver;
  33. import org.jboss.shrinkwrap.api.ShrinkWrap;
  34. import org.jboss.shrinkwrap.api.asset.StringAsset;
  35. import org.jboss.shrinkwrap.api.spec.JavaArchive;
  36. import org.junit.Assert;
  37. import org.junit.BeforeClass;
  38. import org.junit.Test;
  39. import org.junit.runner.RunWith;
  40. /**
  41. * Serviceref through ejb3 deployment descriptor.
  42. *
  43. * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
  44. */
  45. @RunWith(Arquillian.class)
  46. @RunAsClient
  47. public class ServiceRefTestCase {
  48. private static StatelessRemote remote1;
  49. private static StatelessRemote remote2;
  50. @BeforeClass
  51. public static void beforeClass() throws Exception {
  52. final Hashtable<String, String> props = new Hashtable<String, String>();
  53. props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
  54. final Context context = new InitialContext(props);
  55. remote1 = (StatelessRemote) context.lookup("ejb:/ws-serviceref-example//StatelessBean!"
  56. + StatelessRemote.class.getName());
  57. remote2 = (StatelessRemote) context.lookup("ejb:/ws-serviceref-example//StatelessBean2!"
  58. + StatelessRemote.class.getName());
  59. }
  60. @Deployment
  61. public static JavaArchive deployment() {
  62. String wsdl = FileUtils.readFile(ServiceRefTestCase.class, "TestService.wsdl");
  63. final Properties properties = new Properties();
  64. properties.putAll(System.getProperties());
  65. if(properties.containsKey("node0")) {
  66. properties.put("node0", NetworkUtils.formatPossibleIpv6Address((String)properties.get("node0")));
  67. }
  68. return ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar")
  69. .addClasses(EJB3Bean.class, EndpointInterface.class, EndpointService.class, StatelessBean.class, StatelessRemote.class)
  70. .addAsManifestResource(ServiceRefTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml")
  71. .addAsManifestResource(ServiceRefTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml")
  72. .addAsManifestResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl");
  73. }
  74. @Test
  75. public void testEJBRelay1() throws Exception {
  76. // test StatelessBean
  77. final String result1 = remote1.echo1("Relay1");
  78. Assert.assertEquals("First EJB:Relay1", result1);
  79. // test StatelessBean2
  80. final String result2 = remote2.echo1("Relay1");
  81. Assert.assertEquals("Second EJB:Relay1", result2);
  82. }
  83. @Test
  84. public void testEJBRelay2() throws Exception {
  85. // test StatelessBean
  86. final String result1 = remote1.echo2("Relay2");
  87. Assert.assertEquals("First EJB:Relay2", result1);
  88. // test StatelessBean2
  89. final String result2 = remote2.echo2("Relay2");
  90. Assert.assertEquals("Second EJB:Relay2", result2);
  91. }
  92. @Test
  93. public void testEJBRelay3() throws Exception {
  94. // test StatelessBean
  95. final String result1 = remote1.echo3("Relay3");
  96. Assert.assertEquals("First EJB:Relay3", result1);
  97. // test StatelessBean2
  98. final String result2 = remote2.echo3("Relay3");
  99. Assert.assertEquals("Second EJB:Relay3", result2);
  100. }
  101. @Test
  102. public void testEJBRelay4() throws Exception {
  103. // test StatelessBean
  104. final String result1 = remote1.echo4("Relay4");
  105. Assert.assertEquals("First EJB:Relay4", result1);
  106. // test StatelessBean2
  107. final String result2 = remote2.echo4("Relay4");
  108. Assert.assertEquals("Second EJB:Relay4", result2);
  109. }
  110. }