[jboss-svn-commits] JBL Code SVN: r14990 - labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 10 12:23:17 EDT 2007


Author: kevin.conner at jboss.com
Date: 2007-09-10 12:23:17 -0400 (Mon, 10 Sep 2007)
New Revision: 14990

Added:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockContext.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockInitialContextFactory.java
Modified:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java
Log:
Mocked out JNDI classes: JBESB-1014

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java	2007-09-10 14:17:00 UTC (rev 14989)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/AppServerContextUnitTest.java	2007-09-10 16:23:17 UTC (rev 14990)
@@ -38,10 +38,12 @@
 public class AppServerContextUnitTest extends TestCase {
 	
 	private Logger log = Logger.getLogger( AppServerContextUnitTest.class );
-	
+	final String initialContextFactory = MockInitialContextFactory.class.getName() ;
+        
 	public void test_AppServerContext() throws NamingException {
         Properties environment = new Properties();
         environment.setProperty(Context.PROVIDER_URL, "http://localhost:1234");
+        environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
         environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY);
         environment.setProperty(Context.URL_PKG_PREFIXES, NamingContext.JBOSS_URL_PKG_PREFIX);
         Context ctx = NamingContext.getServerContext(environment);
@@ -49,7 +51,7 @@
 		
 		Hashtable props = ctx.getEnvironment();
 		log.debug(props);
-		assertEquals("org.jnp.interfaces.NamingContextFactory", props.get(Context.INITIAL_CONTEXT_FACTORY));
+		assertEquals(initialContextFactory, props.get(Context.INITIAL_CONTEXT_FACTORY));
 		assertEquals("http://localhost:1234", props.get(Context.PROVIDER_URL));
 		
         ctx.close();

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockContext.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockContext.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockContext.java	2007-09-10 16:23:17 UTC (rev 14990)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.soa.esb.helpers;
+
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * Mock context used for AppServerContextUnitTest.
+ * This class contains no funtionality other than basic environment manipulation.
+ * @author kevin
+ */
+public class MockContext implements Context
+{
+    private final Hashtable<Object, Object> environment ;
+    
+    MockContext(final Hashtable<?, ?> environment)
+    {
+        this.environment = new Hashtable<Object, Object>(environment);
+    }
+    
+    public Object addToEnvironment(final String propName, final Object propVal)
+        throws NamingException
+    {
+        return environment.put(propName, propVal);
+    }
+
+    public void bind(final Name name, final Object obj)
+        throws NamingException
+    {
+    }
+
+    public void bind(final String name, final Object obj)
+        throws NamingException
+    {
+    }
+
+    public void close()
+        throws NamingException
+    {
+    }
+
+    public Name composeName(final Name name, final Name prefix)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public String composeName(final String name, final String prefix)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Context createSubcontext(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Context createSubcontext(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public void destroySubcontext(final Name name)
+        throws NamingException
+    {
+    }
+
+    public void destroySubcontext(final String name)
+        throws NamingException
+    {
+    }
+
+    public Hashtable<?, ?> getEnvironment()
+        throws NamingException
+    {
+        return environment ;
+    }
+
+    public String getNameInNamespace()
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NameParser getNameParser(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NameParser getNameParser(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NamingEnumeration<NameClassPair> list(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NamingEnumeration<NameClassPair> list(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NamingEnumeration<Binding> listBindings(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public NamingEnumeration<Binding> listBindings(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Object lookup(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Object lookup(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Object lookupLink(final Name name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public Object lookupLink(final String name)
+        throws NamingException
+    {
+        return null;
+    }
+
+    public void rebind(final Name name, final Object obj)
+        throws NamingException
+    {
+    }
+
+    public void rebind(final String name, final Object obj)
+        throws NamingException
+    {
+    }
+
+    public Object removeFromEnvironment(final String propName)
+        throws NamingException
+    {
+        return environment.remove(propName) ;
+    }
+
+    public void rename(final Name oldName, final Name newName)
+        throws NamingException
+    {
+    }
+
+    public void rename(final String oldName, final String newName)
+        throws NamingException
+    {
+    }
+
+    public void unbind(final Name name)
+        throws NamingException
+    {
+    }
+
+    public void unbind(final String name)
+        throws NamingException
+    {
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockContext.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockInitialContextFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockInitialContextFactory.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockInitialContextFactory.java	2007-09-10 16:23:17 UTC (rev 14990)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.soa.esb.helpers;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * Mock initial context factory used for AppServerContextUnitTest.
+ * @author kevin
+ */
+public class MockInitialContextFactory implements InitialContextFactory
+{
+    /**
+     * Get the initial context specified by the environment.
+     */
+    public Context getInitialContext(final Hashtable<?, ?> environment)
+            throws NamingException
+    {
+        return new MockContext(environment);
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/helpers/MockInitialContextFactory.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list