1 22 package org.jboss.test.web.servlets; 23 24 import java.io.IOException ; 25 import java.io.PrintWriter ; 26 import java.util.Date ; 27 28 import javax.annotation.Resource; 29 import javax.annotation.Resources; 30 import javax.ejb.EJB ; 31 import javax.jms.Queue ; 32 import javax.jms.QueueConnectionFactory ; 33 import javax.servlet.ServletException ; 34 import javax.servlet.http.HttpServlet ; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 37 import javax.sql.DataSource ; 38 39 import org.jboss.logging.Logger; 40 import org.jboss.test.web.mock.EntityHome; 41 import org.jboss.test.web.mock.StatelessSessionHome; 42 import org.jboss.test.web.mock.StatelessSessionLocalHome; 43 44 51 @Resources({ 52 @Resource(name="mail/DefaultMail", type=javax.mail.Session .class, mappedName="java:/Mail"), 53 @Resource(name="url/JBossHome", type=java.net.URL .class, mappedName="http://www.jboss.org"), 54 @Resource(name="mdr/ConsumesLink", type=javax.jms.Queue .class, mappedName="MockQueueA"), 55 @Resource(name="mdr/ProducesLink", type=javax.jms.Topic .class, mappedName="MockTopicA") 56 }) 57 public class StandaloneENCAnnotationsServlet extends HttpServlet 58 { 59 private static final long serialVersionUID = 1; 60 private static final Logger log = Logger.getLogger(StandaloneENCAnnotationsServlet.class); 61 62 @Resource(name="jms/QueFactory", mappedName="java:/ConnectionFactory") 63 QueueConnectionFactory queueFactory; 64 @Resource(name="TestQueue", mappedName="MockQueueB") 65 Queue testQueue; 66 @Resource(name="mdr/ConsumesProducesJNDIName", mappedName="MockQueueA") 67 Queue refQueue; 68 69 @Resource(name="jdbc/DefaultDS", mappedName="java:/MockDS") 70 DataSource ds; 71 @EJB (name="ejb/bean3", beanInterface=StatelessSessionHome.class, 72 mappedName="jbosstest/ejbs/UnsecuredEJB") 73 StatelessSessionHome sshome; 74 @EJB (name="ejb/CtsBmp", beanInterface=EntityHome.class, 75 mappedName="jbosstest/ejbs/CtsBmp") 76 EntityHome entityHome; 77 @EJB (name="ejb/local/bean3", beanInterface=StatelessSessionLocalHome.class, 78 mappedName="jbosstest/ejbs/local/ENCBean1") 79 StatelessSessionLocalHome localHome; 80 @Resource(name="Ints/i0", mappedName="0") 81 int i0; 82 @Resource(name="Ints/i1", mappedName="1") 83 int i1; 84 @Resource(name="Floats/f0", mappedName="0.0") 85 float f0; 86 @Resource(name="Floats/f1", mappedName="1.1") 87 float f1; 88 @Resource(name="Strings/s0", mappedName="String0") 89 String s0; 90 @Resource(name="Strings/s1", mappedName="String1") 91 String s1; 92 @Resource(name="ejb/catalog/CatalogDAOClass", mappedName="com.sun.model.dao.CatalogDAOImpl") 93 String ejbName; 94 95 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 96 throws ServletException , IOException 97 { 98 ENCTester tester = new ENCTester(log); 99 tester.testENC(); 100 101 if( queueFactory == null ) 102 throw new ServletException ("queueFactory is not injected"); 103 if( testQueue == null ) 104 throw new ServletException ("testQueue is not injected"); 105 if( testQueue == null ) 106 throw new ServletException ("testQueue is not injected"); 107 108 response.setContentType("text/html"); 109 PrintWriter out = response.getWriter(); 110 out.println("<html>"); 111 out.println("<head><title>StandaloneENCAnnotationsServlet</title></head>"); 112 out.println("<body>Tests passed<br>Time:" + new Date () + "</body>"); 113 out.println("</html>"); 114 out.close(); 115 } 116 117 protected void doGet(HttpServletRequest request, HttpServletResponse response) 118 throws ServletException , IOException 119 { 120 processRequest(request, response); 121 } 122 123 protected void doPost(HttpServletRequest request, HttpServletResponse response) 124 throws ServletException , IOException 125 { 126 processRequest(request, response); 127 } 128 129 } 130 | Popular Tags |