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

MP Config TCK - fix a regression caused by #2629 #2743

Merged
merged 3 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.tck.config;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.asset.ArchiveAsset;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;

/**
* Arquillian automatically adds the test class to a test deployment. However, some MP Config tests do add the test class to a
* library jar too. As a result, we get ambiguous dependency when trying to instantiate the test class. Unfortunately, we can't
* use an ApplicationArchiveProcessor to remove the test class added by Arquillian because it's applied
* before the test class is added. Therefore, we deciced to remove the test class from any library jar.
*/
public class ConfigApplicationArchiveProcessor implements ApplicationArchiveProcessor {

private static final ArchivePath PATH_LIBRARY = ArchivePaths.create("WEB-INF/lib");

@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
if (applicationArchive instanceof WebArchive) {
WebArchive war = applicationArchive.as(WebArchive.class);
Node libNode = war.get(PATH_LIBRARY);
if (libNode != null) {
for (Node child : libNode.getChildren()) {
Asset childAsset = child.getAsset();
if (childAsset instanceof ArchiveAsset) {
ArchiveAsset archiveAsset = (ArchiveAsset) childAsset;
if (archiveAsset.getArchive() instanceof JavaArchive) {
JavaArchive libArchive = (JavaArchive) archiveAsset.getArchive();
libArchive.deleteClass(testClass.getName());
}
}
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.quarkus.tck.config;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.core.spi.LoadableExtension;

public class ConfigExtension implements LoadableExtension {

@Override
public void register(ExtensionBuilder builder) {
builder.service(ApplicationArchiveProcessor.class, ConfigApplicationArchiveProcessor.class);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.quarkus.tck.config.ConfigExtension