Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLDER-95 migrate tests to compatibility module
- Loading branch information
1 parent
c4fc440
commit 2f3aab0
Showing
32 changed files
with
1,060 additions
and
20 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
65 changes: 65 additions & 0 deletions
65
src/test/java/org/jboss/seam/compat/alternative/AlternativeTest.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,65 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.alternative; | ||
|
||
import static org.jboss.shrinkwrap.api.ShrinkWrap.create; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import javax.enterprise.inject.spi.Extension; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.arquillian.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
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.jboss.shrinkwrap.descriptor.api.Descriptors; | ||
import org.jboss.shrinkwrap.descriptor.api.spec.cdi.beans.BeansDescriptor; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* This test verifies that alternatives work correctly in BDAs that contain at least one extension. | ||
* | ||
* @see <a href="http://java.net/jira/browse/GLASSFISH-15791">GLASSFISH-15791</a> (resolved) | ||
* | ||
* @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class AlternativeTest { | ||
@Inject | ||
private Foo foo; | ||
|
||
@Deployment | ||
public static WebArchive getDeployment() { | ||
return create(WebArchive.class, "test.war").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml").addAsLibrary(getJar()); | ||
} | ||
|
||
public static JavaArchive getJar() { | ||
BeansDescriptor beansXml = Descriptors.create(BeansDescriptor.class).alternativeClass(BarAlternative.class); | ||
return create(JavaArchive.class, "test.jar") | ||
.addClasses(Foo.class, Bar.class, BarAlternative.class, NoopExtension.class) | ||
.addAsManifestResource(new StringAsset(beansXml.exportAsString()), beansXml.getDescriptorName()) | ||
.addAsServiceProvider(Extension.class, NoopExtension.class); | ||
} | ||
|
||
@Test | ||
public void testAlternative() { | ||
assertEquals("barAlternative", foo.getBar().ping()); | ||
} | ||
} |
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,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.alternative; | ||
|
||
public class Bar { | ||
public String ping() { | ||
return "bar"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/org/jboss/seam/compat/alternative/BarAlternative.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,27 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.alternative; | ||
|
||
import javax.enterprise.inject.Alternative; | ||
|
||
@Alternative | ||
public class BarAlternative extends Bar { | ||
@Override | ||
public String ping() { | ||
return super.ping() + "Alternative"; | ||
} | ||
} |
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 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.alternative; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class Foo { | ||
@Inject | ||
private Bar bar; | ||
|
||
public Bar getBar() { | ||
return bar; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/org/jboss/seam/compat/alternative/NoopExtension.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,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.alternative; | ||
|
||
import javax.enterprise.inject.spi.Extension; | ||
|
||
public class NoopExtension implements Extension { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, 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. | ||
*/ | ||
/** | ||
* A collection of tests that explore CDI implementation problems that have threatened | ||
* the portability of Seam 3. | ||
* | ||
* @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a> | ||
* @author <a href="http://community.jboss.org/people/lightguard">Jason Porter</a> | ||
* @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a> | ||
*/ | ||
package org.jboss.seam.compat; | ||
|
28 changes: 28 additions & 0 deletions
28
src/test/java/org/jboss/seam/compat/registration/AnotherBeanClassToRegister.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 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.registration; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class AnotherBeanClassToRegister { | ||
@Inject | ||
private BeanClassToRegister collaborator; | ||
|
||
public BeanClassToRegister getCollaborator() { | ||
return collaborator; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/org/jboss/seam/compat/registration/AnotherManualBeanRegistrationExtension.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,33 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.registration; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.inject.spi.BeforeBeanDiscovery; | ||
import javax.enterprise.inject.spi.Extension; | ||
|
||
/** | ||
* An extension which registers a bean programmatically. | ||
* | ||
* @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a> | ||
*/ | ||
public class AnotherManualBeanRegistrationExtension implements Extension { | ||
public void registerBeans(@Observes BeforeBeanDiscovery event, BeanManager bm) { | ||
event.addAnnotatedType(bm.createAnnotatedType(AnotherBeanClassToRegister.class)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/jboss/seam/compat/registration/BeanClassToRegister.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,30 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.registration; | ||
|
||
/** | ||
* A valid bean class which will be registered manually using a CDI extension rather than auto-discovered by inclusion in a bean | ||
* archive. | ||
* | ||
* @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a> | ||
* @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a> | ||
*/ | ||
public class BeanClassToRegister { | ||
public boolean isInvokable() { | ||
return true; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...a/org/jboss/seam/compat/registration/BeanRegistrationByExtensionInNonBeanArchiveTest.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,61 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.compat.registration; | ||
|
||
import javax.enterprise.inject.spi.Extension; | ||
|
||
import org.jboss.arquillian.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.spec.JavaArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/** | ||
* Validates that a bean can be registered by an extension that resides in a non-bean archive. | ||
* | ||
* @see <a href="http://java.net/jira/browse/GLASSFISH-14808">GLASSFISH-14808</a> (resolved) | ||
* | ||
* @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a> | ||
* @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class BeanRegistrationByExtensionInNonBeanArchiveTest { | ||
@Deployment | ||
public static Archive<?> createTestArchive() { | ||
// Our non-bean archive with an extension | ||
JavaArchive jar1 = ShrinkWrap.create(JavaArchive.class, "a.jar") | ||
.addClasses(BeanClassToRegister.class, ManualBeanRegistrationExtension.class) | ||
.addAsServiceProvider(Extension.class, ManualBeanRegistrationExtension.class); | ||
|
||
// Web archive is necessary so that Arquillian can find the BeanManager | ||
return ShrinkWrap.create(WebArchive.class, "test.war").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") | ||
.addAsLibrary(jar1); | ||
} | ||
|
||
@Test | ||
public void shouldFindBeanReference(BeanClassToRegister bean) { | ||
assertThat(bean, is(notNullValue())); | ||
assertThat(bean.isInvokable(), equalTo(true)); | ||
} | ||
} |
Oops, something went wrong.