[jboss-cvs] JBossAS SVN: r60176 - in branches/JBoss_4_0_5_GA_CP/testsuite: src/main/org/jboss/test/naming and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 1 23:12:06 EST 2007


Author: scott.stark at jboss.org
Date: 2007-02-01 23:12:06 -0500 (Thu, 01 Feb 2007)
New Revision: 60176

Added:
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/resources/naming/services/externalcontext-service.xml
Modified:
   branches/JBoss_4_0_5_GA_CP/testsuite/imports/sections/naming.xml
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/test/ExternalContextUnitTestCase.java
Log:
ASPATCH-158, look to all superclass interfaces when creating the proxy

Modified: branches/JBoss_4_0_5_GA_CP/testsuite/imports/sections/naming.xml
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/imports/sections/naming.xml	2007-02-02 04:08:20 UTC (rev 60175)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/imports/sections/naming.xml	2007-02-02 04:12:06 UTC (rev 60176)
@@ -103,5 +103,17 @@
             <include name="org/jboss/test/naming/interceptors/*"/>
          </fileset>
       </jar>
+
+      <!-- ExternalContext sar -->
+      <jar destfile="${build.lib}/extcontext.sar">
+         <zipfileset dir="${build.resources}/naming/services"
+            fullpath="META-INF/jboss-service.xml">
+            <include name="externalcontext-service.xml"/>
+         </zipfileset>
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/naming/factory/*"/>
+         </fileset>
+      </jar>
+      
    </target>
 </project>

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,53 @@
+/*
+ * 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.naming.factory;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Test an InitialContext subclass
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MockInitialContext extends InitialContext
+{
+
+   public MockInitialContext() throws NamingException
+   {
+      super();
+   }
+
+   public MockInitialContext(boolean lazy) throws NamingException
+   {
+      super(lazy);
+   }
+
+   public MockInitialContext(Hashtable arg0) throws NamingException
+   {
+      super(arg0);
+   }
+
+}


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,46 @@
+/*
+ * 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.naming.factory;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * Factory to test the ExternContext
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MockInitialContextFactory
+   implements InitialContextFactory
+{
+
+   public Context getInitialContext(Hashtable env)
+      throws NamingException
+   {
+      return new SubMockNamingContext(env);
+   }
+
+}


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,202 @@
+/*
+ * 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.naming.factory;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MockNamingContext
+   implements Context
+{
+   private Hashtable env;
+   private HashMap bindings = new HashMap();
+
+   MockNamingContext(Hashtable env)
+   {
+      this.env = env;
+   }
+
+   public Object addToEnvironment(String name, Object value) throws NamingException
+   {
+      return env.put(name, value);
+   }
+
+   public void bind(Name name, Object obj) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public void bind(String name, Object obj) throws NamingException
+   {
+      bindings.put(name, obj);
+   }
+
+   public void close() throws NamingException
+   {      
+   }
+
+   public Name composeName(Name name, Name prefix) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public String composeName(String name, String prefix) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Context createSubcontext(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Context createSubcontext(String name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public void destroySubcontext(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public void destroySubcontext(String name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Hashtable getEnvironment() throws NamingException
+   {
+      return env;
+   }
+
+   public String getNameInNamespace() throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public NameParser getNameParser(Name name) throws NamingException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public NameParser getNameParser(String name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public NamingEnumeration list(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public NamingEnumeration list(String name) throws NamingException
+   {
+      return new MockNamingEnumeration(bindings.values().iterator());
+   }
+
+   public NamingEnumeration listBindings(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public NamingEnumeration listBindings(String name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Object lookup(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Object lookup(String name) throws NamingException
+   {
+      Object value = bindings.get(name);
+      if( value == null )
+         throw new NameNotFoundException(name);
+      return value;
+   }
+
+   public Object lookupLink(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public Object lookupLink(String name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");
+   }
+
+   public void rebind(Name name, Object obj) throws NamingException
+   {
+      throw new NamingException("Unsupported op");      
+   }
+
+   public void rebind(String name, Object obj) throws NamingException
+   {
+      bindings.put(name, obj);
+   }
+
+   public Object removeFromEnvironment(String name) throws NamingException
+   {
+      return env.remove(name);
+   }
+
+   public void rename(Name oldName, Name newName) throws NamingException
+   {
+      throw new NamingException("Unsupported op");      
+   }
+
+   public void rename(String oldName, String newName) throws NamingException
+   {
+      Object value = bindings.remove(oldName);
+      if( value == null )
+         throw new NameNotFoundException(oldName);
+      bindings.put(newName, value);
+   }
+
+   public void unbind(Name name) throws NamingException
+   {
+      throw new NamingException("Unsupported op");      
+   }
+
+   public void unbind(String name) throws NamingException
+   {
+      if( bindings.containsKey(name) == false )
+         throw new NameNotFoundException(name);
+      bindings.remove(name);
+   }
+
+}


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,69 @@
+/*
+ * 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.naming.factory;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MockNamingEnumeration
+   implements NamingEnumeration, Serializable
+{
+   private static final long serialVersionUID = 1;
+   private Iterator iter;
+
+   MockNamingEnumeration(Iterator iter)
+   {
+      this.iter = iter;
+   }
+
+   public void close() throws NamingException
+   {
+   }
+
+   public boolean hasMore() throws NamingException
+   {
+      return iter.hasNext();
+   }
+
+   public Object next() throws NamingException
+   {
+      return iter.next();
+   }
+
+   public boolean hasMoreElements()
+   {
+      return iter.hasNext();
+   }
+
+   public Object nextElement()
+   {
+      return iter.next();
+   }
+
+}


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,41 @@
+/*
+ * 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.naming.factory;
+
+import java.util.Hashtable;
+
+/**
+ * Subclass to test superclass interface resolution
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SubMockNamingContext
+   extends MockNamingContext
+{
+
+   public SubMockNamingContext(Hashtable env)
+   {
+      super(env);
+   }
+
+}


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Modified: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/test/ExternalContextUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/test/ExternalContextUnitTestCase.java	2007-02-02 04:08:20 UTC (rev 60175)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/naming/test/ExternalContextUnitTestCase.java	2007-02-02 04:12:06 UTC (rev 60176)
@@ -49,8 +49,8 @@
 java.naming.provider.url=file:/tmp
 
  *
- * @author    Scott_Stark at displayscape.com
- * @version   $Revision$
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
  */
 public class ExternalContextUnitTestCase extends JBossTestCase
 {
@@ -103,37 +103,24 @@
     */
    protected void setUp() throws Exception
    {
-      try
+      super.setUp();
+      super.redeploy("extcontext.sar");
+      contextNames = null;
+      ObjectName pattern = new ObjectName("*:service=ExternalContext,*");
+      Set names = getServer().queryMBeans(pattern, null);
+      Iterator iter = names.iterator();
+      ArrayList tmp = new ArrayList();
+      while (iter.hasNext())
       {
-         super.setUp();
-         contextNames = null;
-         ObjectName pattern = new ObjectName("*:service=ExternalContext,*");
-         Set names = getServer().queryMBeans(pattern, null);
-         Iterator iter = names.iterator();
-         ArrayList tmp = new ArrayList();
-         while (iter.hasNext())
-         {
-            ObjectInstance oi = (ObjectInstance)iter.next();
-            ObjectName name = oi.getObjectName();
-            getLog().debug(name);
-            tmp.add(name);
-         }
-         if (tmp.size() > 0)
-         {
-            contextNames = new ObjectName[tmp.size()];
-            tmp.toArray(contextNames);
-         }
+         ObjectInstance oi = (ObjectInstance)iter.next();
+         ObjectName name = oi.getObjectName();
+         getLog().debug(name);
+         tmp.add(name);
       }
-      catch (Exception x)
+      if (tmp.size() > 0)
       {
-         if (x instanceof RuntimeMBeanException)
-         {
-            getLog().error("setUp RuntimeMBeanException:",((RuntimeMBeanException)x).getTargetException());
-         }
-         else
-         {
-            getLog().error("setUp Error:" , x);
-         }
+         contextNames = new ObjectName[tmp.size()];
+         tmp.toArray(contextNames);
       }
    }
 

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/resources/naming/services/externalcontext-service.xml
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/resources/naming/services/externalcontext-service.xml	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/resources/naming/services/externalcontext-service.xml	2007-02-02 04:12:06 UTC (rev 60176)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean code="org.jboss.naming.ExternalContext" name="jboss.test:service=ExternalContext,jndiName=external/SubMockNamingContext">
+      <attribute name="JndiName">external/SubMockNamingContext</attribute>
+      <attribute name="InitialContext">org.jboss.test.naming.factory.MockInitialContext</attribute>
+      <attribute name="Properties">
+         # Dummy JNDI properties
+         java.naming.factory.initial=org.jboss.test.naming.factory.MockInitialContextFactory
+         java.naming.provider.url=http://www.jboss.org
+      </attribute>
+      <attribute name="RemoteAccess">true</attribute>
+   </mbean>
+</server>


Property changes on: branches/JBoss_4_0_5_GA_CP/testsuite/src/resources/naming/services/externalcontext-service.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list