geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viol...@apache.org
Subject svn commit: r1083682 - in /geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service: mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/ mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/
Date Mon, 21 Mar 2011 06:18:38 GMT
Author: violalu
Date: Mon Mar 21 06:18:38 2011
New Revision: 1083682

URL: http://svn.apache.org/viewvc?rev=1083682&view=rev
Log:
Update aries-testsuite/mail-osgi-service testcase.

Modified:
    geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/MailTest.java
    geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/MailServlet.java

Modified: geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/MailTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/MailTest.java?rev=1083682&r1=1083681&r2=1083682&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/MailTest.java
(original)
+++ geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-eba/src/test/java/org/apache/geronimo/testsuite/aries/mail/test/MailTest.java
Mon Mar 21 06:18:38 2011
@@ -42,8 +42,8 @@ public class MailTest extends TestSuppor
         URL url = new URL(baseURL + warName + address);
        
         String reply = doGET(url, 6, 10 * 1000);
-        assertTrue("Lookup Mail via osgi:service", 
-                   reply.contains("Java Mail JNDI Lookup via osgi:service Pass"));
+        assertTrue("Lookup Mail via ger:service", 
+                   reply.contains("Java Mail JNDI Lookup via ger:MailSession Pass"));
         
         
         

Modified: geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/MailServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/MailServlet.java?rev=1083682&r1=1083681&r2=1083682&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/MailServlet.java
(original)
+++ geronimo/server/trunk/testsuite/aries-testsuite/mail-osgi-service/mail-wab/src/main/java/org/apache/geronimo/testsuite/aries/mail/web/MailServlet.java
Mon Mar 21 06:18:38 2011
@@ -18,24 +18,14 @@ package org.apache.geronimo.testsuite.ar
 
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.*;
 
 import java.io.PrintWriter;
 import java.io.IOException;
-import java.util.Properties;
-
 import javax.servlet.annotation.WebServlet;
 
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
 import javax.mail.Session;
-import org.apache.geronimo.resource.mail.MailGBean;
-
 /**
  * Call Java Mail Session via osgi:service
  *
@@ -43,17 +33,7 @@ import org.apache.geronimo.resource.mail
 @WebServlet("/mailservlet")
 public class MailServlet extends HttpServlet
 {
-    private ServletContext sc;
-    private BundleContext bundleContext;
-    private static final String OSGI_SERVICE_PREFIX = "osgi:service/";
-    
-    /**
-     * @see Servlet#init(ServletConfig)
-     */
-    public void init(ServletConfig config) throws ServletException {
-       sc = config.getServletContext();       
-    }
-    
+           
     /**
      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
      */
@@ -72,54 +52,21 @@ public class MailServlet extends HttpSer
         PrintWriter pw = null;
         try {
            pw = response.getWriter();
-            /*bundleContext = (BundleContext) sc.getAttribute("osgi-bundlecontext");
-            ServiceReference sr = bundleContext.getServiceReference(MailGBean.class.getName());
-            if (sr != null) {
-                MailGBean sm = (MailGBean) bundleContext.getService(sr);
-                if (sm != null){
-                    pw.println("Java Mail JNDI Lookup via osgi:service Pass"); 
-                }else {
-                    pw.println("Java Mail JNDI Lookup via osgi:service Fail"); 
-                }                
-                bundleContext.ungetService(sr);
-            }*/
-            
-            //JNDI Lookup via osgi:service  , MailGBean jndi name is on to-do list      
  
-            Session mailSession = (Session) getOSGIService("mail/MailSession",null);
+           InitialContext ic = new InitialContext();
+           
+           Session mailSession = (Session) ic.lookup("ger:MailSession");
             if (mailSession != null){               
-                pw.println("Java Mail JNDI Lookup via osgi:service Pass" ); 
+                pw.println("Java Mail JNDI Lookup via ger:MailSession Pass" ); 
             } else {
-                pw.println("Java Mail JNDI Lookup via osgi:service Fail"); 
+                pw.println("Java Mail JNDI Lookup via ger:MailSession Fail"); 
             }
-            
-          
            
         } catch (IOException e) {
             // TODO Auto-generated catch block
-            pw.println(e.toString());
-            e.printStackTrace();
-        } 
-        
-    }   
-    /**
-     * Lookup and return an osgi service
-     * 
-     * @return Object
-     * 
-     */
-    public static final Object getOSGIService(String serviceName, String filter) {
-        
-        String name = OSGI_SERVICE_PREFIX + serviceName;
-        if (filter != null) {
-            name = name + "/" + filter;
-        }
-
-        try {
-            InitialContext ic = new InitialContext();
-            return ic.lookup(name);
-        } catch (NamingException e) {            
-            e.printStackTrace();
-            return null;
+            pw.println(e.toString());            
+        } catch (NamingException e){
+          pw.println(e.toString());
         }
+        
     }
 }
\ No newline at end of file



Mime
View raw message