Skip to content

Commit

Permalink
arquillian#157 check for duplicate test class
Browse files Browse the repository at this point in the history
  • Loading branch information
spyrkob committed Nov 17, 2020
1 parent 31889e0 commit c339f38
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.jboss.arquillian.container.spi.Container;
import org.jboss.arquillian.container.spi.ContainerRegistry;
import org.jboss.arquillian.container.spi.client.deployment.Deployment;
Expand Down Expand Up @@ -47,7 +49,11 @@
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.arquillian.test.spi.annotation.ClassScoped;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.asset.ArchiveAsset;
import org.jboss.shrinkwrap.api.container.ClassContainer;
import org.jboss.shrinkwrap.api.spec.WebArchive;

/**
* DeploymentGenerator
Expand Down Expand Up @@ -173,6 +179,16 @@ private void buildTestableDeployments(DeploymentScenario scenario, TestClass tes
// this should be made more reliable, does not work with e.g. a EnterpriseArchive
if (ClassContainer.class.isInstance(applicationArchive)) {
ClassContainer<?> classContainer = ClassContainer.class.cast(applicationArchive);
if (classContainer instanceof WebArchive) {
Map<ArchivePath, Node> content = ((WebArchive) classContainer).getContent();
for (ArchivePath archivePath : content.keySet()) {
if (content.get(archivePath).getAsset() instanceof ArchiveAsset) {
if (!((ArchiveAsset)content.get(archivePath).getAsset()).getArchive().contains("/" + testCase.getJavaClass().getCanonicalName().replaceAll("\\.","/") + ".class")) {
classContainer.addClass(testCase.getJavaClass());
}
}
}
}
classContainer.addClass(testCase.getJavaClass());
addAdditionalObserverClassesIfPresent(classContainer, testCase.getJavaClass());
}
Expand Down

0 comments on commit c339f38

Please sign in to comment.