You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/02/12 19:49:06 UTC
svn commit: r1243295 - in /openejb/trunk/openejb/arquillian-tomee: ./
arquillian-tomcat-openejb-remote/ arquillian-tomee-webapp-remote/
arquillian-tomee-webapp-remote/src/main/java/org/apache/openejb/
arquillian-tomee-webapp-remote/src/main/java/org/ap...
Author: dblevins
Date: Sun Feb 12 18:49:06 2012
New Revision: 1243295
URL: http://svn.apache.org/viewvc?rev=1243295&view=rev
Log:
Repackaged code in arquillian-tomee-webapp-remote
Added arquillian-tomee-webapp-remote to the build
TOMEE-127, TOME-136
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/
- copied from r1243279, openejb/trunk/openejb/arquillian-tomee/arquillian-tomcat-openejb-remote/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEContainer.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEEJBEnricherArchiveAppender.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEExtension.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEObserver.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEERemoteExtension.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/ZipExtractor.java
Removed:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomcat-openejb-remote/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/openejb/
Modified:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/pom.xml
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/test/java/org/apache/openejb/arquillian/session/SessionScopeTest.java
openejb/trunk/openejb/arquillian-tomee/pom.xml
Modified: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/pom.xml?rev=1243295&r1=1243279&r2=1243295&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/pom.xml (original)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/pom.xml Sun Feb 12 18:49:06 2012
@@ -25,7 +25,7 @@
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.apache.openejb</groupId>
- <artifactId>arquillian-tomee-remote</artifactId>
+ <artifactId>arquillian-tomee-webapp-remote</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEContainer.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEContainer.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEContainer.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,312 @@
+/**
+ * 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.tomee.arquillian.webapp;
+
+import org.apache.openejb.arquillian.common.FileUtils;
+import org.apache.openejb.arquillian.common.MavenCache;
+import org.apache.openejb.arquillian.common.TomEEContainer;
+import org.apache.openejb.config.RemoteServer;
+import org.apache.openejb.loader.ProvisioningUtil;
+import org.apache.tomee.installer.Installer;
+import org.apache.tomee.installer.Paths;
+import org.jboss.arquillian.container.spi.client.container.LifecycleException;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/*
+ * TODO: delete old embedded adapter, move the tests and set those up
+ */
+public class RemoteTomEEContainer extends TomEEContainer {
+ private static File DOWNLOADED = null;
+
+ private RemoteServer container;
+ private boolean needsStart = false;
+
+ public void start() throws LifecycleException {
+ if (System.getProperty("tomee.http.port") != null) {
+ configuration.setHttpPort(Integer.parseInt(System.getProperty("tomee.http.port")));
+ }
+ if (System.getProperty("tomee.shutdown.port") != null) {
+ configuration.setStopPort(Integer.parseInt(System.getProperty("tomee.shutdown.port")));
+ }
+
+ // see if TomEE is already running by checking the http port
+ try {
+ connect(configuration.getHttpPort());
+ } catch (Exception e) {
+ needsStart = true;
+ }
+
+ if (!needsStart) {
+ return;
+ }
+
+ try {
+ final File workingDirectory = new File(configuration.getDir());
+ workingDirectory.mkdirs();
+ if (workingDirectory.exists()) {
+ FileUtils.deleteOnExit(workingDirectory);
+ }
+
+ File openejbHome;
+ if (DOWNLOADED != null && DOWNLOADED.getAbsolutePath().startsWith(workingDirectory.getAbsolutePath())) {
+ openejbHome = findOpenEJBHome(workingDirectory);
+ } else if (configuration.getTomcatVersion() == null || configuration.getTomcatVersion().length() == 0) {
+ downloadTomEE(workingDirectory);
+ openejbHome = findOpenEJBHome(workingDirectory);
+ } else {
+ downloadTomcat(workingDirectory, configuration.getTomcatVersion());
+ openejbHome = findOpenEJBHome(workingDirectory);
+ File webappsOpenEJB = new File(openejbHome, "webapps/openejb");
+ webappsOpenEJB.mkdirs();
+ downloadOpenEJBWebapp(webappsOpenEJB);
+
+ System.setProperty("catalina.home", openejbHome.getAbsolutePath());
+ System.setProperty("catalina.base", openejbHome.getAbsolutePath());
+ System.setProperty("openejb.deploymentId.format", "{appId}/{ejbJarId}/{ejbName}");
+ Paths paths = new Paths(new File(openejbHome.getAbsolutePath(), "/webapps/openejb"));
+ Installer installer = new Installer(paths, true);
+ installer.installAll();
+ }
+ DOWNLOADED = workingDirectory;
+
+ if (openejbHome == null || (!openejbHome.exists())) {
+ throw new LifecycleException("Error finding OPENEJB_HOME");
+ }
+
+ FileUtils.deleteOnExit(openejbHome);
+ Map<String, String> replacements = new HashMap<String, String>();
+ replacements.put("8080", String.valueOf(configuration.getHttpPort()));
+ replacements.put("8005", String.valueOf(configuration.getStopPort()));
+ replace(replacements, new File(openejbHome, "conf/server.xml"));
+
+ final URL logging = Thread.currentThread().getContextClassLoader().getResource("default.remote.logging.properties");
+ if (logging != null) {
+ write(logging, new File(openejbHome, "conf/logging.properties"));
+ }
+
+ System.setProperty("tomee.http.port", String.valueOf(configuration.getHttpPort()));
+ System.setProperty("tomee.shutdown.port", String.valueOf(configuration.getStopPort()));
+ System.setProperty("java.naming.provider.url", "http://localhost:" + configuration.getHttpPort() + "/tomee/ejb");
+ System.setProperty("connect.tries", "90");
+ System.setProperty("server.http.port", String.valueOf(configuration.getHttpPort()));
+ System.setProperty("server.shutdown.port", String.valueOf(configuration.getStopPort()));
+ System.setProperty("java.opts", "-Xmx512m -Xms256m -XX:PermSize=64m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=64m -Dtomee.http.port=" + configuration.getHttpPort());
+ System.setProperty("openejb.home", openejbHome.getAbsolutePath());
+
+ if (false) {
+ Map<Object, Object> map = new TreeMap(System.getProperties());
+ for (Map.Entry<Object, Object> entry : map.entrySet()) {
+ System.out.printf("%s = %s\n", entry.getKey(), entry.getValue());
+ }
+ }
+
+ container = new RemoteServer();
+ container.start();
+ } catch (Exception e) {
+ throw new LifecycleException("Unable to start remote container", e);
+ }
+ }
+
+ private static void write(URL resource, File file) throws IOException {
+ if (file.exists()) {
+ FileUtils.delete(file);
+ }
+ InputStream is = resource.openStream();
+ OutputStream out = new FileOutputStream(file);
+ byte buf[] = new byte[1024];
+ int len;
+ while ((len = is.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ is.close();
+ }
+
+ private File findOpenEJBHome(File directory) {
+ File conf = new File(directory, "conf");
+ File webapps = new File(directory, "webapps");
+
+ if (conf.exists() && conf.isDirectory() && webapps.exists() && webapps.isDirectory()) {
+ return directory;
+ }
+
+ for (File file : directory.listFiles()) {
+ if (".".equals(file.getName()) || "..".equals(file.getName())) continue;
+
+ File found = findOpenEJBHome(file);
+ if (found != null) {
+ return found;
+ }
+ }
+
+ return null;
+ }
+
+ protected void downloadTomEE(File catalinaDirectory) throws LifecycleException {
+ String artifactName;
+ if (configuration.isPlusContainer()) {
+ artifactName = "org.apache.openejb:apache-tomee:" + configuration.getOpenejbVersion() + ":zip:plus";
+ } else {
+ artifactName = "org.apache.openejb:apache-tomee:" + configuration.getOpenejbVersion() + ":zip:webprofile";
+ }
+
+ File zipFile = downloadFile(artifactName, null);
+ ZipExtractor.unzip(zipFile, catalinaDirectory);
+ }
+
+ protected File downloadFile(String artifactName, String altUrl) {
+ final String cache = System.getProperty(ProvisioningUtil.OPENEJB_DEPLOYER_CACHE_FOLDER);
+ System.setProperty(ProvisioningUtil.OPENEJB_DEPLOYER_CACHE_FOLDER, "target");
+ try {
+ final File artifact = new MavenCache().getArtifact(artifactName, altUrl);
+ if (artifact == null) throw new NullPointerException(String.format("No such artifact: %s", artifactName));
+ return artifact;
+ } finally {
+ if (cache == null) {
+ System.getProperties().remove(ProvisioningUtil.OPENEJB_DEPLOYER_CACHE_FOLDER);
+ } else {
+ System.setProperty(ProvisioningUtil.OPENEJB_DEPLOYER_CACHE_FOLDER, cache);
+ }
+ }
+ }
+
+ protected void downloadOpenEJBWebapp(File targetDirectory) throws LifecycleException {
+ String artifactName;
+ if (configuration.isPlusContainer()) {
+ artifactName = "org.apache.openejb:tomee-plus-webapp:" + configuration.getOpenejbVersion() + ":war";
+ } else {
+ artifactName = "org.apache.openejb:tomee-webapp:" + configuration.getOpenejbVersion() + ":war";
+ }
+
+ File zipFile = downloadFile(artifactName, null);
+ ZipExtractor.unzip(zipFile, targetDirectory);
+ }
+
+ protected void downloadTomcat(File catalinaDirectory, String tomcatVersion) throws LifecycleException {
+ String source = null;
+
+ if (tomcatVersion.startsWith("7.")) {
+ source = "http://archive.apache.org/dist/tomcat/tomcat-7/v" + tomcatVersion + "/bin/apache-tomcat-" + tomcatVersion + ".zip";
+ }
+
+ if (tomcatVersion.startsWith("6.")) {
+ source = "http://archive.apache.org/dist/tomcat/tomcat-6/v" + tomcatVersion + "/bin/apache-tomcat-" + tomcatVersion + ".zip";
+ }
+
+ if (tomcatVersion.startsWith("5.5")) {
+ source = "http://archive.apache.org/dist/tomcat/tomcat-5/v" + tomcatVersion + "/bin/apache-tomcat-" + tomcatVersion + ".zip";
+ }
+
+ if (source == null) {
+ throw new LifecycleException("Unable to find URL for Tomcat " + tomcatVersion);
+ }
+
+ File zipFile = downloadFile("org.apache.openejb:tomcat:" + tomcatVersion + ":zip", source);
+ ZipExtractor.unzip(zipFile, catalinaDirectory);
+ }
+
+ public void stop() throws LifecycleException {
+ // only stop the container if we started it
+ if (needsStart) {
+ container.stop();
+ }
+ }
+
+ public void connect(int port) throws Exception {
+ Socket socket = new Socket("localhost", port);
+ OutputStream out = socket.getOutputStream();
+ out.close();
+ }
+
+ private void replace(Map<String, String> replacements, File file) throws IOException {
+ BufferedReader reader = null;
+ PrintWriter writer = null;
+
+ try {
+ File tmpFile = copyToTempFile(file);
+ reader = new BufferedReader(new FileReader(tmpFile));
+ writer = new PrintWriter(new FileWriter(file));
+ String line;
+
+ while ((line = reader.readLine()) != null) {
+ Iterator<String> iterator = replacements.keySet().iterator();
+ while (iterator.hasNext()) {
+ String pattern = iterator.next();
+ String replacement = replacements.get(pattern);
+
+ line = line.replaceAll(pattern, replacement);
+ }
+
+ writer.println(line);
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+
+ if (writer != null) {
+ writer.close();
+ }
+ }
+ }
+
+ private File copyToTempFile(File file) throws IOException {
+ InputStream is = null;
+ OutputStream os = null;
+
+ File tmpFile;
+ try {
+ tmpFile = File.createTempFile("oejb", ".fil");
+ tmpFile.deleteOnExit();
+
+ is = new FileInputStream(file);
+ os = new FileOutputStream(tmpFile);
+
+ Installer.copy(is, os);
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+
+ if (os != null) {
+ os.close();
+ }
+ }
+
+ return tmpFile;
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEEJBEnricherArchiveAppender.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEEJBEnricherArchiveAppender.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEEJBEnricherArchiveAppender.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEEJBEnricherArchiveAppender.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.tomee.arquillian.webapp;
+
+import org.jboss.arquillian.container.test.spi.RemoteLoadableExtension;
+import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveAppender;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+public class RemoteTomEEEJBEnricherArchiveAppender implements AuxiliaryArchiveAppender {
+ @Override public Archive<?> createAuxiliaryArchive() {
+ return ShrinkWrap.create(JavaArchive.class, "arquillian-tomee-testenricher-ejb.jar")
+ .addClasses(RemoteTomEEObserver.class, RemoteTomEERemoteExtension.class)
+ .addAsServiceProvider(RemoteLoadableExtension.class, RemoteTomEERemoteExtension.class);
+ }
+}
\ No newline at end of file
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEExtension.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEExtension.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEExtension.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEExtension.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tomee.arquillian.webapp;
+
+import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
+import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+
+public class RemoteTomEEExtension implements LoadableExtension {
+ @Override public void register(ExtensionBuilder builder) {
+ builder.service(DeployableContainer.class, RemoteTomEEContainer.class)
+ .service(AuxiliaryArchiveAppender.class, RemoteTomEEEJBEnricherArchiveAppender.class);
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEObserver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEObserver.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEObserver.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEEObserver.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.tomee.arquillian.webapp;
+
+import org.apache.openejb.cdi.ThreadSingletonServiceImpl;
+import org.jboss.arquillian.core.api.InstanceProducer;
+import org.jboss.arquillian.core.api.annotation.Inject;
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.test.spi.annotation.SuiteScoped;
+import org.jboss.arquillian.test.spi.event.suite.BeforeSuite;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class RemoteTomEEObserver {
+ @Inject @SuiteScoped private InstanceProducer<BeanManager> beanManager;
+ @Inject @SuiteScoped private InstanceProducer<Context> context;
+
+ public void beforeSuite(@Observes BeforeSuite event) {
+ beanManager.set(ThreadSingletonServiceImpl.get().getBeanManagerImpl());
+ try {
+ context.set(new InitialContext());
+ } catch (NamingException e) {
+ // no-op
+ }
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEERemoteExtension.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEERemoteExtension.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEERemoteExtension.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/RemoteTomEERemoteExtension.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,26 @@
+/**
+ * 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.tomee.arquillian.webapp;
+
+import org.jboss.arquillian.container.test.spi.RemoteLoadableExtension;
+
+public class RemoteTomEERemoteExtension implements RemoteLoadableExtension {
+ @Override public void register(ExtensionBuilder builder) {
+ builder.observer(RemoteTomEEObserver.class);
+ }
+}
Added: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/ZipExtractor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/ZipExtractor.java?rev=1243295&view=auto
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/ZipExtractor.java (added)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/ZipExtractor.java Sun Feb 12 18:49:06 2012
@@ -0,0 +1,74 @@
+/**
+ * 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.tomee.arquillian.webapp;
+
+import java.io. *;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class ZipExtractor {
+
+ public static void unzip(File source, File targetDirectory) {
+ OutputStream os = null;
+ ZipInputStream is = null;
+
+ try {
+ is = new ZipInputStream(new FileInputStream(source));
+ ZipEntry entry;
+
+ while ((entry = is.getNextEntry()) != null) {
+ String name = entry.getName();
+ File file = new File(targetDirectory, name);
+
+ if (name.endsWith("/")) {
+ file.mkdir();
+ } else {
+ file.createNewFile();
+
+ int bytesRead;
+ byte data[] = new byte[8192];
+
+ os = new FileOutputStream(file);
+ while ((bytesRead = is.read(data)) != -1) {
+ os.write(data, 0, bytesRead);
+ }
+
+ is.closeEntry();
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ }
+ }
+
+ if (os != null) {
+ try {
+ os.close();
+ } catch (Exception e) {
+ }
+ }
+
+ }
+ }
+}
Modified: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension?rev=1243295&r1=1243279&r2=1243295&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension (original)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension Sun Feb 12 18:49:06 2012
@@ -1 +1 @@
-org.apache.openejb.arquillian.remote.RemoteTomEEExtension
+org.apache.tomee.arquillian.webapp.RemoteTomEEExtension
Modified: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/test/java/org/apache/openejb/arquillian/session/SessionScopeTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/test/java/org/apache/openejb/arquillian/session/SessionScopeTest.java?rev=1243295&r1=1243279&r2=1243295&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/test/java/org/apache/openejb/arquillian/session/SessionScopeTest.java (original)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-webapp-remote/src/test/java/org/apache/openejb/arquillian/session/SessionScopeTest.java Sun Feb 12 18:49:06 2012
@@ -20,7 +20,6 @@ package org.apache.openejb.arquillian.se
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.openejb.util.IOUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
@@ -34,10 +33,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
@@ -48,14 +43,7 @@ public class SessionScopeTest {
@Deployment
public static WebArchive createDeployment() {
- return ShrinkWrap.create(WebArchive.class, "test.war")
- .addClass(PojoSessionScoped.class).addClass(PojoSessionScopedServletWrapper.class)
- .addAsLibraries(new File("target/test-libs/commons-httpclient.jar"))
- .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
- .setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class)
- .version("3.0")
- .servlet(PojoSessionScopedServletWrapper.class, "/session")
- .exportAsString()));
+ return ShrinkWrap.create(WebArchive.class, "test.war").addClass(PojoSessionScoped.class).addClass(PojoSessionScopedServletWrapper.class).addAsLibraries(new File("target/test-libs/commons-httpclient.jar")).addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")).setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class).version("3.0").servlet(PojoSessionScopedServletWrapper.class, "/session").exportAsString()));
}
@Test
Modified: openejb/trunk/openejb/arquillian-tomee/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/pom.xml?rev=1243295&r1=1243294&r2=1243295&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/pom.xml (original)
+++ openejb/trunk/openejb/arquillian-tomee/pom.xml Sun Feb 12 18:49:06 2012
@@ -47,6 +47,7 @@
<module>arquillian-tomee-common</module>
<module>arquillian-tomee-embedded</module>
<module>arquillian-tomee-remote</module>
+ <module>arquillian-tomee-webapp-remote</module>
<module>arquillian-tomee-tests</module>
<module>arquillian-tomee-moviefun-example</module>
<module>ziplock</module>