[jboss-cvs] JBossAS SVN: r98898 - in projects/reloaded/trunk/naming/src: test/java/org/jboss/reloaded/naming/test/legacy/unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 23 05:53:15 EST 2009
Author: wolfc
Date: 2009-12-23 05:53:15 -0500 (Wed, 23 Dec 2009)
New Revision: 98898
Modified:
projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/AppObjectFactory.java
projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/ModuleObjectFactory.java
projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java
Log:
RELOADED-9: test legacy invocation on java:app and java:module
Modified: projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/AppObjectFactory.java
===================================================================
--- projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/AppObjectFactory.java 2009-12-23 09:25:45 UTC (rev 98897)
+++ projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/AppObjectFactory.java 2009-12-23 10:53:15 UTC (rev 98898)
@@ -28,10 +28,15 @@
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NamingException;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;
/**
+ * The AppObjectFactory is responsible for resolving java:app.
+ * Normally it's installed via the NameSpaces class.
+ *
+ * @see org.jboss.reloaded.naming.service.NameSpaces
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
public class AppObjectFactory implements ObjectFactory
@@ -44,13 +49,13 @@
if(current == null || !currentLegacyId.equals(ComponentObjectFactory.id(current)))
{
// do legacy resolution
- return null;
+ throw new NamingException("java:app not supported by legacy component " + currentLegacyId);
}
else
{
JavaEEApplication application = current.getModule().getApplication();
if(application == null)
- return null;
+ throw new NamingException("module " + current.getModule().getName() + " is not part of an application");
return application.getContext();
}
}
Modified: projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/ModuleObjectFactory.java
===================================================================
--- projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/ModuleObjectFactory.java 2009-12-23 09:25:45 UTC (rev 98897)
+++ projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/service/ModuleObjectFactory.java 2009-12-23 10:53:15 UTC (rev 98898)
@@ -27,6 +27,7 @@
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NamingException;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;
@@ -43,7 +44,7 @@
if(current == null || !currentLegacyId.equals(ComponentObjectFactory.id(current)))
{
// do legacy resolution
- return null;
+ throw new NamingException("java:module not supported by legacy component " + currentLegacyId);
}
else
{
Modified: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java 2009-12-23 09:25:45 UTC (rev 98897)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java 2009-12-23 10:53:15 UTC (rev 98898)
@@ -21,13 +21,7 @@
*/
package org.jboss.reloaded.naming.test.legacy.unit;
-import static junit.framework.Assert.assertEquals;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
import junit.framework.Assert;
-
import org.jboss.naming.ENCFactory;
import org.jboss.reloaded.naming.CurrentComponent;
import org.jboss.reloaded.naming.simple.SimpleJavaEEComponent;
@@ -38,6 +32,12 @@
import org.jboss.util.naming.Util;
import org.junit.Test;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
/**
* @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
* @version $Revision: $
@@ -70,8 +70,46 @@
ENCFactory.popContextId();
}
}
-
+
@Test
+ public void testLegacyCallingApp() throws NamingException
+ {
+ ENCFactory.pushContextId("legacy");
+ try
+ {
+ iniCtx.lookup("java:app/env/value");
+ fail("Expected NamingException");
+ }
+ catch(NamingException e)
+ {
+ // good
+ }
+ finally
+ {
+ ENCFactory.popContextId();
+ }
+ }
+
+ @Test
+ public void testLegacyCallingModule() throws NamingException
+ {
+ ENCFactory.pushContextId("legacy");
+ try
+ {
+ iniCtx.lookup("java:module/env/value");
+ fail("Expected NamingException");
+ }
+ catch(NamingException e)
+ {
+ // good
+ }
+ finally
+ {
+ ENCFactory.popContextId();
+ }
+ }
+
+ @Test
public void testLegacyCallingNew() throws NamingException
{
final String newValue = "testNewCallingLegacy new";
More information about the jboss-cvs-commits
mailing list