Skip to content

Commit

Permalink
BVTCK-177 Improving the way how the AssertJ JAR is added to test WARs
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Jul 6, 2017
1 parent d07f185 commit 9bee788
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Expand Up @@ -9,6 +9,7 @@
import javax.validation.Validator;
import javax.validation.executable.ExecutableValidator;

import org.assertj.core.api.Assert;
import org.hibernate.beanvalidation.tck.util.CollectionHelper;
import org.hibernate.beanvalidation.tck.util.ConstraintViolationAssert;
import org.hibernate.beanvalidation.tck.util.TestUtil;
Expand Down Expand Up @@ -43,8 +44,11 @@ protected static WebArchiveBuilder webArchiveBuilder() {
// we don't use the Maven features of Shrinkwrap as the TCK might not be run with Maven
// or it could be run in an offline environment
// thus we directly include the classes from the classpath
webArchiveBuilder
.withAdditionalJar( "assertj-core.jar", "org.assertj.core" );
webArchiveBuilder.withAdditionalJar( Assert.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()
);

return webArchiveBuilder;
}
Expand Down
Expand Up @@ -6,16 +6,15 @@
*/
package org.hibernate.beanvalidation.tck.util.shrinkwrap;

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

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.container.ClassContainer;
import org.jboss.shrinkwrap.api.container.LibraryContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.URLPackageScanner;

/**
Expand All @@ -39,7 +38,7 @@ public abstract class ArchiveBuilder<T extends ArchiveBuilder<T, A>, A extends A
protected List<String> packages = null;
protected List<String> classes = null;
protected List<ServiceProviderDescriptor> serviceProviders = null;
protected List<JavaArchive> additionalJars = null;
protected List<File> additionalJars = null;

public T withName(String name) {
this.name = name;
Expand All @@ -49,7 +48,7 @@ public T withName(String name) {
public T withServiceProvider(ServiceProviderDescriptor serviceProvider) {

if ( serviceProviders == null ) {
serviceProviders = new ArrayList<ServiceProviderDescriptor>();
serviceProviders = new ArrayList<>();
}

serviceProviders.add( serviceProvider );
Expand All @@ -58,7 +57,7 @@ public T withServiceProvider(ServiceProviderDescriptor serviceProvider) {

public T withClass(Class<?> clazz) {
if ( this.classes == null ) {
this.classes = new ArrayList<String>();
this.classes = new ArrayList<>();
}

this.classes.add( clazz.getName() );
Expand Down Expand Up @@ -108,7 +107,7 @@ public T withTestClassDefinition(Class<?> testClazz) {
public T withPackage(Package pack) {

if ( this.packages == null ) {
this.packages = new ArrayList<String>();
this.packages = new ArrayList<>();
}

this.packages.add( pack.getName() );
Expand All @@ -126,7 +125,7 @@ public T withResource(String source, boolean useTestPackageToLocateSource) {

public T withResource(String source, String target, boolean useTestPackageToLocateSource) {
if ( this.resources == null ) {
this.resources = new ArrayList<ResourceDescriptor>();
this.resources = new ArrayList<>();
}

this.resources.add( new ResourceDescriptor( source, target, useTestPackageToLocateSource ) );
Expand All @@ -140,13 +139,12 @@ public T withValidationXml(String source) {

public abstract T withEmptyBeansXml();

public T withAdditionalJar(String jarName, String... packages) {
public T withAdditionalJar(String jarName) {
if ( additionalJars == null ) {
additionalJars = new ArrayList<>();
}

JavaArchive archive = ShrinkWrap.create( JavaArchive.class, "arquillian-" + jarName )
.addPackages( true, packages );
File archive = new File( jarName );
additionalJars.add( archive );

return self();
Expand Down Expand Up @@ -243,7 +241,7 @@ protected void processAdditionalJars(LibraryContainer<?> archive) {
return;
}

for ( JavaArchive additionalJar : additionalJars ) {
for ( File additionalJar : additionalJars ) {
archive.addAsLibrary( additionalJar );
}
}
Expand Down

0 comments on commit 9bee788

Please sign in to comment.