forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
256 additions
and
66 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...ss/as/test/integration/weld/multideployment/AbstractBundledLibraryDeploymentTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.weld.multideployment; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.exporter.ZipExporter; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.AfterClass; | ||
|
||
public abstract class AbstractBundledLibraryDeploymentTestCase { | ||
|
||
public static final String BUNDLED_LIBRARY_NAME = "weld-bundled-library.jar"; | ||
public static final String EXTENSION_NAME = "org.jboss.as.test.integration.weld.multideployment.WeldBundledLibraryDeploymentTestCase"; | ||
|
||
private static File libraryRoot; | ||
private static File bundledLibraryFile; | ||
|
||
public static void doSetup() throws Exception { | ||
libraryRoot = createLibraryRoot(); | ||
bundledLibraryFile = new File(libraryRoot, BUNDLED_LIBRARY_NAME); | ||
deleteFile(bundledLibraryFile); | ||
createTestModule(bundledLibraryFile); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() throws Exception { | ||
deleteFile(bundledLibraryFile); | ||
} | ||
|
||
private static void deleteFile(File file) { | ||
if (file.exists()) { | ||
file.delete(); | ||
} | ||
} | ||
|
||
private static void createTestModule(File bundledLibraryFile) throws IOException { | ||
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, BUNDLED_LIBRARY_NAME); | ||
jar.addClasses(SimpleBean.class); | ||
jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
jar.setManifest(new StringAsset("Extension-Name: " + EXTENSION_NAME + "\n")); | ||
jar.as(ZipExporter.class).exportTo(bundledLibraryFile, true); | ||
} | ||
|
||
private static File createLibraryRoot() { | ||
String jbossHome = System.getProperty("jboss.home", null); | ||
if (jbossHome == null) { | ||
throw new IllegalStateException("-Djboss.home not set"); | ||
} | ||
String standalonePath = jbossHome + File.separatorChar + "standalone"; | ||
File standaloneDir = new File(standalonePath); | ||
if (!standaloneDir.exists()) { | ||
throw new IllegalStateException("Determined standalone folder path " + standalonePath + " does not exist"); | ||
} | ||
if (!standaloneDir.isDirectory()) { | ||
throw new IllegalStateException("Determined standalone folder path " + standalonePath + " is not a dir"); | ||
} | ||
|
||
String libraryPath = standalonePath + File.separatorChar + "lib" + File.separatorChar + "ext"; | ||
File libraryDir = new File(libraryPath); | ||
if (libraryDir.exists()) { | ||
if (!libraryDir.isDirectory()) { | ||
throw new IllegalStateException("Determined library folder path " + libraryPath + " is not a dir"); | ||
} | ||
} else { | ||
libraryDir.mkdirs(); | ||
} | ||
return libraryDir; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.../basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/InjectedBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.weld.multideployment; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class InjectedBean { | ||
|
||
@Inject | ||
private SimpleBean bean; | ||
|
||
public SimpleBean getBean() { | ||
return bean; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...src/test/java/org/jboss/as/test/integration/weld/multideployment/InjectedSessionBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.weld.multideployment; | ||
|
||
import javax.ejb.Stateful; | ||
import javax.inject.Inject; | ||
|
||
@Stateful | ||
public class InjectedSessionBean { | ||
|
||
@Inject | ||
private SimpleBean bean; | ||
|
||
public SimpleBean getBean() { | ||
return bean; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...oss/as/test/integration/weld/multideployment/WeldBundledLibraryDeploymentEarTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.weld.multideployment; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Tests that CDI beans defined in an installed library can be used in an .ear deployment. | ||
* | ||
* @see https://issues.jboss.org/browse/AS7-6821 | ||
* | ||
* @author Jozef Hartinger | ||
* | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@Ignore("AS7-6767") | ||
public class WeldBundledLibraryDeploymentEarTestCase extends AbstractBundledLibraryDeploymentTestCase { | ||
|
||
@Inject | ||
private SimpleBean bean; | ||
|
||
@Inject | ||
private InjectedBean injectedBean; | ||
|
||
@Inject | ||
private InjectedSessionBean injectedSessionBean; | ||
|
||
@Test | ||
public void testSimpleBeanInjected() { | ||
Assert.assertNotNull(bean); | ||
bean.ping(); | ||
|
||
Assert.assertNotNull(injectedBean); | ||
Assert.assertNotNull(injectedBean.getBean()); | ||
injectedBean.getBean().ping(); | ||
|
||
Assert.assertNotNull(injectedSessionBean); | ||
Assert.assertNotNull(injectedSessionBean.getBean()); | ||
injectedSessionBean.getBean().ping(); | ||
} | ||
|
||
@Deployment | ||
public static Archive<?> getDeployment() throws Exception { | ||
doSetup(); | ||
|
||
WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") | ||
.addClasses(WeldBundledLibraryDeploymentEarTestCase.class, AbstractBundledLibraryDeploymentTestCase.class) | ||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
JavaArchive library = ShrinkWrap.create(JavaArchive.class, "library.jar").addClasses(InjectedBean.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb-archive.jar").addClasses(InjectedSessionBean.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); | ||
ear.addAsModule(war); | ||
ear.addAsModule(ejbJar); | ||
ear.addAsLibrary(library); | ||
ear.setManifest(new StringAsset("Extension-List: weld1\nweld1-Extension-Name: " + EXTENSION_NAME + "\n")); | ||
return ear; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters