Author: rmannibucau
Date: Thu May 3 07:29:24 2012
New Revision: 1333331
URL: http://svn.apache.org/viewvc?rev=1333331&view=rev
Log:
adding a test checking ejb injections are done in jsf
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyEJB.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyManagedBean.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/JSFInjectionTest.java
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/dummy.xhtml
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyEJB.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyEJB.java?rev=1333331&view=auto
==============================================================================
---
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyEJB.java
(added)
+++
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyEJB.java
Thu May 3 07:29:24 2012
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.arquillian.tests.jsf;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class DummyEJB {
+ public String foo() {
+ return "foo";
+ }
+}
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyManagedBean.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyManagedBean.java?rev=1333331&view=auto
==============================================================================
---
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyManagedBean.java
(added)
+++
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/DummyManagedBean.java
Thu May 3 07:29:24 2012
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.arquillian.tests.jsf;
+
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+
+@ManagedBean
+public class DummyManagedBean {
+ @EJB
+ private DummyEJB ejb;
+
+ public String getFoo() {
+ return ejb.foo();
+ }
+}
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/JSFInjectionTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/JSFInjectionTest.java?rev=1333331&view=auto
==============================================================================
---
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/JSFInjectionTest.java
(added)
+++
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/java/org/apache/openejb/arquillian/tests/jsf/JSFInjectionTest.java
Thu May 3 07:29:24 2012
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.arquillian.tests.jsf;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class JSFInjectionTest {
+ @ArquillianResource
+ private URL url;
+
+ @Deployment
+ public static WebArchive getArchive() {
+ final WebAppDescriptor descriptor =
Descriptors.create(WebAppDescriptor.class)
+ .version("3.0");
+
+ return ShrinkWrap.create(WebArchive.class, "jsf-injection-test.war")
+ .addAsWebResource(new ClassLoaderAsset(
+
JSFInjectionTest.class.getPackage().getName().replace('.',
'/').concat("/").concat("dummy.xhtml")), "dummy.xhtml")
+ .addAsLibraries(JarLocation.jarLocation(Test.class)) // junit
+ .setWebXML(new StringAsset(descriptor.exportAsString()));
+ }
+
+ @Test
+ public void testProjectStage() throws Exception {
+ validateTest("foo");
+ }
+
+ private void validateTest(final String expectedOutput) throws IOException {
+ final InputStream is = new URL(url.toExternalForm() +
"dummy.xhtml").openStream();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ int bytesRead;
+ byte[] buffer = new byte[8192];
+ while ((bytesRead = is.read(buffer)) > -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+
+ is.close();
+ os.close();
+
+ String output = new String(os.toByteArray(), "UTF-8");
+ assertNotNull("Response shouldn't be null", output);
+ assertTrue("Output should contain: " + expectedOutput,
output.contains(expectedOutput));
+ }
+}
Added:
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/dummy.xhtml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/dummy.xhtml?rev=1333331&view=auto
==============================================================================
---
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/dummy.xhtml
(added)
+++
openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-tests/src/test/resources/org/apache/openejb/arquillian/tests/jsf/dummy.xhtml
Thu May 3 07:29:24 2012
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html">
+ <h:outputText value="#{dummyManagedBean.foo}"></h:outputText>
+</html>