fix setup for Weld3 based containers.
Weld seems to fire BeforeBeanDiscovery only once for the whole EAR, but
with only the EAR jars on the classpath. So no config in the WAR file
can be seen at this early point in the boot process in Wildfly
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/local/BdaAlternativeEarFileTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/local/BdaAlternativeEarFileTest.java
index 380025f..73cd515 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/local/BdaAlternativeEarFileTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/local/BdaAlternativeEarFileTest.java
@@ -44,7 +44,7 @@
String simpleName = BdaAlternativeWarFileTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
- JavaArchive globalAlternativeConfigJar = ShrinkWrap.create(JavaArchive.class, "globalAlternativesCofig.jar")
+ JavaArchive globalAlternativeConfigJar = ShrinkWrap.create(JavaArchive.class, "globalAlternativesConfig.jar")
.addAsManifestResource(new StringAsset(CONFIG),
"apache-deltaspike.properties");
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeEarFileTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeEarFileTest.java
index 8863c5a..8a21635 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeEarFileTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeEarFileTest.java
@@ -18,14 +18,20 @@
*/
package org.apache.deltaspike.test.core.api.exclude;
+import java.io.IOException;
+
import org.apache.deltaspike.test.category.EnterpriseArchiveProfileCategory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import static org.apache.deltaspike.test.core.api.exclude.ExcludeWarFileTest.getConfigContent;
+
/**
* Tests for {@link org.apache.deltaspike.core.api.exclude.Exclude}
*/
@@ -33,14 +39,22 @@
@Category(EnterpriseArchiveProfileCategory.class)
public class ExcludeEarFileTest extends ExcludeTest
{
+
@Deployment
- public static EnterpriseArchive deployEar()
+ public static EnterpriseArchive deployEar() throws IOException
{
//workaround for tomee - the ear-file needs to have the same name as the war-file
String simpleName = ExcludeWarFileTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ // we needs to package the config into the EAR, as Weld3 based app servers boot the whole container
+ // with just the EAR classloader. No WAR file packaged config is reachable for BeforeBeanDiscovery
+ JavaArchive excludeConfigJar = ShrinkWrap.create(JavaArchive.class, "excludeConfig.jar")
+ .addAsManifestResource(new StringAsset(getConfigContent()), "apache-deltaspike.properties");
+
return ShrinkWrap.create(EnterpriseArchive.class, archiveName + ".ear")
+ .addAsLibrary(excludeConfigJar)
.addAsModule(ExcludeWarFileTest.deploy());
}
}
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeWarFileTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeWarFileTest.java
index 156201d..1085322 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeWarFileTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/ExcludeWarFileTest.java
@@ -35,7 +35,9 @@
import org.junit.runner.RunWith;
import javax.enterprise.inject.spi.Extension;
-import java.net.URL;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
/**
* Tests for {@link org.apache.deltaspike.core.api.exclude.Exclude}
@@ -47,7 +49,7 @@
* X TODO creating a WebArchive is only a workaround because JavaArchive cannot contain other archives.
*/
@Deployment
- public static WebArchive deploy()
+ public static WebArchive deploy() throws IOException
{
String simpleName = ExcludeWarFileTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
@@ -55,16 +57,12 @@
// in case the Arquillian adapter doesn't properly handle resources on the classpath
ProjectStageProducer.setProjectStage(ProjectStage.Production);
- URL fileUrl = ExcludeWarFileTest.class.getClassLoader()
- .getResource("META-INF/apache-deltaspike.properties");
-
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "excludeTest.jar")
.addPackage(ExcludeWarFileTest.class.getPackage())
.addPackage(TestClassDeactivator.class.getPackage())
- .addAsManifestResource(FileUtils.getFileForURL(fileUrl.toString()))
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
- .addAsResource(new StringAsset("org.apache.deltaspike.ProjectStage = Production"),
- "apache-deltaspike.properties"); // when deployed on some remote container;
+ .addAsManifestResource(new StringAsset(getConfigContent()),
+ "apache-deltaspike.properties") // when deployed on some remote container;
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
@@ -73,6 +71,14 @@
.addAsServiceProvider(Extension.class, ExcludeExtension.class);
}
+ public static String getConfigContent() throws IOException
+ {
+ byte[] configContent = Files.readAllBytes(FileUtils.getFileForURL(ExcludeWarFileTest.class.getClassLoader()
+ .getResource("META-INF/apache-deltaspike.properties").toString()).toPath());
+ return new String(configContent, StandardCharsets.UTF_8) +
+ "\norg.apache.deltaspike.ProjectStage = Production";
+ }
+
@AfterClass
public static void resetProjectStage() {
ProjectStageProducer.setProjectStage(null);