Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment "caching". #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions spring/spring-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-integration-spring-inject</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* <p>A helper class for creating the tests deployments.</p>
Expand All @@ -38,6 +35,11 @@
*/
public final class Deployments {

/**
* <p>Represents the deployment dependencies.</p>
*/
private static File[] deploymentsDependencies;

/**
* <p>Creates new instance of {@link Deployments} class.</p>
*
Expand All @@ -64,40 +66,27 @@ public static WebArchive createDeployment() {
.addAsResource("create.sql")
.addAsResource("delete.sql")
.addAsResource("insert.sql")
.addAsLibraries(springDependencies());
.addAsLibraries(getDeploymentDependencies());
}

/**
* <p>Retrieves the dependencies.</p>
* <p>Retrieves the deployment dependencies.</p>
*
* @return the array of the dependencies
* @return the deployment dependencies
*/
public static File[] springDependencies() {
private static File[] getDeploymentDependencies() {

ArrayList<File> files = new ArrayList<File>();

files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
files.addAll(resolveDependencies("org.springframework:spring-orm:3.1.1.RELEASE"));
files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE"));
files.addAll(resolveDependencies("org.hibernate:hibernate-core:3.6.0.Final"));
files.addAll(resolveDependencies("org.hibernate:hibernate-annotations:3.4.0.GA"));
files.addAll(resolveDependencies("javassist:javassist:3.6.0.GA"));

return files.toArray(new File[files.size()]);
}

/**
* <p>Resolves the given artifact by it's name with help of maven build system.</p>
*
* @param artifactName the fully qualified artifact name
*
* @return the resolved files
*/
public static List<File> resolveDependencies(String artifactName) {
MavenDependencyResolver mvnResolver = DependencyResolvers.use(MavenDependencyResolver.class);
if (deploymentsDependencies == null) {

mvnResolver.loadMetadataFromPom("pom.xml");
deploymentsDependencies = DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("org.springframework:spring-context:3.1.1.RELEASE",
"org.springframework:spring-orm:3.1.1.RELEASE",
"org.springframework:spring-tx:3.1.1.RELEASE",
"org.hibernate:hibernate-core:3.6.0.Final",
"javassist:javassist:3.6.0.GA")
.resolveAsFiles();
}

return Arrays.asList(mvnResolver.artifacts(artifactName).resolveAsFiles());
return deploymentsDependencies;
}
}
10 changes: 4 additions & 6 deletions spring/spring-hibernate/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

<defaultProtocol type="Servlet 3.0"/>

<engine>
<property name="deploymentExportPath">target/test-archives</property>
</engine>

<!-- Managed container settings -->
<container qualifier="jbossas-managed" default="true">
<configuration>
Expand All @@ -15,10 +19,4 @@
</configuration>
</container>

<!-- Spring extension settings -->
<extension qualifier="spring-deployer">
<!-- Disables the auto package allowing to add all the dependencies through the test -->
<property name="autoPackage">false</property>
</extension>

</arquillian>
5 changes: 0 additions & 5 deletions spring/spring-inject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-integration-spring-inject</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
import com.acme.spring.inject.service.StockService;
import com.acme.spring.inject.service.impl.DefaultStockService;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

import java.io.File;

/**
* <p>A helper class for creating the tests deployments.</p>
Expand All @@ -31,6 +35,11 @@
*/
public final class Deployments {

/**
* <p>Represents the deployment dependencies.</p>
*/
private static File[] deploymentsDependencies;

/**
* <p>Creates new instance of {@link com.acme.spring.inject.Deployments} class.</p>
*
Expand All @@ -41,13 +50,33 @@ private Deployments() {
}

/**
* <p>Creates new tests deployment</p>
* <p>Creates new test deployment.</p>
*
* @return new test deployment
*/
public static JavaArchive createDeployment() {
public static WebArchive createDeployment() {

return ShrinkWrap.create(JavaArchive.class, "spring-test.jar")
return ShrinkWrap.create(WebArchive.class, "spring-test.war")
.addClasses(Stock.class, StockRepository.class, StockService.class,
DefaultStockRepository.class, DefaultStockService.class)
.addAsResource("applicationContext.xml");
.addAsResource("applicationContext.xml")
.addAsLibraries(getDeploymentDependencies());
}

/**
* <p>Retrieves the deployment dependencies.</p>
*
* @return the deployment dependencies
*/
private static File[] getDeploymentDependencies() {

if (deploymentsDependencies == null) {

deploymentsDependencies = DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("org.springframework:spring-context:3.1.1.RELEASE")
.resolveAsFiles();
}

return deploymentsDependencies;
}
}
5 changes: 0 additions & 5 deletions spring/spring-javaconfig/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-integration-spring-javaconfig</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import com.acme.spring.javaconfig.service.StockService;
import com.acme.spring.javaconfig.service.impl.DefaultStockService;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

import java.io.File;

/**
* <p>A helper class for creating the tests deployments.</p>
Expand All @@ -32,6 +36,11 @@
*/
public final class Deployments {

/**
* <p>Represents the deployment dependencies.</p>
*/
private static File[] deploymentsDependencies;

/**
* <p>Creates new instance of {@link Deployments} class.</p>
*
Expand All @@ -42,12 +51,34 @@ private Deployments() {
}

/**
* <p>Creates new tests deployment</p>
* <p>Creates new test deployment.</p>
*
* @return new test deployment
*/
public static JavaArchive createDeployment() {
public static WebArchive createDeployment() {

return ShrinkWrap.create(JavaArchive.class, "spring-test.jar")
return ShrinkWrap.create(WebArchive.class, "spring-test.war")
.addClasses(Stock.class, StockRepository.class, StockService.class,
DefaultStockRepository.class, DefaultStockService.class, StockConfig.class);
DefaultStockRepository.class, DefaultStockService.class, StockConfig.class)
.addAsLibraries(getDeploymentDependencies());
}

/**
* <p>Retrieves the deployment dependencies.</p>
*
* @return the deployment dependencies
*/
private static File[] getDeploymentDependencies() {

if (deploymentsDependencies == null) {

deploymentsDependencies = DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("org.springframework:spring-context:3.1.1.RELEASE", "cglib:cglib:2.2.2")
.resolveAsFiles();


}

return deploymentsDependencies;
}
}
5 changes: 0 additions & 5 deletions spring/spring-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-integration-spring-inject</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* <p>A helper class for creating the tests deployments.</p>
Expand All @@ -38,6 +35,11 @@
*/
public final class Deployments {

/**
* <p>Represents the deployment dependencies.</p>
*/
private static File[] deploymentsDependencies;

/**
* <p>Creates new instance of {@link Deployments} class.</p>
*
Expand All @@ -48,9 +50,9 @@ private Deployments() {
}

/**
* <p>Creates new tests deployment.</p>
* <p>Creates new test deployment.</p>
*
* @return the create archive
* @return new test deployment
*/
public static WebArchive createDeployment() {

Expand All @@ -64,37 +66,24 @@ public static WebArchive createDeployment() {
.addAsResource("create.sql")
.addAsResource("delete.sql")
.addAsResource("insert.sql")
.addAsLibraries(springDependencies());
.addAsLibraries(getDeploymentDependencies());
}

/**
* <p>Retrieves the dependencies.</p>
* <p>Retrieves the deployment dependencies.</p>
*
* @return the array of the dependencies
* @return the deployment dependencies
*/
public static File[] springDependencies() {
private static File[] getDeploymentDependencies() {

ArrayList<File> files = new ArrayList<File>();

files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
files.addAll(resolveDependencies("org.springframework:spring-jdbc:3.1.1.RELEASE"));
files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE"));

return files.toArray(new File[files.size()]);
}

/**
* <p>Resolves the given artifact by it's name with help of maven build system.</p>
*
* @param artifactName the fully qualified artifact name
*
* @return the resolved files
*/
public static List<File> resolveDependencies(String artifactName) {
MavenDependencyResolver mvnResolver = DependencyResolvers.use(MavenDependencyResolver.class);
if (deploymentsDependencies == null) {

mvnResolver.loadMetadataFromPom("pom.xml");
deploymentsDependencies = DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("org.springframework:spring-context:3.1.1.RELEASE",
"org.springframework:spring-jdbc:3.1.1.RELEASE",
"org.springframework:spring-tx:3.1.1.RELEASE").resolveAsFiles();
}

return Arrays.asList(mvnResolver.artifacts(artifactName).resolveAsFiles());
return deploymentsDependencies;
}
}
6 changes: 0 additions & 6 deletions spring/spring-jdbc/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@
</configuration>
</container>

<!-- Spring extension settings -->
<extension qualifier="spring-deployer">
<!-- Disables the auto package allowing to add all the dependencies through the test -->
<property name="autoPackage">false</property>
</extension>

</arquillian>
5 changes: 0 additions & 5 deletions spring/spring-jms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
<artifactId>arquillian-junit-container</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-integration-spring-inject</artifactId>
Expand Down
Loading