Ejemplo n.º 1
0
public class CalculatorTest {

  private static EJBContainer container;

  // Random port to avoid test conflicts
  private static final int port =
      Integer.parseInt(
          System.getProperty(
              "httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));

  @BeforeClass
  public static void setUp() throws Exception {
    final Properties properties = new Properties();
    properties.setProperty("openejb.embedded.remotable", "true");

    // Just for this test we change the default port from 4204 to avoid conflicts
    properties.setProperty("httpejbd.port", "" + port);

    container = EJBContainer.createEJBContainer(properties);
  }

  @Before
  public void inject() throws NamingException {
    if (container != null) {
      container.getContext().bind("inject", this);
    }
  }

  @AfterClass
  public static void close() {
    if (container != null) {
      container.close();
    }
  }

  @Test
  public void wsdlExists() throws Exception {
    final URL url =
        new URL(
            "http://localhost:" + port + "/simple-webservice-without-interface/Calculator?wsdl");
    assertTrue(IOUtils.readLines(url.openStream()).size() > 0);
    assertTrue(IOUtils.readLines(url.openStream()).toString().contains("CalculatorWsService"));
  }
}
Ejemplo n.º 2
0
 @BeforeClass
 public static void beforeClass() {
   port = NetworkUtil.getNextAvailablePort();
 }