Author: rmannibucau
Date: Tue Jan 1 16:05:31 2013
New Revision: 1427453
URL: http://svn.apache.org/viewvc?rev=1427453&view=rev
Log:
avoiding npe + some more jaxrs test
Added:
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSRoutingTest.java
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSWithInterfaceTest.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java?rev=1427453&r1=1427452&r2=1427453&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceUnitInfoImpl.java
Tue Jan 1 16:05:31 2013
@@ -327,6 +327,10 @@ public class PersistenceUnitInfoImpl imp
// not the shouldSkip() method from UrlClassLoaderFirst since we skip more
here
// we just need JPA stuff so all the tricks we have for the server part
are useless
public static boolean isServerClass(final String name) {
+ if (name == null) {
+ return false;
+ }
+
for (String prefix : URLClassLoaderFirst.FORCED_SKIP) {
if (name.startsWith(prefix)) {
return true;
@@ -369,6 +373,7 @@ public class PersistenceUnitInfoImpl imp
if (apache.startsWith("juli.")) return true;
if (apache.startsWith("webbeans.")) return true;
if (apache.startsWith("cxf.")) return true;
+ if (apache.startsWith("activemq.")) return true;
if (apache.startsWith("commons.")) {
final String commons =
apache.substring("commons.".length());
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java?rev=1427453&r1=1427452&r2=1427453&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/classloader/URLClassLoaderFirst.java
Tue Jan 1 16:05:31 2013
@@ -169,6 +169,10 @@ public class URLClassLoaderFirst extends
// /!\ please check
org.apache.openejb.persistence.PersistenceUnitInfoImpl.isServerClass() too
// when updating this method
public static boolean shouldSkip(final String name) {
+ if (name == null) { // can happen with rest servlet definition or
errors
+ return false;
+ }
+
for (String prefix : FORCED_SKIP) {
if (name.startsWith(prefix)) {
return true;
Added:
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSRoutingTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSRoutingTest.java?rev=1427453&view=auto
==============================================================================
---
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSRoutingTest.java
(added)
+++
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSRoutingTest.java
Tue Jan 1 16:05:31 2013
@@ -0,0 +1,82 @@
+/*
+ * 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.apache.openejb.server.cxf.rs;
+
+import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.apache.openejb.server.cxf.rs.beans.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices("jax-rs")
+@RunWith(ApplicationComposer.class)
+public class JAXRSRoutingTest {
+ public static final String BASE_URL = "http://localhost:4204/foo/";
+
+ @Module
+ @Classes({ RestWithInjections.class, SimpleEJB.class,
MyExpertRestClass.class, MyFirstRestClass.class })
+ public WebApp war() {
+ return new WebApp()
+ .contextRoot("foo")
+ .addServlet("REST Application", Application.class.getName())
+ .addInitParam("REST Application", "javax.ws.rs.Application",
NoClassAtPathApplication.class.getName());
+ }
+
+ @Test
+ public void routing() {
+ assertEquals("routing",
WebClient.create(BASE_URL).path("routing").get(String.class));
+ }
+
+ public static class NoClassAtPathApplication extends Application {
+ private final Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public NoClassAtPathApplication() {
+ classes.add(FirstService.class);
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+ }
+
+ public static class FirstService {
+ @Path("routing")
+ @GET
+ public String routing() {
+ return "routing";
+ }
+ }
+}
Added:
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSWithInterfaceTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSWithInterfaceTest.java?rev=1427453&view=auto
==============================================================================
---
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSWithInterfaceTest.java
(added)
+++
openejb/trunk/openejb/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/JAXRSWithInterfaceTest.java
Tue Jan 1 16:05:31 2013
@@ -0,0 +1,83 @@
+/*
+ * 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.apache.openejb.server.cxf.rs;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.apache.openejb.server.cxf.rs.beans.MyExpertRestClass;
+import org.apache.openejb.server.cxf.rs.beans.MyFirstRestClass;
+import org.apache.openejb.server.cxf.rs.beans.RestWithInjections;
+import org.apache.openejb.server.cxf.rs.beans.SimpleEJB;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices("jax-rs")
+@RunWith(ApplicationComposer.class)
+public class JAXRSWithInterfaceTest {
+ public static final String BASE_URL = "http://localhost:4204/foo/";
+
+ @Module
+ @Classes({ RestWithInjections.class, SimpleEJB.class,
MyExpertRestClass.class, MyFirstRestClass.class })
+ public WebApp war() {
+ return new WebApp()
+ .contextRoot("foo")
+ .addServlet("REST Application", Application.class.getName())
+ .addInitParam("REST Application", "javax.ws.rs.Application",
InterfaceApp.class.getName());
+ }
+
+ @Test
+ public void itf() {
+ assertEquals("itf",
WebClient.create(BASE_URL).path("itf").get(String.class));
+ }
+
+ public static class InterfaceApp extends Application {
+ private final Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public InterfaceApp() {
+ classes.add(Impl.class);
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+ }
+
+ public static interface Itf {
+ @Path("itf")
+ @GET
+ String itf();
+ }
+
+ public static class Impl implements Itf {
+ public String itf() {
+ return "itf";
+ }
+ }
+}
Modified:
openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java?rev=1427453&r1=1427452&r2=1427453&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
(original)
+++
openejb/trunk/openejb/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
Tue Jan 1 16:05:31 2013
@@ -71,7 +71,7 @@ public abstract class RESTService implem
private List<DeployedService> services = new ArrayList<DeployedService>();
private String virtualHost;
private boolean enabled = true;
- private String wildcard =
SystemInstance.get().getProperty("openejb.rest.wildcard", ".*");
+ private String wildcard =
SystemInstance.get().getProperty("openejb.rest.wildcard", ".*"); // embedded =
regex, tomee = servlet
public void afterApplicationCreated(final AppInfo appInfo, final
WebAppInfo webApp) {
final WebContext webContext =
containerSystem.getWebContext(webApp.moduleId);