Skip to content

Commit

Permalink
Seam Compatibility tests - iteration 3 / CDITCK-230
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Oct 10, 2011
1 parent 2669cf7 commit 631337a
Show file tree
Hide file tree
Showing 21 changed files with 877 additions and 0 deletions.
@@ -0,0 +1,29 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import javax.inject.Inject;

public class BarBean {

@Inject
private BarExtension extension;

public BarExtension getExtension() {
return extension;
}
}
@@ -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.jsr299.tck.tests.deployment.packaging.ear;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;

public class BarExtension implements Extension {

public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
System.out.println("bar");
}
}
@@ -0,0 +1,34 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import javax.inject.Inject;

/**
*
* @author Martin Kouba
*/
public class BarWebBean {

@Inject
FooBean fooBean;

public void ping() {
fooBean.getExtension();
}

}
@@ -0,0 +1,29 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import javax.inject.Inject;

public class FooBean {

@Inject
private FooExtension extension;

public FooExtension getExtension() {
return extension;
}
}
@@ -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.jsr299.tck.tests.deployment.packaging.ear;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;

public class FooExtension implements Extension {

public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
System.out.println("foo");
}
}
@@ -0,0 +1,34 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import javax.inject.Inject;

/**
*
* @author Martin Kouba
*/
public class FooWebBean {

@Inject
FooBean fooBean;

public void ping() {
fooBean.getExtension();
}

}
@@ -0,0 +1,72 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.jsr299.tck.shrinkwrap.EnterpriseArchiveBuilder;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

/**
* This test verifies that multiple CDI-enabled web applications can be bundled inside of an enterprise archive (.ear)
*
* <p>
* This test was originally part of Seam Compatibility project.
* <p>
*
* TODO verify assertions
*
* @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a>
* @author Martin Kouba
* @see http://java.net/jira/browse/GLASSFISH-16303
*/
@SpecVersion(spec = "cdi", version = "20091101")
public class MultiWebAppTest extends SingleWebAppTest {

@Deployment(testable = false)
public static EnterpriseArchive createTestArchive() {

EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder().withTestClass(MultiWebAppTest.class).build();
StringAsset applicationXml = new StringAsset(Descriptors.create(ApplicationDescriptor.class).applicationName("Test")
.createModule().getOrCreateWeb().webUri("foo.war").contextRoot("/foo").up().up().createModule()
.getOrCreateWeb().webUri("bar.war").contextRoot("/bar").up().up().exportAsString());
enterpriseArchive.setApplicationXML(applicationXml);

WebArchive fooArchive = createWar("foo.war", createJar("foo.jar", FooExtension.class, FooBean.class));
fooArchive.addClass(FooWebBean.class);
enterpriseArchive.addAsModule(fooArchive);

WebArchive barArchive = createWar("bar.war", createJar("bar.jar", BarExtension.class, BarBean.class));
barArchive.addClass(BarWebBean.class);
enterpriseArchive.addAsModule(barArchive);

return enterpriseArchive;
}

@Test
@SpecAssertions({ @SpecAssertion(section = "12.1", id = "bbc"), @SpecAssertion(section = "12.1", id = "bbe") })
public void test() {
}

}
@@ -0,0 +1,89 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.ear;

import javax.enterprise.inject.spi.Extension;
import javax.inject.Inject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.shrinkwrap.EnterpriseArchiveBuilder;
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.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.application6.ApplicationDescriptor;
import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

/**
* This test verifies that a CDI extension can be used with a web application bundled inside of an enterprise archive (.ear)
*
* <p>
* This test was originally part of Seam Compatibility project.
* <p>
*
* TODO verify assertions
*
* @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a>
* @author Martin Kouba
* @see https://issues.jboss.org/browse/JBAS-8683
*/
@SpecVersion(spec = "cdi", version = "20091101")
public class SingleWebAppTest extends AbstractJSR299Test {

@Deployment
public static EnterpriseArchive createTestArchive() {

EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder().withTestClass(SingleWebAppTest.class).build();
StringAsset applicationXml = new StringAsset(Descriptors.create(ApplicationDescriptor.class).applicationName("Test")
.createModule().getOrCreateWeb().webUri("test.war").contextRoot("/test").up().up().exportAsString());
enterpriseArchive.setApplicationXML(applicationXml);

WebArchive webArchive = createWar("test.war", createJar("test.jar", FooExtension.class, FooBean.class));
webArchive.addClass(FooWebBean.class);

enterpriseArchive.addAsModule(webArchive);
return enterpriseArchive;
}

public static WebArchive createWar(String name, JavaArchive... libraries) {
StringAsset webXml = new StringAsset(Descriptors.create(WebAppDescriptor.class).exportAsString());
return ShrinkWrap.create(WebArchive.class, name).setWebXML(webXml)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml").addAsLibraries(libraries);
}

public static JavaArchive createJar(String name, Class<? extends Extension> extension, Class<?>... classes) {
return ShrinkWrap.create(JavaArchive.class, name).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addClasses(classes).addClass(extension).addAsServiceProvider(Extension.class, extension);
}

@Inject
FooWebBean fooWebBean;

@Test
@SpecAssertions({ @SpecAssertion(section = "12.1", id = "bbc"), @SpecAssertion(section = "12.1", id = "bbe") })
public void test() {
fooWebBean.ping();
}
}
@@ -0,0 +1,36 @@
/*
* 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.jsr299.tck.tests.deployment.packaging.visibility;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.inject.Qualifier;

@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface American {
}

0 comments on commit 631337a

Please sign in to comment.