[jboss-cvs] JBossAS SVN: r77432 - in trunk/testsuite: src/main/org/jboss/test/jsf and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 25 10:09:33 EDT 2008


Author: emuckenhuber
Date: 2008-08-25 10:09:33 -0400 (Mon, 25 Aug 2008)
New Revision: 77432

Added:
   trunk/testsuite/src/main/org/jboss/test/jsf/ejb/
   trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateful.java
   trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatefulBean.java
   trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateless.java
   trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatelessBean.java
   trunk/testsuite/src/main/org/jboss/test/jsf/managed/
   trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCAnnotationsManagedBean.java
   trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCTester.java
   trunk/testsuite/src/main/org/jboss/test/jsf/managed/SimpleManagedBean.java
   trunk/testsuite/src/main/org/jboss/test/web/test/JSFInjectionUnitTestCase.java
   trunk/testsuite/src/resources/web/jsfinjection/
   trunk/testsuite/src/resources/web/jsfinjection/META-INF/
   trunk/testsuite/src/resources/web/jsfinjection/META-INF/application.xml
   trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/
   trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/faces-config.xml
   trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/web.xml
   trunk/testsuite/src/resources/web/jsfinjection/enc.jsp
   trunk/testsuite/src/resources/web/jsfinjection/simple.jsp
Modified:
   trunk/testsuite/imports/sections/jsf.xml
Log:
[JBAS-4399] jsf injection testcase

Modified: trunk/testsuite/imports/sections/jsf.xml
===================================================================
--- trunk/testsuite/imports/sections/jsf.xml	2008-08-25 14:03:12 UTC (rev 77431)
+++ trunk/testsuite/imports/sections/jsf.xml	2008-08-25 14:09:33 UTC (rev 77432)
@@ -76,7 +76,36 @@
        </webinf>
   
      </war>
+   	
+    <jar destfile="${build.lib}/jbosstest-jsf-ejbs.jar">
+        <fileset dir="${build.classes}">
+           <include name="org/jboss/test/jsf/ejb/**"/>
+        </fileset>
+    </jar>
 
+    <war destfile="${build.lib}/jbosstest-jsf-injection.war"
+      webxml="${build.resources}/web/jsfinjection/WEB-INF/web.xml">
+      <fileset dir="${build.resources}/web/jsfinjection">
+        <include name="**/*.jsp"/>
+      </fileset>
+
+      <classes dir="${build.classes}">
+         <include name="org/jboss/test/jsf/managed/**"/>
+      </classes>
+
+      <webinf dir="${build.resources}/web/jsfinjection/WEB-INF">
+        <include name="**/*"/>
+      </webinf>
+    </war>
+   	
+    <ear earfile="${build.lib}/jbosstest-jsf-injection.ear"
+       appxml="${build.resources}/web/jsfinjection/META-INF/application.xml">
+       <fileset dir="${build.lib}">
+          <include name="jbosstest-jsf-ejbs.jar"/>
+       	  <include name="jbosstest-jsf-injection.war"/>
+       </fileset>
+    </ear>
+   	
    </target>
 
 </project>

Added: trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateful.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateful.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateful.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.ejb;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Remote
+public interface SimpleStateful
+{
+
+   boolean doSomething();
+   
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatefulBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatefulBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatefulBean.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.ejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateless(name = "SimpleStatefulBean", mappedName = "simpleStatefulMappedName")
+public class SimpleStatefulBean implements SimpleStateful
+{
+
+   public boolean doSomething()
+   {
+      // do something...
+      return true;
+   }
+   
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateless.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateless.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStateless.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.ejb;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Remote
+public interface SimpleStateless
+{
+   
+   boolean doSomething();
+
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatelessBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatelessBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/ejb/SimpleStatelessBean.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.ejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateless
+public class SimpleStatelessBean implements SimpleStateless
+{
+
+   public boolean doSomething()
+   {
+      return true;
+   }
+
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCAnnotationsManagedBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCAnnotationsManagedBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCAnnotationsManagedBean.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.managed;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.EJB;
+import javax.faces.FacesException;
+import javax.jms.Queue;
+import javax.jms.QueueConnectionFactory;
+import javax.sql.DataSource;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.web.mock.EntityHome;
+import org.jboss.test.web.mock.StatelessSessionHome;
+import org.jboss.test.web.mock.StatelessSessionLocalHome;
+
+/**
+ * Tests of a managed bean for java:comp/env jndi settings and resource injection specified via javaee5 annotations.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Resources({
+   @Resource(name="mail/DefaultMail", type=javax.mail.Session.class, mappedName="java:/Mail"),
+   @Resource(name="mdr/ConsumesLink", type=javax.jms.Queue.class, mappedName="MockQueueA"),
+   @Resource(name="mdr/ProducesLink", type=javax.jms.Topic.class, mappedName="MockTopicA")
+})
+public class ENCAnnotationsManagedBean
+{
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(ENCAnnotationsManagedBean.class);
+
+   @Resource(name="jms/QueFactory", mappedName="java:/ConnectionFactory")
+   QueueConnectionFactory queueFactory;
+   @Resource(name="TestQueue", mappedName="MockQueueB")
+   Queue testQueue;
+   @Resource(name="mdr/ConsumesProducesJNDIName", mappedName="MockQueueA")
+   Queue refQueue;
+
+   @Resource(name="jdbc/DefaultDS", mappedName="java:/MockDS")
+   DataSource ds;
+   @EJB(name="ejb/bean3", beanInterface=StatelessSessionHome.class, 
+         mappedName="jbosstest/ejbs/UnsecuredEJB")
+   StatelessSessionHome sshome;
+   @EJB(name="ejb/CtsBmp", beanInterface=EntityHome.class, 
+         mappedName="jbosstest/ejbs/CtsBmp")
+   EntityHome entityHome;
+   @EJB(name="ejb/local/bean3", beanInterface=StatelessSessionLocalHome.class, 
+         mappedName="jbosstest/ejbs/local/ENCBean1")
+   StatelessSessionLocalHome localHome;
+
+   @Resource(name="url/JBossHome", mappedName="http://www.jboss.org")
+   java.net.URL url;
+
+   @Resource(name="Ints/i0", mappedName="0")
+   Integer i0;
+   @Resource(name="Ints/i1", mappedName="1")
+   Integer i1;
+   @Resource(name="Floats/f0", mappedName="0.0")
+   Float f0;
+   @Resource(name="Floats/f1", mappedName="1.1")
+   Float f1;
+   @Resource(name="Strings/s0", mappedName="String0")
+   String s0;
+   @Resource(name="Strings/s1", mappedName="String1")
+   String s1;
+   @Resource(name="ejb/catalog/CatalogDAOClass", mappedName="com.sun.model.dao.CatalogDAOImpl")
+   String ejbName;
+   
+   public boolean getTest()
+   {
+      ENCTester tester = new ENCTester(log);
+      tester.testENC();
+
+      if( queueFactory == null )
+         throw new FacesException("queueFactory is not injected");
+      if( testQueue == null )
+         throw new FacesException("testQueue is not injected");
+      if( testQueue == null )
+         throw new FacesException("testQueue is not injected");
+      if(url == null)
+         throw new FacesException("url is not injected");
+      
+      return true;
+   }
+   
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCTester.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/managed/ENCTester.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.jsf.managed;
+
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Topic;
+import javax.mail.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.web.mock.EntityHome;
+import org.jboss.test.web.mock.StatelessSessionHome;
+import org.jboss.test.web.mock.StatelessSessionLocalHome;
+
+/**
+ * A common test bean used by the enc servlets to validate their enc configuration.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 58438 $
+ */
+public class ENCTester
+{
+   private Logger log;
+   ENCTester(Logger log)
+   {
+      this.log = log;
+   }
+
+   void testENC() throws FacesException
+   {
+      try
+      {
+         // Obtain the environment naming context.
+         Context initCtx = new InitialContext();
+         Hashtable env = initCtx.getEnvironment();
+         Iterator keys = env.keySet().iterator();
+         log.info("InitialContext.env:");
+         while( keys.hasNext() )
+         {
+            Object key = keys.next();
+            log.info("Key: "+key+", value: "+env.get(key));
+         }
+         Context myEnv = (Context) initCtx.lookup("java:comp/env");
+         testEjbRefs(initCtx, myEnv);
+         testJdbcDataSource(initCtx, myEnv);
+         testMail(initCtx, myEnv);
+         testJMS(initCtx, myEnv);
+         testURL(initCtx, myEnv);
+         testEnvEntries(initCtx, myEnv);
+         testMessageDestinationRefs(initCtx, myEnv);
+      }
+      catch (NamingException e)
+      {
+         log.debug("Lookup failed", e);
+         throw new FacesException("Lookup failed, ENC tests failed", e);
+      }
+      catch (JMSException e)
+      {
+         log.debug("JMS access failed", e);
+         throw new FacesException("JMS access failed, ENC tests failed", e);
+      }
+      catch (RuntimeException e)
+      {
+         log.debug("Runtime error", e);
+         throw new FacesException("Runtime error, ENC tests failed", e);
+      }
+   }
+
+   private void testEnvEntries(Context initCtx, Context myEnv) throws NamingException
+   {
+      // Basic env values
+      Integer i = (Integer) myEnv.lookup("Ints/i0");
+      log.debug("Ints/i0 = " + i);
+      i = (Integer) initCtx.lookup("java:comp/env/Ints/i1");
+      log.debug("Ints/i1 = " + i);
+      Float f = (Float) myEnv.lookup("Floats/f0");
+      log.debug("Floats/f0 = " + f);
+      f = (Float) initCtx.lookup("java:comp/env/Floats/f1");
+      log.debug("Floats/f1 = " + f);
+      String s = (String) myEnv.lookup("Strings/s0");
+      log.debug("Strings/s0 = " + s);
+      s = (String) initCtx.lookup("java:comp/env/Strings/s1");
+      log.debug("Strings/s1 = " + s);
+      s = (String) initCtx.lookup("java:comp/env/ejb/catalog/CatalogDAOClass");
+      log.debug("ejb/catalog/CatalogDAOClass = " + s);
+   }
+
+   private void testEjbRefs(Context initCtx, Context myEnv) throws NamingException
+   {
+      //do lookup on bean specified without ejb-link
+      Object ejb = initCtx.lookup("java:comp/env/ejb/bean3");
+      if ((ejb instanceof StatelessSessionHome) == false)
+         throw new NamingException("ejb/bean3 is not a StatelessSessionHome");
+      log.debug("ejb/bean3 = " + ejb);
+
+
+      ejb = initCtx.lookup("java:comp/env/ejb/CtsBmp");
+      if ((ejb instanceof EntityHome) == false)
+         throw new NamingException("ejb/CtsBmp is not a EntityHome");
+
+      //lookup of local-ejb-ref bean specified without ejb-link
+      ejb = initCtx.lookup("java:comp/env/ejb/local/bean3");
+      if ((ejb instanceof StatelessSessionLocalHome) == false)
+         throw new NamingException("ejb/local/bean3 is not a StatelessSessionLocalHome");
+      log.debug("ejb/local/bean3 = " + ejb);
+   }
+
+   private void testJdbcDataSource(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JDBC DataSource
+      DataSource ds = (DataSource) myEnv.lookup("jdbc/DefaultDS");
+      log.debug("jdbc/DefaultDS = " + ds);
+   }
+
+   private void testMail(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JavaMail Session
+      Session session = (Session) myEnv.lookup("mail/DefaultMail");
+      log.debug("mail/DefaultMail = " + session);
+   }
+
+   private void testJMS(Context initCtx, Context myEnv) throws NamingException
+   {
+      // JavaMail Session
+      QueueConnectionFactory qf = (QueueConnectionFactory) myEnv.lookup("jms/QueFactory");
+      log.debug("jms/QueFactory = " + qf);
+   }
+
+   private void testURL(Context initCtx, Context myEnv) throws NamingException
+   {
+      // URLs
+      URL home1 = (URL) myEnv.lookup("url/JBossHome");
+      log.debug("url/JBossHome = " + home1);
+      URL home2 = (URL) initCtx.lookup("java:comp/env/url/JBossHome");
+      log.debug("url/JBossHome = " + home2);
+      if( home1.equals(home2) == false )
+         throw new NamingException("url/JBossHome != java:comp/env/url/JBossHome");
+   }
+
+   private void testMessageDestinationRefs(Context initCtx, Context myEnv) throws NamingException, JMSException
+   {
+      Object obj = myEnv.lookup("mdr/ConsumesLink");
+      log.debug("mdr/ConsumesLink = " + obj);
+      if ((obj instanceof Queue) == false)
+         throw new RuntimeException("mdr/ConsumesLink is not a javax.jms.Queue");
+      Queue queue = (Queue) obj;
+      if ("QUEUE.testQueue".equals(queue.getQueueName()))
+         throw new RuntimeException("Excepted QUEUE.testQueue, got " + queue);
+      
+      obj = myEnv.lookup("mdr/ProducesLink");
+      log.debug("mdr/ProducesLink = " + obj);
+      if ((obj instanceof Topic) == false)
+         throw new RuntimeException("mdr/ProducesLink is not a javax.jms.Topic");
+      Topic topic = (Topic) obj;
+      if ("TOPIC.testTopic".equals(topic.getTopicName()))
+         throw new RuntimeException("Excepted TOPIC.testTopic got " + topic);
+
+      obj = myEnv.lookup("mdr/ConsumesProducesJNDIName");
+      log.debug("mdr/ConsumesProducesJNDIName = " + obj);
+      if ((obj instanceof Queue) == false)
+         throw new RuntimeException("mdr/ConsumesProducesJNDIName is not a javax.jms.Queue");
+      queue = (Queue) obj;
+      if ("QUEUE.A".equals(queue.getQueueName()))
+         throw new RuntimeException("Excepted QUEUE.A, got " + queue);
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/jsf/managed/SimpleManagedBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jsf/managed/SimpleManagedBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jsf/managed/SimpleManagedBean.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.jsf.managed;
+
+import java.net.URL;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.faces.FacesException;
+
+import org.jboss.test.jsf.ejb.SimpleStateful;
+import org.jboss.test.jsf.ejb.SimpleStateless;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class SimpleManagedBean
+{
+
+   @EJB(mappedName = "simpleStatefulMappedName")
+   private SimpleStateful simpleStateful;
+   
+   @EJB
+   private SimpleStateless simplestateless;
+   
+   @Resource(name = "url/Injection", mappedName = "http://jboss.org")
+   private java.net.URL url;
+   
+   /**
+    * Test the injection of a simple stateless Bean with a mappedName
+    * 
+    * @throws Exception
+    */
+   public boolean getTestStatelessBean() throws Exception
+   {
+      if(simplestateless == null)
+         throw new FacesException("stateless bean in null.");
+      
+      return simplestateless.doSomething();
+   }
+   
+   public boolean getTestStatefulBean() throws Exception
+   {
+      if(simpleStateful == null)
+         throw new FacesException("stateful bean in null.");
+      
+      return simpleStateful.doSomething();      
+   }
+   
+   /**
+    * Test a url resource injection
+    * 
+    * @throws Exception
+    */
+   public boolean getTestURL() throws Exception
+   {
+      if(url == null)
+         throw new FacesException("url is null.");
+      
+      URL url = new URL("http://jboss.org");
+      if(! url.equals(this.url))
+         throw new FacesException("url mismatch.");
+      
+      return true;
+   }
+   
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/web/test/JSFInjectionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/JSFInjectionUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/JSFInjectionUnitTestCase.java	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.web.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.web.HttpUtils;
+
+/**
+ * JBAS-4399. Test correct injection into a JSF managed beans.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JSFInjectionUnitTestCase extends JBossTestCase
+{
+
+   private String baseURL = HttpUtils.getBaseURL(); 
+   
+   public JSFInjectionUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testSimpleJSF() throws Exception
+   {
+      URL url = new URL(baseURL+"jsfinjection/simple.jsf");
+      HttpUtils.accessURL(url);
+   }
+   
+   public void testENCJSF() throws Exception
+   {
+      URL url = new URL(baseURL+"jsfinjection/enc.jsf");
+      HttpUtils.accessURL(url);
+   }
+   
+   /**
+    * Setup the test suite.
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(JSFInjectionUnitTestCase.class, "simple-mock.beans,jbosstest-jsf-injection.ear");
+   }
+
+
+   
+}
+

Added: trunk/testsuite/src/resources/web/jsfinjection/META-INF/application.xml
===================================================================
--- trunk/testsuite/src/resources/web/jsfinjection/META-INF/application.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/jsfinjection/META-INF/application.xml	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE application PUBLIC
+   "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+   "http://java.sun.com/dtd/application_1_3.dtd">
+
+<application>
+    <display-name>JBossTest Web JSF Injection</display-name>
+
+	<module>
+	    <ejb>jbosstest-jsf-ejbs.jar</ejb>
+	</module>
+    <module>
+	    <web>
+	        <web-uri>jbosstest-jsf-injection.war</web-uri>
+	        <context-root>/jsfinjection</context-root>
+	    </web>
+    </module>
+</application>
+

Added: trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/faces-config.xml
===================================================================
--- trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/faces-config.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/faces-config.xml	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+              version="1.2">
+              
+   <managed-bean> 
+      <description>simple managed bean</description>
+      <managed-bean-name>simpleManagedBean</managed-bean-name>
+      <managed-bean-class>org.jboss.test.jsf.managed.SimpleManagedBean</managed-bean-class> 
+      <managed-bean-scope>request</managed-bean-scope> 
+   </managed-bean>
+      <managed-bean> 
+      <description>enc bean</description>
+      <managed-bean-name>encBean</managed-bean-name>
+      <managed-bean-class>org.jboss.test.jsf.managed.ENCAnnotationsManagedBean</managed-bean-class> 
+      <managed-bean-scope>request</managed-bean-scope> 
+   </managed-bean>
+   
+</faces-config>
\ No newline at end of file

Added: trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/web.xml
===================================================================
--- trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/web.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/web/jsfinjection/WEB-INF/web.xml	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
+
+	<servlet>
+		<servlet-name>javax.faces.FacesServlet</servlet-name>
+		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+		<load-on-startup>0</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>javax.faces.FacesServlet</servlet-name>
+		<url-pattern>*.jsf</url-pattern>
+	</servlet-mapping>
+	
+	<login-config>
+		<auth-method>BASIC</auth-method>
+	</login-config>
+</web-app>

Added: trunk/testsuite/src/resources/web/jsfinjection/enc.jsp
===================================================================
--- trunk/testsuite/src/resources/web/jsfinjection/enc.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/web/jsfinjection/enc.jsp	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,18 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@page import="org.jboss.test.jsf.webapp.*" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>JBoss JSF Injection Test</title>
+    </head>
+    <body>
+    <f:view>
+    	<h:outputText rendered="#{encBean.test}" value="tests passed." />
+    </f:view>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/testsuite/src/resources/web/jsfinjection/simple.jsp
===================================================================
--- trunk/testsuite/src/resources/web/jsfinjection/simple.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/web/jsfinjection/simple.jsp	2008-08-25 14:09:33 UTC (rev 77432)
@@ -0,0 +1,22 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@page import="org.jboss.test.jsf.webapp.*" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>JBoss JSF Injection Test</title>
+    </head>
+    <body>
+    <f:view>
+        <h:outputText rendered="#{simpleManagedBean.testStatefulBean}" value="testStatefulBean is ok" />
+    	<br/>
+    	<h:outputText rendered="#{simpleManagedBean.testStatelessBean}" value="testStatelessBean is ok" />
+    	<br/>
+    	<h:outputText rendered="#{simpleManagedBean.testURL}" value="testURL is ok" />
+    </f:view>
+    </body>
+</html>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list