tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1183659 - in /openejb/trunk/openejb/assembly/tomee/tomee-embedded/src: main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java
Date Sat, 15 Oct 2011 15:01:48 GMT
Author: rmannibucau
Date: Sat Oct 15 15:01:47 2011
New Revision: 1183659

URL: http://svn.apache.org/viewvc?rev=1183659&view=rev
Log:
fixing a bit TomEEEJBContainerTest testing deployment of a simple static application

Modified:
    openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
    openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java

Modified: openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java?rev=1183659&r1=1183658&r2=1183659&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
(original)
+++ openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
Sat Oct 15 15:01:47 2011
@@ -16,6 +16,7 @@ import java.util.Map;
  * @author rmannibucau
  */
 public class EmbeddedTomEEContainer extends EJBContainer {
+    public static final String TOMEE_EJBCONTAINER_HTTP_PORT = "tomee.ejbcontainer.http.port";
     private static EmbeddedTomEEContainer tomEEContainer;
 
     private Container container = new Container();
@@ -56,6 +57,11 @@ public class EmbeddedTomEEContainer exte
             final Object modules = properties.get(EJBContainer.MODULES);
 
             tomEEContainer = new EmbeddedTomEEContainer(appId);
+            Configuration configuration = new Configuration();
+            if (properties.containsKey(TOMEE_EJBCONTAINER_HTTP_PORT)) {
+                configuration.setHttpPort((Integer) properties.get(TOMEE_EJBCONTAINER_HTTP_PORT));
+            }
+            tomEEContainer.container.setup(configuration);
             try {
                 tomEEContainer.container.start();
 

Modified: openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java?rev=1183659&r1=1183658&r2=1183659&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java
(original)
+++ openejb/trunk/openejb/assembly/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/EmbeddedTomEEContainerTest.java
Sat Oct 15 15:01:47 2011
@@ -5,18 +5,14 @@ import org.apache.openejb.util.IOUtils;
 import org.junit.Test;
 
 import javax.ejb.embeddable.EJBContainer;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.naming.Context;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Properties;
-import java.util.jar.JarFile;
 
+import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
 
 /**
  * @author rmannibucau
@@ -30,30 +26,41 @@ public class EmbeddedTomEEContainerTest 
     }
 
     @Test public void containerTest() throws Exception {
+        File war = createWar();
         Properties p = new Properties();
         p.setProperty(EJBContainer.APP_NAME, "test");
         p.setProperty(EJBContainer.PROVIDER, EmbeddedTomEEContainer.class.getName());
-        p.setProperty(EJBContainer.MODULES, createWar());
+        p.setProperty(EJBContainer.MODULES, war.getAbsolutePath());
         try {
             EJBContainer container = EJBContainer.createEJBContainer(p);
             assertNotNull(container);
             assertNotNull(container.getContext());
+            URL url = new URL("http://127.0.0.1:8080/" + war.getName() + "/index.html");
+            assertEquals("true", IOUtils.readProperties(url).getProperty("ok"));
             container.close();
         } finally {
-            new File(p.getProperty(EJBContainer.MODULES)).delete();
+            if (!war.delete()) {
+                war.deleteOnExit();
+            }
         }
     }
 
-    private String createWar() throws IOException {
+    private File createWar() throws IOException {
         File file = new File(System.getProperty("java.io.tmpdir") + "/tomee-" + Math.random());
-        file.mkdirs();
+        if (!file.mkdirs() && !file.exists()) {
+            throw new RuntimeException("can't create " + file.getAbsolutePath());
+        }
+
         write("ok=true", new File(file, "index.html"));
-        write("<beans />", new File(file, "META-INF/beans.xml"));
-        return file.getAbsolutePath();
+        write("<beans />", new File(file, "WEB-INF/classes/META-INF/beans.xml"));
+        return file;
     }
 
     private static void write(String content, File file) throws IOException {
-        file.getParentFile().mkdirs();
+        if (!file.getParentFile().mkdirs() && !file.getParentFile().exists()) {
+            throw new RuntimeException("can't create " + file.getParent());
+        }
+
         FileWriter index = new FileWriter(file);
         index.write(content);
         index.close();



Mime
View raw message