You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2013/09/19 11:51:34 UTC

svn commit: r879061 - in /websites/staging/tomee/trunk: cgi-bin/ content/ content/examples-trunk/rest-example/ content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/

Author: buildbot
Date: Thu Sep 19 09:51:34 2013
New Revision: 879061

Log:
Staging update by buildbot for tomee

Modified:
    websites/staging/tomee/trunk/cgi-bin/   (props changed)
    websites/staging/tomee/trunk/content/   (props changed)
    websites/staging/tomee/trunk/content/examples-trunk/rest-example/pom.xml
    websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java
    websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java

Propchange: websites/staging/tomee/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Sep 19 09:51:34 2013
@@ -1 +1 @@
-1524621
+1524674

Propchange: websites/staging/tomee/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Sep 19 09:51:34 2013
@@ -1 +1 @@
-1524621
+1524674

Modified: websites/staging/tomee/trunk/content/examples-trunk/rest-example/pom.xml
==============================================================================
Binary files - no diff available.

Modified: websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java
==============================================================================
--- websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java (original)
+++ websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java Thu Sep 19 09:51:34 2013
@@ -44,8 +44,8 @@ public class UserDaoTest {
 
     @Test
     public void create() throws NamingException {
-        UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
-        User user = dao.create("foo", "dummy", "foo@bar.org");
+        final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
+        final User user = dao.create("foo", "dummy", "foo@bar.org");
         assertNotNull(dao.find(user.getId()));
     }
 }

Modified: websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java
==============================================================================
--- websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java (original)
+++ websites/staging/tomee/trunk/content/examples-trunk/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java Thu Sep 19 09:51:34 2013
@@ -16,10 +16,9 @@
  */
 package org.superbiz.rest.dao;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
-import org.apache.openejb.loader.JarLocation;
 import org.apache.tomee.embedded.EmbeddedTomEEContainer;
+import org.apache.ziplock.Archive;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -37,16 +36,16 @@ import java.util.Properties;
 
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
+import static org.apache.openejb.loader.JarLocation.jarLocation;
 
 public class UserServiceTest {
 
     private static EJBContainer container;
-    private static File webApp;
 
     @BeforeClass
     public static void start() throws IOException {
-        webApp = createWebApp();
-        Properties p = new Properties();
+        final File webApp = Archive.archive().copyTo("WEB-INF/classes", jarLocation(UserDAO.class)).asDir();
+        final Properties p = new Properties();
         p.setProperty(EJBContainer.APP_NAME, "rest-example");
         p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature
         p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
@@ -59,41 +58,23 @@ public class UserServiceTest {
         if (container != null) {
             container.close();
         }
-        if (webApp != null) {
-            try {
-                FileUtils.forceDelete(webApp);
-            } catch (IOException e) {
-                FileUtils.deleteQuietly(webApp);
-            }
-        }
     }
 
     @Test
     public void create() throws NamingException {
-        UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
-        User user = dao.create("foo", "dummy", "foo@dummy.org");
+        final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
+        final User user = dao.create("foo", "dummy", "foo@dummy.org");
         assertNotNull(dao.find(user.getId()));
 
-        String uri = "http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/rest-example";
-        UserServiceClientAPI client = JAXRSClientFactory.create(uri, UserServiceClientAPI.class);
-        User retrievedUser = client.show(user.getId());
+        final String uri = "http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/rest-example";
+        final UserServiceClientAPI client = JAXRSClientFactory.create(uri, UserServiceClientAPI.class);
+        final User retrievedUser = client.show(user.getId());
         assertNotNull(retrievedUser);
         assertEquals("foo", retrievedUser.getFullname());
         assertEquals("dummy", retrievedUser.getPassword());
         assertEquals("foo@dummy.org", retrievedUser.getEmail());
     }
 
-    private static File createWebApp() throws IOException {
-        File file = new File(System.getProperty("java.io.tmpdir") + "/tomee-" + Math.random());
-        if (!file.mkdirs() && !file.exists()) {
-            throw new RuntimeException("can't create " + file.getAbsolutePath());
-        }
-
-        FileUtils.copyDirectory(JarLocation.jarLocation(UserDAO.class), new File(file, "WEB-INF/classes"));
-
-        return file;
-    }
-
     /**
      * a simple copy of the unique method i want to use from my service.
      * It allows to use cxf proxy to call remotely our rest service.