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.
WFLY-476 Support for implicit bean archives
- Loading branch information
1 parent
861a9ce
commit c1959b3
Showing
53 changed files
with
1,615 additions
and
152 deletions.
There are no files selected for viewing
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
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
25 changes: 25 additions & 0 deletions
25
.../integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Alpha.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,25 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
public class Alpha implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
123 changes: 123 additions & 0 deletions
123
.../basic/src/test/java/org/jboss/as/test/integration/weld/deployment/BeanDiscoveryTest.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,123 @@ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.inject.spi.Extension; | ||
import javax.inject.Inject; | ||
|
||
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.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author Martin Kouba | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class BeanDiscoveryTest { | ||
|
||
@Deployment | ||
public static WebArchive createTestArchive() { | ||
|
||
// 1.1 version beans.xml with bean-discovery-mode of all | ||
JavaArchive alpha = ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClass(Alpha.class) | ||
.addAsManifestResource(newBeans11Descriptor("all"), "beans.xml"); | ||
// Empty beans.xml | ||
JavaArchive bravo = ShrinkWrap.create(JavaArchive.class).addClass(Bravo.class) | ||
.addAsManifestResource(new StringAsset(""), "beans.xml"); | ||
// No version beans.xml | ||
JavaArchive charlie = ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClass(Charlie.class) | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
// Bean defining annotation and no beans.xml | ||
JavaArchive delta = ShrinkWrap.create(JavaArchive.class).addClass(Delta.class); | ||
// Bean defining annotation and 1.1 version beans.xml with bean-discovery-mode of annotated | ||
JavaArchive echo = ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClasses(Echo.class, EchoNotABean.class) | ||
.addAsManifestResource(newBeans11Descriptor("annotated"), "beans.xml"); | ||
// Bean defining annotation and 1.1 version beans.xml with bean-discovery-mode of none | ||
JavaArchive foxtrot = ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClass(Foxtrot.class) | ||
.addAsManifestResource(newBeans11Descriptor("none"), "beans.xml"); | ||
|
||
// Archive which contains an extension and no beans.xml file | ||
JavaArchive legacy = ShrinkWrap.create(JavaArchive.class).addClasses(LegacyExtension.class, LegacyAlpha.class, | ||
LegacyBravo.class).addAsServiceProvider(Extension.class, LegacyExtension.class); | ||
|
||
return ShrinkWrap.create(WebArchive.class).addClasses(BeanDiscoveryTest.class, VerifyingExtension.class) | ||
.addAsServiceProvider(Extension.class, VerifyingExtension.class) | ||
.addAsLibrary(ShrinkWrap.create(JavaArchive.class).addClass(Ping.class)) | ||
.addAsLibraries(alpha, bravo, charlie, delta, echo, foxtrot, legacy); | ||
} | ||
|
||
@Inject | ||
private VerifyingExtension extension; | ||
|
||
@Inject | ||
private BeanManager manager; | ||
|
||
@Test | ||
public void testExplicitBeanArchiveModeAll(Alpha alpha) { | ||
assertDiscoveredAndAvailable(alpha, Alpha.class); | ||
} | ||
|
||
@Test | ||
public void testExplicitBeanArchiveEmptyDescriptor(Bravo bravo) { | ||
assertDiscoveredAndAvailable(bravo, Bravo.class); | ||
} | ||
|
||
@Test | ||
public void testExplicitBeanArchiveLegacyDescriptor(Charlie charlie) { | ||
assertDiscoveredAndAvailable(charlie, Charlie.class); | ||
} | ||
|
||
@Test | ||
public void testImplicitBeanArchiveNoDescriptor(Delta delta) { | ||
assertDiscoveredAndAvailable(delta, Delta.class); | ||
} | ||
|
||
@Test | ||
public void testImplicitBeanArchiveModeAnnotated(Echo echo) { | ||
assertDiscoveredAndAvailable(echo, Echo.class); | ||
assertNotDiscoveredAndNotAvailable(EchoNotABean.class); | ||
} | ||
|
||
@Test | ||
public void testNoBeanArchiveModeNone() { | ||
assertNotDiscoveredAndNotAvailable(Foxtrot.class); | ||
} | ||
|
||
@Test | ||
public void testNotBeanArchiveExtension(LegacyAlpha legacyAlpha) { | ||
assertDiscoveredAndAvailable(legacyAlpha, LegacyAlpha.class); | ||
assertNotDiscoveredAndNotAvailable(LegacyBravo.class); | ||
} | ||
|
||
private <T extends Ping> void assertDiscoveredAndAvailable(T reference, Class<T> clazz) { | ||
Assert.assertTrue(extension.getObservedAnnotatedTypes().contains(clazz)); | ||
Assert.assertNotNull(reference); | ||
reference.pong(); | ||
manager.resolve(manager.getBeans(clazz)); | ||
} | ||
|
||
private <T> void assertNotDiscoveredAndNotAvailable(Class<T> clazz) { | ||
Assert.assertFalse(extension.getObservedAnnotatedTypes().contains(clazz)); | ||
Assert.assertTrue(manager.getBeans(clazz).isEmpty()); | ||
} | ||
|
||
private static StringAsset newBeans11Descriptor(String mode) { | ||
return new StringAsset("<beans bean-discovery-mode=\"" + mode + "\" version=\"1.1\"/>"); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.../integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Bravo.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,25 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
public class Bravo implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...ntegration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Charlie.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,25 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
public class Charlie implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
.../integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Delta.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,28 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
|
||
@RequestScoped | ||
public class Delta implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...e/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Echo.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,28 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
|
||
@RequestScoped | ||
public class Echo implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...ation/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/EchoNotABean.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,25 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
public class EchoNotABean implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ntegration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Foxtrot.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,28 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
|
||
@RequestScoped | ||
public class Foxtrot implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/LegacyAlpha.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,28 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
|
||
@RequestScoped | ||
public class LegacyAlpha implements Ping { | ||
|
||
@Override | ||
public void pong() { | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/LegacyBravo.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,24 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.as.test.integration.weld.deployment; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
|
||
@RequestScoped | ||
public class LegacyBravo { | ||
|
||
} |
Oops, something went wrong.