[jboss-svn-commits] JBoss Common SVN: r4675 - in arquillian/trunk/containers: jetty-embedded-7 and 21 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Jul 4 02:35:46 EDT 2010
Author: dan.j.allen
Date: 2010-07-04 02:35:45 -0400 (Sun, 04 Jul 2010)
New Revision: 4675
Added:
arquillian/trunk/containers/jetty-embedded-7/
arquillian/trunk/containers/jetty-embedded-7/pom.xml
arquillian/trunk/containers/jetty-embedded-7/src/
arquillian/trunk/containers/jetty-embedded-7/src/main/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedConfiguration.java
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedContainer.java
arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedDeploymentAppender.java
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.container.jetty.embedded_7.ShrinkWrapWebAppContext
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
arquillian/trunk/containers/jetty-embedded-7/src/test/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedClientTestCase.java
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedInContainerTestCase.java
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/MavenArtifactResolver.java
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestBean.java
arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestServlet.java
arquillian/trunk/containers/jetty-embedded-7/src/test/resources/
arquillian/trunk/containers/jetty-embedded-7/src/test/resources/arquillian.xml
arquillian/trunk/containers/jetty-embedded-7/src/test/resources/client-web.xml
arquillian/trunk/containers/jetty-embedded-7/src/test/resources/in-container-web.xml
arquillian/trunk/containers/jetty-embedded-7/src/test/resources/jetty-env.xml
Log:
ARQ-145 Jetty Embedded 7 container
Property changes on: arquillian/trunk/containers/jetty-embedded-7
___________________________________________________________________
Name: svn:ignore
+ target
Added: arquillian/trunk/containers/jetty-embedded-7/pom.xml
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/pom.xml (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/pom.xml 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jetty-embedded-7</artifactId>
+ <name>Arquillian Container: Jetty Embedded 7.x and 8.x</name>
+ <description>Jetty Embedded 7.x and 8.x container integration for the Arquillian project</description>
+
+ <properties>
+ <!-- known to work with all Jetty 7.x and 8.x versions (7.0.0.v20091005 through 8.0.0.M0) -->
+ <version.jetty>7.0.0.v20091005</version.jetty>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>${version.jetty}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-extension-jetty-7</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet-ee6</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- TODO We likely need a servlet packager to restrict use of EAR -->
+ <dependency>
+ <groupId>org.jboss.arquillian.packager</groupId>
+ <artifactId>arquillian-packager-javaee</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-cdi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-resource</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-impl-base</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Jetty plus and naming required for testing resource injections -->
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>${version.jetty}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Weld servlet required for testing CDI injections -->
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <version>1.0.1-Final</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.2.138</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
+
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedConfiguration.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedConfiguration.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedConfiguration.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import org.jboss.arquillian.spi.ContainerConfiguration;
+import org.jboss.arquillian.spi.ContainerProfile;
+
+/**
+ * A {@link org.jboss.arquillian.spi.ContainerConfiguration} implementation for
+ * the Jetty Embedded 7.x and 8.x containers.
+ *
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+public class JettyEmbeddedConfiguration implements ContainerConfiguration
+{
+ private String bindAddress = "localhost";
+
+ private int bindHttpPort = 9090;
+
+ private boolean jettyPlus = true;
+
+ public ContainerProfile getContainerProfile()
+ {
+ return ContainerProfile.CLIENT;
+ }
+
+ public int getBindHttpPort()
+ {
+ return bindHttpPort;
+ }
+
+ public void setBindHttpPort(int bindHttpPort)
+ {
+ this.bindHttpPort = bindHttpPort;
+ }
+
+ public String getBindAddress()
+ {
+ return bindAddress;
+ }
+
+ public void setBindAddress(String bindAddress)
+ {
+ this.bindAddress = bindAddress;
+ }
+
+ public boolean isJettyPlus()
+ {
+ return jettyPlus;
+ }
+
+ public void setJettyPlus(boolean jettyPlus)
+ {
+ this.jettyPlus = jettyPlus;
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedContainer.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedContainer.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedContainer.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import java.net.URL;
+import java.util.logging.Logger;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.jetty_7.api.ShrinkWrapWebAppContext;
+
+/**
+ * <p>Jetty Embedded 7.x and 8.x container for the Arquillian project.</p>
+ *
+ * <p>This container only supports a WebArchive deployment. The context path of the
+ * deployed application is always set to "/test", which is expected by the Arquillian
+ * servlet protocol.</p>
+ *
+ * <p>Another known issue is that the container configuration process logs an exception when
+ * running in-container. However, the container is still configured properly during setup.</p>
+ *
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+public class JettyEmbeddedContainer implements DeployableContainer
+{
+ public static final String HTTP_PROTOCOL = "http";
+
+ public static final String WEB_APP_CONTEXT_PATH = "/test";
+
+ public static final String[] JETTY_PLUS_CONFIGURATION_CLASSES =
+ {
+ "org.eclipse.jetty.webapp.WebInfConfiguration",
+ "org.eclipse.jetty.webapp.WebXmlConfiguration",
+ "org.eclipse.jetty.webapp.MetaInfConfiguration",
+ "org.eclipse.jetty.webapp.FragmentConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.Configuration",
+ "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
+ };
+
+ private static final Logger log = Logger.getLogger(JettyEmbeddedContainer.class.getName());
+
+ private Server server;
+
+ private JettyEmbeddedConfiguration containerConfig;
+
+ public JettyEmbeddedContainer()
+ {
+ }
+
+ public void setup(Context context, Configuration arquillianConfig)
+ {
+ containerConfig = arquillianConfig.getContainerConfig(JettyEmbeddedConfiguration.class);
+ }
+
+ public void start(Context context) throws LifecycleException
+ {
+ try
+ {
+ server = new Server();
+ Connector connector = new SelectChannelConnector();
+ connector.setHost(containerConfig.getBindAddress());
+ connector.setPort(containerConfig.getBindHttpPort());
+ server.setConnectors(new Connector[] { connector });
+ server.setHandler(new HandlerCollection(true));
+ log.info("Starting Jetty Embedded Server " + Server.getVersion() + " [id:" + server.hashCode() + "]");
+ server.start();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not start container", e);
+ }
+ }
+
+ public void stop(Context context) throws LifecycleException
+ {
+ try
+ {
+ log.info("Stopping Jetty Embedded Server [id:" + server.hashCode() + "]");
+ server.stop();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not stop container", e);
+ }
+ }
+
+ public ContainerMethodExecutor deploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ try
+ {
+ WebAppContext wctx = archive.as(ShrinkWrapWebAppContext.class);
+ // Jetty plus is required to support in-container invocation and enrichment
+ if (containerConfig.isJettyPlus())
+ {
+ wctx.setConfigurationClasses(JETTY_PLUS_CONFIGURATION_CLASSES);
+ }
+ // FIXME shrinkwrap jetty adapter does not remove file extension from name when setting context path
+ wctx.setContextPath(WEB_APP_CONTEXT_PATH);
+ // possible configuration parameters
+ wctx.setExtractWAR(true);
+ wctx.setLogUrlOnStart(true);
+ ((HandlerCollection) server.getHandler()).addHandler(wctx);
+ wctx.start();
+ context.add(WebAppContext.class, wctx);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy " + archive.getName(), e);
+ }
+
+ try
+ {
+ return new ServletMethodExecutor(
+ new URL(
+ HTTP_PROTOCOL,
+ containerConfig.getBindAddress(),
+ containerConfig.getBindHttpPort(),
+ "/")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create ContainerMethodExecutor", e);
+ }
+ }
+
+ public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ WebAppContext wctx = context.get(WebAppContext.class);
+ if (wctx != null)
+ {
+ try
+ {
+ wctx.stop();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ log.severe("Could not stop context " + wctx.getContextPath() + ": " + e.getMessage());
+ }
+ ((HandlerCollection) server.getHandler()).removeHandler(wctx);
+ }
+ }
+
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedDeploymentAppender.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedDeploymentAppender.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedDeploymentAppender.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher;
+import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * Package the test enrichers supported by the Jetty Embedded 7 container plugin.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+public class JettyEmbeddedDeploymentAppender implements AuxiliaryArchiveAppender
+{
+
+ public Archive<?> createAuxiliaryArchive()
+ {
+ JavaArchive archive = ShrinkWrap.create("arquillian-jetty-testenrichers.jar", JavaArchive.class)
+ .addPackages(
+ false,
+ CDIInjectionEnricher.class.getPackage(),
+ ResourceInjectionEnricher.class.getPackage())
+ .addServiceProvider(
+ TestEnricher.class,
+ CDIInjectionEnricher.class,
+ ResourceInjectionEnricher.class);
+ return archive;
+ }
+
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.container.jetty.embedded_7.ShrinkWrapWebAppContext
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.container.jetty.embedded_7.ShrinkWrapWebAppContext (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.container.jetty.embedded_7.ShrinkWrapWebAppContext 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.jetty.embedded_7.ShrinkWrapWebAppContext
\ No newline at end of file
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.jetty.embedded_7.JettyEmbeddedDeploymentAppender
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.jetty.embedded_7.JettyEmbeddedConfiguration
Added: arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.jetty.embedded_7.JettyEmbeddedContainer
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedClientTestCase.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedClientTestCase.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedClientTestCase.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import static org.jboss.arquillian.api.RunModeType.AS_CLIENT;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Client test case for the Jetty Embedded 7 container
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+ at Run(AS_CLIENT)
+public class JettyEmbeddedClientTestCase
+{
+ private static final Logger log = Logger.getLogger(JettyEmbeddedClientTestCase.class.getName());
+
+ /**
+ * Deployment for the test
+ */
+ @Deployment
+ public static WebArchive getTestArchive()
+ {
+ final WebArchive war = ShrinkWrap.create("client-test.war", WebArchive.class)
+ .addClass(TestServlet.class)
+ .setWebXML("client-web.xml");
+ log.info(war.toString(true));
+ return war;
+ }
+
+ @Test
+ public void shouldBeAbleToInvokeServletInDeployedWebApp() throws Exception
+ {
+ String body = readAllAndClose(
+ new URL("http://localhost:9595/test" + TestServlet.URL_PATTERN).openStream());
+
+ Assert.assertEquals(
+ "Verify that the servlet was deployed and returns expected result",
+ TestServlet.MESSAGE,
+ body);
+ }
+
+ private String readAllAndClose(InputStream is) throws Exception
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try
+ {
+ int read;
+ while( (read = is.read()) != -1)
+ {
+ out.write(read);
+ }
+ }
+ finally
+ {
+ try { is.close(); } catch (Exception e) { }
+ }
+ return out.toString();
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedInContainerTestCase.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedInContainerTestCase.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/JettyEmbeddedInContainerTestCase.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import java.sql.Connection;
+import java.util.logging.Logger;
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.sql.DataSource;
+
+import org.jboss.arquillian.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.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * In-container test case for the Jetty Embedded 7 container
+ *
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class JettyEmbeddedInContainerTestCase
+{
+ private static final Logger log = Logger.getLogger(JettyEmbeddedInContainerTestCase.class.getName());
+
+ /**
+ * Deployment for the test
+ */
+ @Deployment
+ public static WebArchive getTestArchive()
+ {
+ final WebArchive war = ShrinkWrap.create("in-container-test.war", WebArchive.class)
+ .addClass(TestBean.class)
+ // adding the configuration class silences the logged exception when building the configuration on the server-side, but shouldn't be necessary
+ //.addClass(JettyEmbeddedConfiguration.class)
+ .addLibrary(MavenArtifactResolver.resolve("org.jboss.weld.servlet:weld-servlet:1.0.1-Final"))
+ .addWebResource("jetty-env.xml")
+ .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml")
+ .setWebXML("in-container-web.xml");
+ log.info(war.toString(true));
+ return war;
+ }
+
+ // defined in jetty-env.xml, scoped to global
+ @Resource(mappedName = "version") Integer version;
+
+ // defined in web.xml, scoped to webapp (relative to java:comp/env)
+ @Resource(name = "name") String name;
+
+ // defined in jetty-env.xml, scoped to webapp (relative to java:comp/env)
+ @Resource(name = "type") String containerType;
+
+ @Resource(name = "jdbc/test") DataSource ds;
+
+ @Inject TestBean testBean;
+
+ @Test
+ public void shouldBeAbleToInjectMembersIntoTestClass() throws Exception
+ {
+ Assert.assertNotNull(version);
+ Assert.assertEquals(new Integer(6), version);
+ Assert.assertNotNull(name);
+ Assert.assertEquals("Jetty", name);
+ Assert.assertNotNull(containerType);
+ Assert.assertEquals("Embedded", containerType);
+ Assert.assertNotNull(ds);
+ Connection c = null;
+ try
+ {
+ c = ds.getConnection();
+ Assert.assertEquals("H2", c.getMetaData().getDatabaseProductName());
+ c.close();
+ }
+ catch (Exception e)
+ {
+ Assert.fail(e.getMessage());
+ }
+ finally
+ {
+ if (c != null && !c.isClosed())
+ {
+ c.close();
+ }
+ }
+ Assert.assertNotNull(testBean);
+ Assert.assertEquals("Jetty", testBean.getName());
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/MavenArtifactResolver.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/MavenArtifactResolver.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/MavenArtifactResolver.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import java.io.File;
+
+/**
+ * A crude resolver that converts a Maven artifact reference
+ * into a {@link java.io.File} object.
+ *
+ * <p>This approach is an interim solution for Maven projects
+ * until the open feature request to add formally add artifacts
+ * to a test (ARQ-66) is implementated.</p>
+ *
+ * <p>The testCompile goal will resolve any test dependencies and
+ * put them in your local Maven repository. By the time the test
+ * executes, you can be sure that the JAR files you need will be
+ * in your local repository.</p>
+ *
+ * <p>Example usage:</p>
+ *
+ * <pre>
+ * WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ * .addLibrary(MavenArtifactResolver.resolve("commons-lang:commons-lang:2.5"));
+ * </pre>
+ *
+ * @author Dan Allen
+ */
+public class MavenArtifactResolver
+{
+ private static final String LOCAL_MAVEN_REPO =
+ System.getProperty("user.home") + File.separatorChar +
+ ".m2" + File.separatorChar + "repository";
+
+ public static File resolve(String groupId, String artifactId, String version)
+ {
+ return new File(LOCAL_MAVEN_REPO + File.separatorChar +
+ groupId.replace(".", File.separator) + File.separatorChar +
+ artifactId + File.separatorChar +
+ version + File.separatorChar +
+ artifactId + "-" + version + ".jar");
+ }
+
+ public static File resolve(String qualifiedArtifactId)
+ {
+ String[] segments = qualifiedArtifactId.split(":");
+ return resolve(segments[0], segments[1], segments[2]);
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestBean.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestBean.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestBean.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import javax.annotation.Resource;
+
+public class TestBean
+{
+ @Resource(name = "name")
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestServlet.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestServlet.java (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/java/org/jboss/arquillian/container/jetty/embedded_7/TestServlet.java 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.arquillian.container.jetty.embedded_7;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * TestServlet
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class TestServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final String URL_PATTERN = "/Test";
+
+ public static final String MESSAGE = "hello";
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ response.getWriter().append(MESSAGE);
+ }
+}
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/resources/arquillian.xml
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/resources/arquillian.xml (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/resources/arquillian.xml 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.com/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jetty7="urn:arq:org.jboss.arquillian.container.jetty.embedded_7">
+
+ <jetty7:container>
+ <jetty7:bindHttpPort>9595</jetty7:bindHttpPort>
+ </jetty7:container>
+
+</arquillian>
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/resources/client-web.xml
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/resources/client-web.xml (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/resources/client-web.xml 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <servlet>
+ <servlet-name>Test</servlet-name>
+ <servlet-class>org.jboss.arquillian.container.jetty.embedded_7.TestServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Test</servlet-name>
+ <url-pattern>/Test</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/resources/in-container-web.xml
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/resources/in-container-web.xml (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/resources/in-container-web.xml 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <env-entry>
+ <env-entry-name>name</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Jetty</env-entry-value>
+ </env-entry>
+
+ <!-- Should be overridden by jetty-env.xml -->
+ <env-entry>
+ <env-entry-name>type</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Remote</env-entry-value>
+ </env-entry>
+
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+</web-app>
Added: arquillian/trunk/containers/jetty-embedded-7/src/test/resources/jetty-env.xml
===================================================================
--- arquillian/trunk/containers/jetty-embedded-7/src/test/resources/jetty-env.xml (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-7/src/test/resources/jetty-env.xml 2010-07-04 06:35:45 UTC (rev 4675)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
+ "http://www.eclipse.org/jetty/configure.dtd">
+<Configure id="webAppCtx" class="org.eclipse.jetty.webapp.WebAppContext">
+ <!-- Third argument to EnvEntry constructor (overrideWebXml) required for Jetty <= 6.1.14 -->
+ <!-- EnvEntry scope not implemented until Jetty 6.1.12 -->
+ <New class="org.eclipse.jetty.plus.jndi.EnvEntry">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>type</Arg>
+ <Arg type="java.lang.String">Embedded</Arg>
+ <Arg type="boolean">true</Arg>
+ </New>
+ <New class="org.eclipse.jetty.plus.jndi.EnvEntry">
+ <Arg>version</Arg>
+ <Arg type="java.lang.Integer">6</Arg>
+ <Arg type="boolean">true</Arg>
+ </New>
+ <!-- I can't figure out why org.eclipse.jetty.plus.jndi.Resource doesn't work here, but it doesn't -->
+ <New class="org.eclipse.jetty.plus.jndi.EnvEntry">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>BeanManager</Arg>
+ <Arg>
+ <New class="javax.naming.Reference">
+ <Arg>javax.enterprise.inject.spi.BeanManager</Arg>
+ <Arg>org.jboss.weld.resources.ManagerObjectFactory</Arg>
+ <Arg/>
+ </New>
+ </Arg>
+ <Arg type="boolean">true</Arg>
+ </New>
+ <New class="org.eclipse.jetty.plus.jndi.EnvEntry">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>jdbc/test</Arg>
+ <Arg>
+ <New class="org.h2.jdbcx.JdbcDataSource">
+ <Set name="URL">jdbc:h2:mem:test</Set>
+ <Set name="user">sa</Set>
+ <Set name="password">sa</Set>
+ </New>
+ </Arg>
+ <Arg type="boolean">true</Arg>
+ </New>
+</Configure>
More information about the jboss-svn-commits
mailing list