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 2012/10/30 16:59:33 UTC

svn commit: r836605 - in /websites/staging/openejb/trunk: cgi-bin/ content/ content/examples-trunk/ content/examples-trunk/rest-applicationcomposer-mockito/ content/examples-trunk/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/res...

Author: buildbot
Date: Tue Oct 30 15:59:32 2012
New Revision: 836605

Log:
Staging update by buildbot for openejb

Added:
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/pom.xml   (with props)
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
Modified:
    websites/staging/openejb/trunk/cgi-bin/   (props changed)
    websites/staging/openejb/trunk/content/   (props changed)
    websites/staging/openejb/trunk/content/examples-trunk/pom.xml
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/pom.xml
    websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java

Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Oct 30 15:59:32 2012
@@ -1 +1 @@
-1403682
+1403755

Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Oct 30 15:59:32 2012
@@ -1 +1 @@
-1403682
+1403755

Modified: websites/staging/openejb/trunk/content/examples-trunk/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/pom.xml (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/pom.xml Tue Oct 30 15:59:32 2012
@@ -17,7 +17,7 @@
     limitations under the License.
 -->
 <!--test 2-->
-<!-- $Rev: 1403653 $ $Date: 2012-10-30 10:18:16 +0000 (Tue, 30 Oct 2012) $ -->
+<!-- $Rev: 1403755 $ $Date: 2012-10-30 15:59:23 +0000 (Tue, 30 Oct 2012) $ -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
@@ -99,6 +99,7 @@
     <module>reload-persistence-unit-properties</module>
     <module>resources-declared-in-webapp</module>
     <module>rest-applicationcomposer-mockito</module>
+    <module>rest-applicationcomposer</module>
     <module>rest-on-ejb</module>
     <module>rest-example</module>
     <module>rest-example-with-application</module>

Modified: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/pom.xml
==============================================================================
Binary files - no diff available.

Modified: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java Tue Oct 30 15:59:32 2012
@@ -19,15 +19,14 @@ package org.superbiz.composed.rest;
 import org.apache.openejb.OpenEjbContainer;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.MockInjector;
 import org.apache.openejb.junit.Module;
 import org.apache.openejb.loader.IO;
-import org.junit.Before;
+import org.apache.openejb.mockito.MockitoInjector;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
 
-import javax.enterprise.inject.Produces;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Properties;
@@ -38,13 +37,7 @@ import static org.mockito.Mockito.when;
 @RunWith(ApplicationComposer.class)
 public class GreetingServiceTest {
     @Mock
-    @Produces
-    public static Messager messager;
-
-    @Before
-    public void injectMocks() {
-        MockitoAnnotations.initMocks(this);
-    }
+    private Messager messager;
 
     @Configuration
     public Properties configuration() {
@@ -53,6 +46,11 @@ public class GreetingServiceTest {
         }};
     }
 
+    @MockInjector
+    public Class<?> mockitoInjector() {
+        return MockitoInjector.class;
+    }
+
     @Module
     public Class<?>[] app() {
         return new Class<?>[] { GreetingService.class, Messager.class };

Added: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/pom.xml
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Added: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java Tue Oct 30 15:59:32 2012
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/greeting")
+public class GreetingService {
+    @GET
+    public String message() {
+        throw new IllegalArgumentException("this exception is handled by an exception mapper");
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java Tue Oct 30 15:59:32 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class IllegalArgumentExceptionMapper implements ExceptionMapper<IllegalArgumentException> {
+    @Override
+    public Response toResponse(final IllegalArgumentException throwable) {
+        return Response.ok(throwable.getMessage()).build();
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java Tue Oct 30 15:59:32 2012
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.oejb3.EjbDeployment;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.Module;
+import org.apache.openejb.loader.IO;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+    @Configuration
+    public Properties configuration() {
+        return new Properties() {{
+            setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, Boolean.TRUE.toString());
+        }};
+    }
+
+    @Module
+    public EjbModule app() {
+        // in embedded mode only ejb are deployed
+        final SingletonBean bean = (SingletonBean) new SingletonBean(GreetingService.class).localBean();
+        bean.setRestService(true);
+
+        // now create an ejbjar and an openejb-jar to hold the provider config
+
+        final EjbJar ejbJar = new EjbJar();
+        ejbJar.addEnterpriseBean(bean);
+
+        final OpenejbJar openejbJar = new OpenejbJar();
+        openejbJar.addEjbDeployment(new EjbDeployment(ejbJar.getEnterpriseBeans()[0]));
+
+        final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
+        properties.setProperty("cxf.jaxrs.providers", IllegalArgumentExceptionMapper.class.getName());
+
+        // link all and return this module
+
+        final EjbModule module = new EjbModule(ejbJar);
+        module.setOpenejbJar(openejbJar);
+
+        return module;
+    }
+
+    @Test
+    public void checkProviderIsUsed() throws IOException {
+        final String message = IO.slurp(new URL("http://localhost:4204/GreetingServiceTest/greeting/"));
+        assertEquals("this exception is handled by an exception mapper", message);
+    }
+}