Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARQ-1172 Initial implementation of Arquillian adapter for embedded WLS.
Rationale behind Surefire configuration values is explained in the POM. For now, developers i.e. end-users are expected to make the embeddable EJB SPI implementation of WLS 12c, in the Surefire classpath. Developers may do so via a Maven artifact if it makes all the classes available (currently not possible), or add weblogic.jar as a classpath element to Surefire. The JBoss and Oracle/Sun Java EE 6 API artifacts must be omitted from the Surefire classpath for various reasons. The former for having entries to JBoss classes in SPI files, and the latter for not having method bodies. Use weblogic.jar or an equivalent to provide EE 6 APIs at runtime. Multiple test-scoped deployments are not supported since the second and subsequent deployments prevents the container from cleaning up properly.
- Loading branch information
1 parent
7d9fa66
commit ed29c4c
Showing
9 changed files
with
457 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-parent-wls</artifactId> | ||
<version>1.0.0.Final-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
<artifactId>arquillian-wls-embedded-12.1</artifactId> | ||
<name>Arquillian Container WebLogic Embedded 12.1</name> | ||
<properties> | ||
<version.javaee-6_api>6.0</version.javaee-6_api> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-wls-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-container-spi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-container-test-spi</artifactId> | ||
</dependency> | ||
|
||
<!-- Enrichers --> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-cdi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-resource</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-ejb</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.testenricher</groupId> | ||
<artifactId>arquillian-testenricher-initialcontext</artifactId> | ||
</dependency> | ||
|
||
<!-- testing --> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.descriptors</groupId> | ||
<artifactId>shrinkwrap-descriptors-api-javaee</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap.descriptors</groupId> | ||
<artifactId>shrinkwrap-descriptors-impl-javaee</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Java EE 6 standards support --> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>${version.javaee-6_api}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>integration</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>false</skip> | ||
<!-- 80M is the default size of the permanent generation. Insufficient for embedded WLS 12c --> | ||
<argLine>-XX:MaxPermSize=128M</argLine> | ||
<!-- Disable assertions otherwise an assertionerror involving the WLS management runtime is thrown --> | ||
<enableAssertions>false</enableAssertions> | ||
<!-- Add the weblogic.jar to the classpath. | ||
Contains the embedded EJB SPI provider implementation in it's manifest classpath --> | ||
<additionalClasspathElements> | ||
<additionalClasspathElement>${env.WL_HOME}/server/lib/weblogic.jar</additionalClasspathElement> | ||
</additionalClasspathElements> | ||
<!-- Exclude the JEE 6 APIs since they do not have method bodies --> | ||
<classpathDependencyExcludes> | ||
<classpathDependencyExcludes>javax:javaee-api</classpathDependencyExcludes> | ||
</classpathDependencyExcludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
135 changes: 135 additions & 0 deletions
135
...2.1/src/main/java/org/jboss/arquillian/container/wls/embedded_12_1/WebLogicContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.wls.embedded_12_1; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import javax.ejb.embeddable.EJBContainer; | ||
import javax.naming.Context; | ||
|
||
import org.jboss.arquillian.container.spi.client.container.DeployableContainer; | ||
import org.jboss.arquillian.container.spi.client.container.DeploymentException; | ||
import org.jboss.arquillian.container.spi.client.container.LifecycleException; | ||
import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription; | ||
import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; | ||
import org.jboss.arquillian.container.spi.context.annotation.ContainerScoped; | ||
import org.jboss.arquillian.container.wls.ShrinkWrapUtil; | ||
import org.jboss.arquillian.core.api.InstanceProducer; | ||
import org.jboss.arquillian.core.api.annotation.Inject; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.descriptor.api.Descriptor; | ||
|
||
/** | ||
* A {@link DeployableContainer} implementation that uses the {@link EJBContainer} API to control an embedded WLS 12c container. | ||
* | ||
* @author Vineet Reynolds | ||
*/ | ||
public class WebLogicContainer implements DeployableContainer<WebLogicEmbeddedConfiguration> { | ||
|
||
private static final Logger logger = Logger.getLogger(WebLogicContainer.class.getName()); | ||
private EJBContainer ejbContainer; | ||
private WebLogicEmbeddedConfiguration configuration; | ||
|
||
@Inject | ||
@ContainerScoped | ||
private InstanceProducer<Context> ctx; | ||
|
||
@Override | ||
public Class<WebLogicEmbeddedConfiguration> getConfigurationClass() { | ||
return WebLogicEmbeddedConfiguration.class; | ||
} | ||
|
||
@Override | ||
public void setup(WebLogicEmbeddedConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
@Override | ||
public void start() throws LifecycleException { | ||
logger.log(Level.FINE, "Starting container - initialization system properties."); | ||
if (configuration.isOutputToConsole()) { | ||
System.setProperty("weblogic.server.embed.debug", "true"); | ||
System.setProperty("weblogic.StdoutDebugEnabled", "true"); | ||
} | ||
} | ||
|
||
@Override | ||
public void stop() throws LifecycleException { | ||
logger.log(Level.FINE, "Starting container - nothing to do here."); | ||
} | ||
|
||
@Override | ||
public ProtocolDescription getDefaultProtocol() { | ||
return new ProtocolDescription("Local"); | ||
} | ||
|
||
@Override | ||
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { | ||
if (ejbContainer != null) { | ||
throw new DeploymentException("The embedded container does not support multiple deployments in a single test."); | ||
} | ||
logger.log(Level.FINE, "Deploying archive {0}", archive); | ||
// Write the deployment to disk | ||
File deployment = ShrinkWrapUtil.toFile(archive); | ||
String deploymentName = getDeploymentName(archive); | ||
|
||
// Prepare embedded container configuration | ||
Map<String, Object> props = new HashMap<String, Object>(); | ||
props.put(EJBContainer.APP_NAME, deploymentName); | ||
props.put(EJBContainer.MODULES, deployment); | ||
|
||
// Start the embedded container | ||
ejbContainer = EJBContainer.createEJBContainer(props); | ||
ctx.set(ejbContainer.getContext()); | ||
return new ProtocolMetaData(); | ||
} | ||
|
||
@Override | ||
public void undeploy(Archive<?> archive) throws DeploymentException { | ||
logger.log(Level.FINE, "Undeploying archive {0}", archive); | ||
// Stop the embedded container, since there is no undeploy API. | ||
// To prevent multiple deployment in the same test class scope , we'll close and nullify on undeploy. | ||
if (ejbContainer != null) { | ||
ejbContainer.close(); | ||
ejbContainer = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void deploy(Descriptor descriptor) throws DeploymentException { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
@Override | ||
public void undeploy(Descriptor descriptor) throws DeploymentException { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
private String getDeploymentName(Archive<?> archive) { | ||
String archiveFilename = archive.getName(); | ||
int indexOfDot = archiveFilename.indexOf("."); | ||
if (indexOfDot != -1) { | ||
return archiveFilename.substring(0, indexOfDot); | ||
} | ||
return archiveFilename; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
.../java/org/jboss/arquillian/container/wls/embedded_12_1/WebLogicEmbeddedConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.wls.embedded_12_1; | ||
|
||
import org.jboss.arquillian.container.spi.ConfigurationException; | ||
import org.jboss.arquillian.container.spi.client.container.ContainerConfiguration; | ||
|
||
public class WebLogicEmbeddedConfiguration implements ContainerConfiguration { | ||
|
||
private boolean outputToConsole; | ||
|
||
@Override | ||
public void validate() throws ConfigurationException { | ||
|
||
} | ||
|
||
public boolean isOutputToConsole() { | ||
return outputToConsole; | ||
} | ||
|
||
public void setOutputToConsole(boolean outputToConsole) { | ||
this.outputToConsole = outputToConsole; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...2.1/src/main/java/org/jboss/arquillian/container/wls/embedded_12_1/WebLogicExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.wls.embedded_12_1; | ||
|
||
import org.jboss.arquillian.container.spi.client.container.DeployableContainer; | ||
import org.jboss.arquillian.core.spi.LoadableExtension; | ||
|
||
/** | ||
* The WebLogic 12c embedded container adapter | ||
* | ||
* @author Vineet Reynolds | ||
*/ | ||
public class WebLogicExtension implements LoadableExtension { | ||
|
||
@Override | ||
public void register(ExtensionBuilder builder) { | ||
builder.service(DeployableContainer.class, WebLogicContainer.class); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...12.1/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.jboss.arquillian.container.wls.embedded_12_1.WebLogicExtension |
43 changes: 43 additions & 0 deletions
43
...embedded-12.1/src/test/java/org/jboss/arquillian/container/wls/embedded_12_1/Greeter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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. | ||
*/ | ||
|
||
/** | ||
* | ||
* @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a> | ||
*/ | ||
package org.jboss.arquillian.container.wls.embedded_12_1; | ||
|
||
import javax.ejb.Stateless; | ||
|
||
/** | ||
* Basic SLSB for injection. | ||
* | ||
* @author <a href="http://community.jboss.org/people/aslak">Aslak Knutsen</a> | ||
* @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a> | ||
*/ | ||
@Stateless | ||
public class Greeter | ||
{ | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.arquillian.container.wls.remote_103x.Greeter#greet() | ||
*/ | ||
public String greet() | ||
{ | ||
return "Hello"; | ||
} | ||
} |
Oops, something went wrong.