You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/05/25 07:03:44 UTC
[2/5] tomee git commit: getting rid of the version in arquilian
openejb embedded adapter
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
new file mode 100644
index 0000000..56393be
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/SWClassLoader.java
@@ -0,0 +1,289 @@
+/*
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.util.Enumerator;
+import org.apache.openejb.util.URLs;
+import org.apache.openejb.util.reflection.Reflections;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Node;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.FileAsset;
+import org.jboss.shrinkwrap.api.asset.UrlAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.base.filter.IncludeRegExpPaths;
+
+import javax.enterprise.inject.spi.Extension;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Arrays.asList;
+import static org.apache.openejb.arquillian.openejb.reflection.Assets.get;
+
+public class SWClassLoader extends ClassLoader implements Closeable {
+ static {
+ try {
+ final Field handler = URL.class.getDeclaredField("handlers");
+ handler.setAccessible(true);
+ ((Hashtable<String, URLStreamHandler>) handler.get(null)).put("archive", new ArchiveStreamHandler());
+ } catch (final Exception e) {
+ // no-op
+ }
+ }
+
+ private final Collection<Archive<?>> archives;
+ private final Collection<Closeable> closeables = new ArrayList<Closeable>();
+
+ public SWClassLoader(final ClassLoader parent, final Archive<?>... ar) {
+ super(parent);
+ this.archives = new ArrayList<>(asList(ar));
+ for (final Archive<?> a : ar) {
+ ArchiveStreamHandler.set(a, closeables);
+
+ final boolean isWar = WebArchive.class.isInstance(a);
+ if (isWar) { // add dependencies - file and url - to be able to lookup them. ArchiveAssets are provided normally
+ for (final Node n : a.getContent(new IncludeRegExpPaths("/WEB-INF/lib/.*\\.jar")).values()) {
+ final Asset asset = n.getAsset();
+ if (FileAsset.class.isInstance(asset)) {
+ final JavaArchive jar = ShrinkWrap.createFromZipFile(JavaArchive.class, get(File.class, "file", asset));
+ this.archives.add(jar);
+ ArchiveStreamHandler.set(jar, closeables);
+ } else if (UrlAsset.class.isInstance(asset)) {
+ final JavaArchive jar = ShrinkWrap.createFromZipFile(JavaArchive.class, URLs.toFile(get(URL.class, "url", asset)));
+ this.archives.add(jar);
+ ArchiveStreamHandler.set(jar, closeables);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public Enumeration<URL> getResources(final String name) throws IOException {
+ if (name == null) {
+ return super.getResources(null);
+ }
+ final boolean cdiExtensions = name.startsWith("META-INF/services/" + Extension.class.getName());
+ if (cdiExtensions || !name.contains("META-INF/services/javax")) {
+ final List<Archive<?>> node = findNodes(name);
+ if (!node.isEmpty()) {
+ final List<URL> urls = new ArrayList<>();
+ for (final Archive<?> i : node) {
+ urls.add(new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler()));
+ }
+ if (cdiExtensions && !"true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.arquillian.cdi.extension.skip-externals", "false"))) {
+ addContainerExtensions(name, urls);
+ }
+ return enumerator(urls);
+ }
+ if (cdiExtensions) {
+ if ("true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.arquillian.cdi.extension.skip-externals", "false"))) {
+ return enumerator(Collections.<URL>emptyList());
+ }
+ return enumerator(addContainerExtensions(name, new ArrayList<URL>(2)));
+ }
+ }
+ return super.getResources(name);
+ }
+
+ private List<URL> addContainerExtensions(final String name, final List<URL> urls) throws IOException {
+ final Collection<URL> containerExtensions = Collections.list(getParent().getResources(name));
+ for (final URL u : containerExtensions) {
+ final String externalForm = u.toExternalForm();
+ if (externalForm.contains("myfaces-impl") || externalForm.contains("bval-jsr")) {
+ urls.add(u);
+ }
+ }
+ return urls;
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(final String name) throws IOException {
+ final List<Archive<?>> node = findNodes(name);
+ if (!node.isEmpty()) {
+ final List<URL> urls = new ArrayList<>();
+ for (final Archive<?> i : node) {
+ urls.add(new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler()));
+ }
+ return enumerator(urls);
+ }
+ return super.findResources(name);
+ }
+
+ public URL getWebResource(final String name) {
+ for (final Archive<?> a : archives) {
+ if (!WebArchive.class.isInstance(a)) {
+ continue;
+ }
+ final Node node = a.get(name);
+ if (node != null) {
+ try {
+ return new URL(null, "archive:" + a.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler());
+ } catch (final MalformedURLException e) {
+ // no-op
+ }
+ }
+ }
+ return null;
+ }
+
+ public LinkedList<Archive<?>> findNodes(final String name) {
+ final LinkedList<Archive<?>> items = new LinkedList<>();
+ for (final Archive<?> a : archives) {
+ final boolean isWar = WebArchive.class.isInstance(a);
+ final Node node = a.get(ArchivePaths.create((isWar ? "/WEB-INF/classes/" : "") + name));
+ if (node != null) {
+ items.add(a);
+ }
+ }
+ return items;
+ }
+
+ private static Enumeration<URL> enumerator(final List<URL> urls) {
+ return new Enumerator(urls);
+ }
+
+ @Override
+ protected URL findResource(final String name) {
+ final LinkedList<Archive<?>> node = findNodes(name);
+ if (!node.isEmpty()) {
+ final Archive<?> i = node.getLast();
+ try {
+ return new URL(null, "archive:" + i.getName() + (!name.startsWith("/") ? "/" : "") + name, new ArchiveStreamHandler());
+ } catch (final MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return super.findResource(name);
+ }
+
+ private static class ArchiveStreamHandler extends URLStreamHandler {
+ public static final Map<String, Archive<?>> archives = new HashMap<String, Archive<?>>();
+ public static final Map<String, Collection<Closeable>> closeables = new HashMap<String, Collection<Closeable>>();
+
+ public static void set(final Archive<?> ar, final Collection<Closeable> c) {
+ final String archiveName = ar.getName();
+ archives.put(archiveName, ar);
+ closeables.put(archiveName, c);
+ }
+
+ public static void reset(final String archiveName) {
+ archives.remove(archiveName);
+ closeables.remove(archiveName);
+ }
+
+ @Override
+ protected URLConnection openConnection(final URL u) throws IOException {
+ final String arName = key(u);
+
+ final Archive<?> archive = archives.get(arName);
+ final String path = path(archive.getName(), WebArchive.class.isInstance(archive) ? "/WEB-INF/classes/" : "", u);
+ Node node = archive.get(path);
+ if (node == null) {
+ node = archive.get(path(archive.getName(), "", u)); // web resources
+ if (node == null) {
+ throw new IOException(u.toExternalForm() + " not found");
+ }
+ }
+
+ final Asset asset = node.getAsset();
+ if (UrlAsset.class.isInstance(asset)) {
+ return URL.class.cast(Reflections.get(asset, "url")).openConnection();
+ } else if (FileAsset.class.isInstance(asset)) {
+ return File.class.cast(Reflections.get(asset, "file")).toURI().toURL().openConnection();
+ } else if (ClassLoaderAsset.class.isInstance(asset)) {
+ return ClassLoader.class.cast(Reflections.get(asset, "classLoader")).getResource(String.class.cast(Reflections.get(asset, "resourceName"))).openConnection();
+ }
+
+ return new URLConnection(u) {
+ @Override
+ public void connect() throws IOException {
+ // no-op
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ final InputStream input = asset.openStream();
+ final Collection<Closeable> c = closeables.get(arName);
+ c.add(input);
+ return input;
+ }
+ };
+ }
+
+ private static String path(final String arName, final String prefix, final URL url) {
+ final String p = url.getPath();
+ final String out = p.substring(arName.length(), p.length());
+ if (prefix.endsWith("/") && out.startsWith("/")) {
+ return prefix + out.substring(1);
+ }
+ return prefix + out;
+ }
+
+ private static String key(final URL url) {
+ final String p = url.getPath();
+ if (p == null) {
+ return null;
+ }
+ final int endIndex = p.indexOf('/');
+ if (endIndex >= 0) {
+ return p.substring(0, endIndex);
+ }
+ return p;
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ for (final Archive<?> a : archives) {
+ ArchiveStreamHandler.reset(a.getName());
+ }
+ for (final Closeable cl : closeables) {
+ try {
+ cl.close();
+ } catch (final IOException e) {
+ // no-op
+ }
+ }
+ }
+
+ // to let frameworks using TCCL use the archive directly
+ public Collection<Archive<?>> getArchives() {
+ return archives;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/cucumber/ArchiveResourceIteratorFactory.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/cucumber/ArchiveResourceIteratorFactory.java b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/cucumber/ArchiveResourceIteratorFactory.java
new file mode 100644
index 0000000..8a9d74f
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/cucumber/ArchiveResourceIteratorFactory.java
@@ -0,0 +1,106 @@
+/*
+ * 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.arquillian.openejb.cucumber;
+
+import cucumber.runtime.io.Resource;
+import cucumber.runtime.io.ResourceIteratorFactory;
+import org.apache.openejb.arquillian.openejb.SWClassLoader;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.Filter;
+import org.jboss.shrinkwrap.api.Node;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+public class ArchiveResourceIteratorFactory implements ResourceIteratorFactory {
+ @Override
+ public boolean isFactoryFor(final URL url) {
+ return url.getProtocol().startsWith("archive");
+ }
+
+ @Override
+ public Iterator<Resource> createIterator(final URL url, final String path, final String suffix) {
+ return findResources(path, suffix).iterator();
+ }
+
+ private Collection<Resource> findResources(final String path, final String suffix) {
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ final Collection<Resource> resources = new ArrayList<Resource>();
+ if (SWClassLoader.class.isInstance(loader)) {
+ final Collection<Archive<?>> archives = SWClassLoader.class.cast(loader).getArchives();
+ final ClassLoader parent = loader.getParent();
+ for (final Archive<?> archive : archives) {
+ final Map<ArchivePath, Node> content = archive.getContent(new Filter<ArchivePath>() {
+ @Override
+ public boolean include(final ArchivePath object) {
+ final String currentPath = classloaderPath(object);
+
+ return !(parent != null && parent.getResource(currentPath) != null)
+ && currentPath.startsWith('/' + path) && currentPath.endsWith(suffix);
+
+ }
+ });
+
+ for (final Map.Entry<ArchivePath, Node> entry : content.entrySet()) {
+ resources.add(new SWResource(entry.getKey(), entry.getValue()));
+ }
+ }
+ }
+ return resources;
+ }
+
+ private static class SWResource implements Resource {
+ private final Node node;
+ private final String path;
+
+ public SWResource(final ArchivePath key, final Node value) {
+ path = classloaderPath(key);
+ node = value;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public String getAbsolutePath() {
+ return path;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return node.getAsset().openStream();
+ }
+
+ @Override
+ public String getClassName(final String extension) {
+ return path.replace('/', '.') + extension;
+ }
+ }
+
+ private static String classloaderPath(final ArchivePath key) {
+ return key.get().replace("/WEB-INF/classes/", "");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
new file mode 100644
index 0000000..5fd0b04
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/http/WebArchiveResourceProvider.java
@@ -0,0 +1,33 @@
+/*
+ * 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.arquillian.openejb.http;
+
+import org.apache.openejb.arquillian.openejb.SWClassLoader;
+import org.apache.openejb.server.httpd.EmbeddedServletContext;
+
+import java.net.URL;
+
+public class WebArchiveResourceProvider implements EmbeddedServletContext.ResourceProvider {
+ @Override
+ public URL getResource(final String s) {
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (SWClassLoader.class.isInstance(tccl)) {
+ return SWClassLoader.class.cast(tccl).getWebResource(s);
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/reflection/Assets.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/reflection/Assets.java b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/reflection/Assets.java
new file mode 100644
index 0000000..9755b7e
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/reflection/Assets.java
@@ -0,0 +1,45 @@
+/**
+ * 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.arquillian.openejb.reflection;
+
+import org.jboss.shrinkwrap.api.asset.Asset;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+
+public final class Assets {
+ public static final ClassLoader EMPTY_LOADER = new ClassLoader() {
+ @Override
+ public URL getResource(final String name) {
+ return null;
+ }
+ };
+
+ public static <T> T get(final Class<T> fileClass, final String attr, final Asset asset) {
+ try {
+ final Field field = asset.getClass().getDeclaredField(attr);
+ field.setAccessible(true);
+ return fileClass.cast(field.get(asset));
+ } catch (final Exception e) {
+ return null;
+ }
+ }
+
+ private Assets() {
+ // no-op
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/server/ServiceManagers.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/server/ServiceManagers.java b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/server/ServiceManagers.java
new file mode 100644
index 0000000..0a33c0b
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/java/org/apache/openejb/arquillian/openejb/server/ServiceManagers.java
@@ -0,0 +1,53 @@
+/*
+ * 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.arquillian.openejb.server;
+
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.server.ServerService;
+import org.apache.openejb.server.SimpleServiceManager;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
+
+// only here to not trigger any loadClass of openejb-server if not mandatory
+public final class ServiceManagers {
+ private ServiceManagers() {
+ // no-op
+ }
+
+ public static ProtocolMetaData protocolMetaData(final AppInfo info) {
+ final org.apache.openejb.server.ServiceManager smp = org.apache.openejb.server.ServiceManager.get();
+ if (smp != null && SimpleServiceManager.class.isInstance(smp)) {
+ final ServerService[] daemons = SimpleServiceManager.class.cast(smp).getDaemons();
+ for (final ServerService ss : daemons) {
+ if ("httpejbd".equals(ss.getName())) {
+ if (info.webApps.size() == 1) {
+ return newHttpProtocolMetaData(ss, info.webApps.iterator().next().contextRoot);
+ }
+ return newHttpProtocolMetaData(ss, info.appId);
+ }
+ }
+ }
+ return null;
+ }
+
+ private static ProtocolMetaData newHttpProtocolMetaData(final ServerService ss, final String contextRoot) {
+ final HTTPContext httpContext = new HTTPContext(ss.getIP(), ss.getPort());
+ httpContext.add(new Servlet("ArquillianServletRunner", contextRoot));
+ return new ProtocolMetaData().addContext(httpContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/cucumber.runtime.io.ResourceIteratorFactory
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/cucumber.runtime.io.ResourceIteratorFactory b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/cucumber.runtime.io.ResourceIteratorFactory
new file mode 100644
index 0000000..bde7650
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/cucumber.runtime.io.ResourceIteratorFactory
@@ -0,0 +1 @@
+org.apache.openejb.arquillian.openejb.cucumber.ArchiveResourceIteratorFactory
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
new file mode 100644
index 0000000..a145f42
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.apache.openejb.server.httpd.EmbeddedServletContext$ResourceProvider
@@ -0,0 +1 @@
+org.apache.openejb.arquillian.openejb.http.WebArchiveResourceProvider
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
new file mode 100644
index 0000000..82b08e2
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.apache.openejb.arquillian.openejb.OpenEJBExtension
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/AdapterArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/AdapterArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/AdapterArquillianStandaloneTest.java
new file mode 100644
index 0000000..bcf65a2
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/AdapterArquillianStandaloneTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class AdapterArquillianStandaloneTest {
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, AdapterArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void checkItIsStarted() {
+ assertTrue(SystemInstance.isInitialized());
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianAndMockitoTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianAndMockitoTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianAndMockitoTest.java
new file mode 100644
index 0000000..6779425
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianAndMockitoTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ArquillianAndMockitoTest {
+ @Inject
+ private AFooBean bean;
+
+ @Mock @Produces
+ private static AnInterface mock;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, ArquillianAndMockitoTest.class.getSimpleName().concat(".jar"))
+ .addClasses(AnInterface.class, AFooBean.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void mockWorks() {
+ assertNotNull(bean);
+ assertNotNull(mock);
+ assertNotNull(bean.get());
+ }
+
+ public static interface AnInterface {}
+
+ public static class AFooBean {
+ @Inject
+ private AnInterface mock;
+
+ public AnInterface get() {
+ return mock;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianResourceURLTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianResourceURLTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianResourceURLTest.java
new file mode 100644
index 0000000..0738de6
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianResourceURLTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ArquillianResourceURLTest {
+ @Deployment(testable = false)
+ public static WebArchive archive() {
+ return ShrinkWrap.create(WebArchive.class, ArquillianResourceURLTest.class.getSimpleName().concat(".war"))
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @ArquillianResource
+ private URL url;
+
+ @Test
+ public void mockWorks() {
+ assertNotNull(url);
+ assertEquals(4204, url.getPort());
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/BindingInJavaGlobalTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/BindingInJavaGlobalTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/BindingInJavaGlobalTest.java
new file mode 100644
index 0000000..0d4bd42
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/BindingInJavaGlobalTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class BindingInJavaGlobalTest {
+ @Deployment
+ public static JavaArchive jar() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .addAsManifestResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<persistence version=\"2.0\"\n" +
+ " xmlns=\"http://java.sun.com/xml/ns/persistence\"\n" +
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence\n" +
+ " http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n" +
+ " <persistence-unit name=\"person\">\n" +
+ " <jta-data-source>java:global/db</jta-data-source>\n" +
+ " </persistence-unit>\n" +
+ "</persistence>"), "persistence.xml");
+ }
+
+ @PersistenceUnit
+ private EntityManagerFactory emf;
+
+ @Test
+ public void checkSimpleBiding() throws NamingException {
+ final BasicDataSource ds = (BasicDataSource) new InitialContext().lookup("java:global/db");
+ assertEquals("jdbc:hsqldb:mem:global", ds.getUrl());
+ }
+
+ @Test
+ public void checkJpaBiding() throws NamingException {
+ assertEquals("jdbc:hsqldb:mem:global", ((BasicDataSource) ((ReloadableEntityManagerFactory) emf).info().getJtaDataSource()).getUrl());
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/CDIArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/CDIArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/CDIArquillianStandaloneTest.java
new file mode 100644
index 0000000..c230731
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/CDIArquillianStandaloneTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.loader.SystemInstance;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class CDIArquillianStandaloneTest {
+ @Inject
+ private ABean bean;
+
+ @Inject
+ private AnEJB ejbFromCdiAnnotation;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, CDIArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addClasses(ABean.class, AnEJB.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void checkItIsStarted() {
+ assertTrue(SystemInstance.isInitialized());
+ }
+
+ @Test
+ public void checkInjections() {
+ assertNotNull(bean);
+ assertNotNull(ejbFromCdiAnnotation);
+ }
+
+ public static class ABean {
+ }
+
+ @Singleton
+ public static class AnEJB {
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EJBArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EJBArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EJBArquillianStandaloneTest.java
new file mode 100644
index 0000000..a01edf5
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EJBArquillianStandaloneTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.arquillian.openejb;
+
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class EJBArquillianStandaloneTest {
+ @EJB
+ private AnEJB ejbFromEjbAnnotation;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, EJBArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addClass(AnEJB.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("ejb-jar.xml"));
+ }
+
+ @Test
+ public void checkInjections() {
+ assertNotNull(ejbFromEjbAnnotation);
+ }
+
+ @Singleton
+ public static class AnEJB {}
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EnvEntriesArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EnvEntriesArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EnvEntriesArquillianStandaloneTest.java
new file mode 100644
index 0000000..4a63df4
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/EnvEntriesArquillianStandaloneTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.arquillian.openejb;
+
+import javax.annotation.Resource;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class EnvEntriesArquillianStandaloneTest {
+ @Resource(name = "foo")
+ private String foo;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, EnvEntriesArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("ejb-jar.xml"))
+ .addAsManifestResource(new StringAsset("foo=bar"), ArchivePaths.create("env-entries.properties"));
+ }
+
+ @Test
+ public void check() {
+ assertEquals("bar", foo);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ExceptionInjectionTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ExceptionInjectionTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ExceptionInjectionTest.java
new file mode 100644
index 0000000..bab0830
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ExceptionInjectionTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.webbeans.exception.WebBeansDeploymentException;
+import org.jboss.arquillian.container.spi.client.container.DeploymentException;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.ShouldThrowException;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ExceptionInjectionTest {
+ @ArquillianResource
+ private DeploymentException de;
+
+ @ArquillianResource
+ private WebBeansDeploymentException owbException;
+
+ @ArquillianResource
+ private DeploymentException oejbException;
+
+ @Deployment(testable = false)
+ @ShouldThrowException(javax.enterprise.inject.spi.DeploymentException.class)
+ public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addAsWebInfResource(new StringAsset(Descriptors.create(BeansDescriptor.class)
+ .getOrCreateInterceptors()
+ .clazz("i.dont.exist.so.i.ll.make.the.deployment.fail")
+ .up()
+ .exportAsString()), ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void checkSomeExceptionsOfTheHierarchy() {
+ assertNotNull(de);
+ assertNotNull(owbException);
+ assertNotNull(oejbException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/JPAArquillianAdapterTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/JPAArquillianAdapterTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/JPAArquillianAdapterTest.java
new file mode 100644
index 0000000..5c68f73
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/JPAArquillianAdapterTest.java
@@ -0,0 +1,107 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.PersistenceContext;
+
+@RunWith(Arquillian.class)
+public class JPAArquillianAdapterTest {
+ @Inject
+ private Persister persister;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, JPAArquillianAdapterTest.class.getSimpleName().concat(".jar"))
+ .addClasses(Person.class, Persister.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addAsManifestResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<persistence version=\"2.0\"\n" +
+ " xmlns=\"http://java.sun.com/xml/ns/persistence\"\n" +
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence\n" +
+ " http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n" +
+ " <persistence-unit name=\"person\">\n" +
+ " <jta-data-source>My DataSource</jta-data-source>\n" +
+ " <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>\n" +
+ " <class>" + Person.class.getName() + "</class>\n" +
+ " <properties>\n" +
+ " <property name=\"openjpa.jdbc.SynchronizeMappings\" value=\"buildSchema(ForeignKeys=true)\"/>\n" +
+ " </properties>\n" +
+ " </persistence-unit>\n" +
+ "</persistence>"), ArchivePaths.create("persistence.xml"));
+ }
+
+ @Test
+ public void persist() {
+ persister.persist(new Person("foo"));
+ }
+
+ @Entity
+ public static class Person {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+
+ public Person() {
+ // no-op
+ }
+
+ public Person(final String name) {
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @Singleton
+ public static class Persister {
+ @PersistenceContext
+ private EntityManager em;
+
+ public void persist(final Person person) {
+ em.persist(person);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/LifecycleTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/LifecycleTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/LifecycleTest.java
new file mode 100644
index 0000000..bc5fe94
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/LifecycleTest.java
@@ -0,0 +1,112 @@
+/**
+ * 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.arquillian.openejb;
+
+import java.net.URLClassLoader;
+import javax.inject.Inject;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(Arquillian.class)
+public class LifecycleTest {
+ private static int beforeClassNb = 0;
+ private static int beforeNb = 0;
+ private static int afterClassNb = 0;
+ private static int afterNb = 0;
+
+ @Inject
+ private Foo foo;
+
+ @Deployment
+ public static JavaArchive jar() {
+ return ShrinkWrap.create(JavaArchive.class, LifecycleTest.class.getSimpleName() + ".jar")
+ .addClass(Foo.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ if (beforeClassNb > 0) {
+ fail();
+ }
+ checkCl();
+ beforeClassNb++;
+ }
+
+ @Before
+ public void before() {
+ if (beforeNb > 0) {
+ fail();
+ }
+ checkCl();
+ assertNotNull(foo); // injections should be available
+ beforeNb++;
+ }
+
+ @After
+ public void after() {
+ if (afterNb > 0) {
+ fail();
+ }
+ checkCl();
+ assertNotNull(foo); // injections should be available
+ afterNb++;
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ if (afterClassNb > 0) {
+ fail();
+ }
+ checkCl();
+ afterClassNb++;
+
+ assertEquals(1, beforeClassNb);
+ assertEquals(1, beforeNb);
+ assertEquals(1, afterNb);
+ assertEquals(1, afterClassNb);
+ }
+
+ @Test
+ public void justToRunOthers() {
+ // no-op
+ }
+
+ private static void checkCl() { // openejb classloader, not the app one
+ assertThat(Thread.currentThread().getContextClassLoader().getParent(), instanceOf(URLClassLoader.class));
+ }
+
+ public static class Foo {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/MethodParameterEnrichmentTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/MethodParameterEnrichmentTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/MethodParameterEnrichmentTest.java
new file mode 100644
index 0000000..53ea363
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/MethodParameterEnrichmentTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class MethodParameterEnrichmentTest {
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, MethodParameterEnrichmentTest.class.getSimpleName().concat(".jar"))
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addClass(Foo.class);
+ }
+
+ @Test
+ public void check(final Foo foo) {
+ assertNotNull(foo);
+ }
+
+ public static class Foo {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/RequestScopeArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/RequestScopeArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/RequestScopeArquillianStandaloneTest.java
new file mode 100644
index 0000000..7a7d9f3
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/RequestScopeArquillianStandaloneTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class RequestScopeArquillianStandaloneTest {
+ @Inject
+ private ARequestBean bean;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, RequestScopeArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addClass(ARequestBean.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void checkInjections() {
+ assertNotNull(bean);
+ assertTrue(bean.getClass().getName().contains("$Owb"));
+ }
+
+ @RequestScoped
+ public static class ARequestBean {}
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ResourceArquillianStandaloneTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ResourceArquillianStandaloneTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ResourceArquillianStandaloneTest.java
new file mode 100644
index 0000000..c9134fd
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/ResourceArquillianStandaloneTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.arquillian.openejb;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ResourceArquillianStandaloneTest {
+ @Resource(name = "db1")
+ private DataSource db1;
+
+ @Deployment
+ public static JavaArchive archive() {
+ return ShrinkWrap.create(JavaArchive.class, ResourceArquillianStandaloneTest.class.getSimpleName().concat(".jar"))
+ .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ @Test
+ public void checkInjections() {
+ assertNotNull(db1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWLibTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWLibTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWLibTest.java
new file mode 100644
index 0000000..84c11ee
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWLibTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class SWLibTest {
+ @Inject
+ private Lib lib;
+
+ @Deployment
+ public static WebArchive jar() {
+ return ShrinkWrap.create(WebArchive.class, SWLibTest.class.getSimpleName() + ".war")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addAsLibraries(ShrinkWrap.create(JavaArchive.class).addClass(Lib.class));
+ }
+
+ @Test
+ public void checkClassWasFound() {
+ assertNotNull(lib);
+ }
+
+ public static class Lib {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWMavenWarTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWMavenWarTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWMavenWarTest.java
new file mode 100644
index 0000000..ce31a91
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SWMavenWarTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.util.classloader.URLClassLoaderFirst;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class SWMavenWarTest {
+ @Deployment
+ public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class, "sw-mvn.war")
+ .addClass(SWBean.class)
+ .addAsLibraries(Maven.resolver()
+ .loadPomFromFile("src/test/resources/a-pom.xml")
+ .importRuntimeAndTestDependencies().resolve().withTransitivity().asFile());
+ }
+
+ @Singleton
+ @TransactionManagement(TransactionManagementType.BEAN)
+ public static class SWBean {
+ public Class<?> gherkin() throws Exception {
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ assertThat(loader.getParent(), instanceOf(URLClassLoaderFirst.class));
+ return loader.loadClass("gherkin.Main");
+ }
+ }
+
+ @EJB
+ private SWBean bean;
+
+ @Test
+ public void check() throws Exception {
+ bean.gherkin(); // if fail will throw an exception
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
new file mode 100644
index 0000000..fbae01e
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/SessionDestroyTest.java
@@ -0,0 +1,113 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.loader.IO;
+import org.jboss.arquillian.container.test.api.Deployer;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class SessionDestroyTest {
+ @Deployment(name = "app", managed = false, testable = false)
+ public static Archive<?> app() {
+ return ShrinkWrap.create(WebArchive.class).addClasses(SessionTestManager.class, SessionListener.class);
+ }
+
+ @ArquillianResource
+ private Deployer deployer;
+
+ private static String id;
+
+ @Test
+ @InSequence(1)
+ public void deploy() {
+ reset();
+ deployer.deploy("app");
+ }
+
+ @Test
+ @InSequence(2)
+ @OperateOnDeployment("app")
+ public void doTest(@ArquillianResource final URL url) throws IOException {
+ id = IO.slurp(new URL(url.toExternalForm() + "create"));
+ assertNotNull(SessionListener.created);
+ assertEquals(id, SessionListener.created);
+ }
+
+ @Test
+ @InSequence(3)
+ public void undeployAndAsserts() {
+ deployer.undeploy("app");
+ assertNotNull(SessionListener.destroyed);
+ assertEquals(id, SessionListener.destroyed);
+ reset();
+ }
+
+ private void reset() {
+ SessionListener.destroyed = null;
+ SessionListener.created = null;
+ id = null;
+ }
+
+ @WebServlet("/create")
+ public static class SessionTestManager extends HttpServlet {
+ @Override
+ protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ req.getSession().setAttribute("test", "ok");
+ resp.getWriter().write(req.getSession().getId());
+ }
+ }
+
+ @WebListener
+ public static class SessionListener implements HttpSessionListener {
+ private static String created;
+ private static String destroyed;
+
+ @Override
+ public void sessionCreated(final HttpSessionEvent httpSessionEvent) {
+ created = httpSessionEvent.getSession().getId();
+ }
+
+ @Override
+ public void sessionDestroyed(final HttpSessionEvent httpSessionEvent) {
+ destroyed = httpSessionEvent.getSession().getId();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/StartDeploymentTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/StartDeploymentTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/StartDeploymentTest.java
new file mode 100644
index 0000000..bbe489b
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/StartDeploymentTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.arquillian.openejb.archive.SimpleArchive;
+import org.apache.openejb.arquillian.openejb.archive.SimpleArchive2;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+import org.jboss.arquillian.junit.Arquillian;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class StartDeploymentTest {
+ @Inject
+ private SimpleArchive2.AnotherSingleton bean;
+
+ @Test
+ public void deployment() {
+ final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+ assertNotNull(containerSystem.getAppContext("start"));
+ assertNotNull(containerSystem.getAppContext("start2"));
+ }
+
+ @Test
+ public void checkItIsStarted() {
+ assertTrue(SimpleArchive.ASingleton.ok);
+ }
+
+ @Test
+ public void injections() {
+ assertNotNull(bean);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/TransactionTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/TransactionTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/TransactionTest.java
new file mode 100644
index 0000000..080ac8f
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/TransactionTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.apache.openejb.OpenEJB;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
+import org.jboss.arquillian.transaction.api.annotation.Transactional;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+@RunWith(Arquillian.class)
+public class TransactionTest {
+ @Deployment
+ public static WebArchive archive() {
+ return ShrinkWrap.create(WebArchive.class, TransactionTest.class.getSimpleName().concat(".war"))
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("ejb-jar.xml"));
+ }
+
+ @Test
+ @Transactional(TransactionMode.DISABLED)
+ public void noTx() throws SystemException {
+ assertNull(currentTransaction());
+ }
+
+ @Test
+ public void noTxAtAll() throws SystemException {
+ assertNull(currentTransaction());
+ }
+
+ @Test
+ @Transactional(TransactionMode.COMMIT)
+ public void txCommit() throws SystemException {
+ assertNotNull(currentTransaction());
+ }
+
+ @Test
+ @Transactional(TransactionMode.ROLLBACK)
+ public void txRollback() throws SystemException {
+ assertNotNull(currentTransaction());
+ }
+
+ private Transaction currentTransaction() throws SystemException {
+ return OpenEJB.getTransactionManager().getTransaction();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5b16879e/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/VirtualResourceTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/VirtualResourceTest.java b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/VirtualResourceTest.java
new file mode 100644
index 0000000..f992454
--- /dev/null
+++ b/arquillian/arquillian-openejb-embedded/src/test/java/org/apache/openejb/arquillian/openejb/VirtualResourceTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.arquillian.openejb;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class VirtualResourceTest {
+ @Deployment
+ public static WebArchive jar() {
+ return ShrinkWrap.create(WebArchive.class, SWLibTest.class.getSimpleName() + ".war")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addAsServiceProvider(Extension.class, MyExtension.class)
+ .addClass(MyExtension.class);
+ }
+
+ @Test
+ public void check() {
+ assertTrue(MyExtension.called);
+ }
+
+ public static class MyExtension implements Extension {
+ public static boolean called = false;
+
+ public void observe(@Observes final BeforeBeanDiscovery bbd) {
+ called = true;
+ }
+ }
+}