[jboss-cvs] JBossAS SVN: r69606 - in trunk/testsuite: src/main/org/jboss/test/naming and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 5 02:24:44 EST 2008


Author: emuckenhuber
Date: 2008-02-05 02:24:44 -0500 (Tue, 05 Feb 2008)
New Revision: 69606

Added:
   trunk/testsuite/src/main/org/jboss/test/naming/factory/
   trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java
   trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java
   trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java
   trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java
   trunk/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java
   trunk/testsuite/src/resources/naming/services/externalcontext-service.xml
Modified:
   trunk/testsuite/imports/sections/naming.xml
Log:
[JBAS-5006]

Modified: trunk/testsuite/imports/sections/naming.xml
===================================================================
--- trunk/testsuite/imports/sections/naming.xml	2008-02-05 06:07:40 UTC (rev 69605)
+++ trunk/testsuite/imports/sections/naming.xml	2008-02-05 07:24:44 UTC (rev 69606)
@@ -106,6 +106,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>     
     
       <jar destfile="${build.lib}/naming-restart.sar">
          <zipfileset dir="${build.resources}/naming/restart"

Added: trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContext.java	2008-02-05 07:24:44 UTC (rev 69606)
@@ -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);
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/naming/factory/MockInitialContextFactory.java	2008-02-05 07:24:44 UTC (rev 69606)
@@ -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);
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingContext.java	2008-02-05 07:24:44 UTC (rev 69606)
@@ -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);
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/naming/factory/MockNamingEnumeration.java	2008-02-05 07:24:44 UTC (rev 69606)
@@ -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();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/naming/factory/SubMockNamingContext.java	2008-02-05 07:24:44 UTC (rev 69606)
@@ -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);
+   }
+
+}

Added: trunk/testsuite/src/resources/naming/services/externalcontext-service.xml
===================================================================
--- trunk/testsuite/src/resources/naming/services/externalcontext-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/naming/services/externalcontext-service.xml	2008-02-05 07:24:44 UTC (rev 69606)
@@ -0,0 +1,13 @@
+<?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>




More information about the jboss-cvs-commits mailing list