Fix for #308858 (Update test suite to JUnit4 - Module jetty-plus).
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1754 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
8f6bde3ccd
commit
2a37d805b3
|
@ -7,6 +7,7 @@ jetty-7.1.1-SNAPSHOT
|
||||||
+ 308853 Update test suite to JUnit4 - Module jetty-deploy
|
+ 308853 Update test suite to JUnit4 - Module jetty-deploy
|
||||||
+ 308854 Update test suite to JUnit4 - Module jetty-http
|
+ 308854 Update test suite to JUnit4 - Module jetty-http
|
||||||
+ 308859 Update test suite to JUnit4 - Module jetty-policy
|
+ 308859 Update test suite to JUnit4 - Module jetty-policy
|
||||||
|
+ 308858 Update test suite to JUnit4 - Module jetty-plus
|
||||||
|
|
||||||
jetty-7.1.0 5 May 2010
|
jetty-7.1.0 5 May 2010
|
||||||
+ 306353 fixed cross context dispatch to root context.
|
+ 306353 fixed cross context dispatch to root context.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!--
|
<!--
|
||||||
COMMENTED OUT UNTIL CORRECT CONFIG IS FOUND FOR Export uses clauses
|
COMMENTED OUT UNTIL CORRECT CONFIG IS FOUND FOR Export uses clauses
|
||||||
-->
|
-->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -79,6 +79,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit4-version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -4,19 +4,17 @@
|
||||||
// All rights reserved. This program and the accompanying materials
|
// All rights reserved. This program and the accompanying materials
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
// The Eclipse Public License is available at
|
// The Eclipse Public License is available at
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
// The Apache License v2.0 is available at
|
// The Apache License v2.0 is available at
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
||||||
package org.eclipse.jetty.plus.jndi;
|
package org.eclipse.jetty.plus.jndi;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.Name;
|
import javax.naming.Name;
|
||||||
|
@ -27,138 +25,110 @@ import javax.naming.Referenceable;
|
||||||
import javax.naming.StringRefAddr;
|
import javax.naming.StringRefAddr;
|
||||||
import javax.naming.spi.ObjectFactory;
|
import javax.naming.spi.ObjectFactory;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestEnvEntry
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TestNamingEntries extends TestCase
|
public class TestNamingEntries
|
||||||
{
|
{
|
||||||
public class ScopeA extends Object
|
public class ScopeA
|
||||||
{
|
{
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return this.getClass().getName()+"@"+super.hashCode();
|
return this.getClass().getName()+"@"+super.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScopeB extends ScopeA
|
public class ScopeB extends ScopeA
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class SomeObject
|
public static class SomeObject
|
||||||
{
|
{
|
||||||
private int value;
|
private int value;
|
||||||
public SomeObject (int value)
|
public SomeObject (int value)
|
||||||
{this.value = value;}
|
{this.value = value;}
|
||||||
|
|
||||||
public int getValue ()
|
public int getValue ()
|
||||||
{
|
{
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SomeObjectFactory implements ObjectFactory
|
public static class SomeObjectFactory implements ObjectFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
public SomeObjectFactory()
|
public SomeObjectFactory()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
|
|
||||||
* @param arg0
|
|
||||||
* @param arg1
|
|
||||||
* @param arg2
|
|
||||||
* @param arg3
|
|
||||||
* @return the object instance
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
|
public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
|
||||||
{
|
{
|
||||||
Reference ref = (Reference)arg0;
|
Reference ref = (Reference)arg0;
|
||||||
|
|
||||||
RefAddr refAddr = ref.get(0);
|
RefAddr refAddr = ref.get(0);
|
||||||
String valueName = refAddr.getType();
|
String valueName = refAddr.getType();
|
||||||
if (!valueName.equalsIgnoreCase("val"))
|
if (!valueName.equalsIgnoreCase("val"))
|
||||||
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
|
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
|
||||||
|
|
||||||
String value = (String)refAddr.getContent();
|
String value = (String)refAddr.getContent();
|
||||||
|
|
||||||
return new SomeObject(Integer.parseInt(value.trim()));
|
return new SomeObject(Integer.parseInt(value.trim()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SomeOtherObject extends SomeObject implements Referenceable
|
public static class SomeOtherObject extends SomeObject implements Referenceable
|
||||||
{
|
{
|
||||||
|
|
||||||
private String svalue;
|
|
||||||
public SomeOtherObject (String value)
|
public SomeOtherObject (String value)
|
||||||
{
|
{
|
||||||
super(Integer.parseInt(value.trim()));
|
super(Integer.parseInt(value.trim()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see javax.naming.Referenceable#getReference()
|
|
||||||
* @return the reference
|
|
||||||
* @throws NamingException
|
|
||||||
*/
|
|
||||||
public Reference getReference() throws NamingException
|
public Reference getReference() throws NamingException
|
||||||
{
|
{
|
||||||
RefAddr refAddr = new StringRefAddr("val", String.valueOf(getValue()));
|
RefAddr refAddr = new StringRefAddr("val", String.valueOf(getValue()));
|
||||||
Reference ref = new Reference(SomeOtherObject.class.getName(), refAddr, SomeOtherObjectFactory.class.getName(), null);
|
return new Reference(SomeOtherObject.class.getName(), refAddr, SomeOtherObjectFactory.class.getName(), null);
|
||||||
return ref;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SomeOtherObjectFactory implements ObjectFactory
|
public static class SomeOtherObjectFactory implements ObjectFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
public SomeOtherObjectFactory()
|
public SomeOtherObjectFactory()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
|
|
||||||
* @param arg0
|
|
||||||
* @param arg1
|
|
||||||
* @param arg2
|
|
||||||
* @param arg3
|
|
||||||
* @return the object instance
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
|
public Object getObjectInstance(Object arg0, Name arg1, Context arg2, Hashtable arg3) throws Exception
|
||||||
{
|
{
|
||||||
Reference ref = (Reference)arg0;
|
Reference ref = (Reference)arg0;
|
||||||
|
|
||||||
RefAddr refAddr = ref.get(0);
|
RefAddr refAddr = ref.get(0);
|
||||||
String valueName = refAddr.getType();
|
String valueName = refAddr.getType();
|
||||||
if (!valueName.equalsIgnoreCase("val"))
|
if (!valueName.equalsIgnoreCase("val"))
|
||||||
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
|
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
|
||||||
|
|
||||||
String value = (String)refAddr.getContent();
|
String value = (String)refAddr.getContent();
|
||||||
|
|
||||||
return new SomeOtherObject(value.trim());
|
return new SomeOtherObject(value.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SomeObject someObject;
|
||||||
public SomeObject someObject;
|
|
||||||
|
@Before
|
||||||
public void setUp ()
|
public void init()
|
||||||
{
|
{
|
||||||
this.someObject = new SomeObject(4);
|
this.someObject = new SomeObject(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnvEntryNoScope ()
|
@Test
|
||||||
throws Exception
|
public void testEnvEntryNoScope() throws Exception
|
||||||
{
|
{
|
||||||
EnvEntry ee = new EnvEntry("nameZ", "zstring", true);
|
EnvEntry ee = new EnvEntry("nameZ", "zstring", true);
|
||||||
List list = NamingEntryUtil.lookupNamingEntries(null, EnvEntry.class);
|
List list = NamingEntryUtil.lookupNamingEntries(null, EnvEntry.class);
|
||||||
|
@ -170,10 +140,10 @@ public class TestNamingEntries extends TestCase
|
||||||
EnvEntry eo = (EnvEntry)o;
|
EnvEntry eo = (EnvEntry)o;
|
||||||
assertEquals ("nameZ", eo.getJndiName());
|
assertEquals ("nameZ", eo.getJndiName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnvEntryOverride ()
|
@Test
|
||||||
throws Exception
|
public void testEnvEntryOverride() throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, true);
|
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, true);
|
||||||
|
|
||||||
|
@ -188,10 +158,9 @@ public class TestNamingEntries extends TestCase
|
||||||
assertNotNull(namingEntriesContext);
|
assertNotNull(namingEntriesContext);
|
||||||
assertEquals(someObject, scopeContext.lookup("nameA"));
|
assertEquals(someObject, scopeContext.lookup("nameA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testEnvEntryNonOverride ()
|
@Test
|
||||||
throws Exception
|
public void testEnvEntryNonOverride() throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, false);
|
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, false);
|
||||||
|
@ -208,34 +177,32 @@ public class TestNamingEntries extends TestCase
|
||||||
assertEquals(someObject, scopeContext.lookup("nameA"));
|
assertEquals(someObject, scopeContext.lookup("nameA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testResource ()
|
public void testResource () throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
InitialContext icontext = new InitialContext();
|
InitialContext icontext = new InitialContext();
|
||||||
|
|
||||||
Resource resource = new Resource (null, "resourceA/b/c", someObject);
|
Resource resource = new Resource (null, "resourceA/b/c", someObject);
|
||||||
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceA/b/c");
|
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceA/b/c");
|
||||||
assertNotNull(ne);
|
assertNotNull(ne);
|
||||||
assertTrue(ne instanceof Resource);
|
assertTrue(ne instanceof Resource);
|
||||||
assertEquals(icontext.lookup("resourceA/b/c"), someObject);
|
assertEquals(icontext.lookup("resourceA/b/c"), someObject);
|
||||||
|
|
||||||
Object scope = new ScopeA();
|
Object scope = new ScopeA();
|
||||||
Resource resource2 = new Resource (scope, "resourceB", someObject);
|
Resource resource2 = new Resource (scope, "resourceB", someObject);
|
||||||
ne = NamingEntryUtil.lookupNamingEntry(scope, "resourceB");
|
ne = NamingEntryUtil.lookupNamingEntry(scope, "resourceB");
|
||||||
assertNotNull(ne);
|
assertNotNull(ne);
|
||||||
assertTrue(ne instanceof Resource);
|
assertTrue(ne instanceof Resource);
|
||||||
|
|
||||||
ne = NamingEntryUtil.lookupNamingEntry(null, "resourceB");
|
ne = NamingEntryUtil.lookupNamingEntry(null, "resourceB");
|
||||||
assertNull(ne);
|
assertNull(ne);
|
||||||
|
|
||||||
ne = NamingEntryUtil.lookupNamingEntry(new ScopeB(), "resourceB");
|
ne = NamingEntryUtil.lookupNamingEntry(new ScopeB(), "resourceB");
|
||||||
assertNull(ne);
|
assertNull(ne);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLink ()
|
public void testLink () throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
InitialContext icontext = new InitialContext();
|
InitialContext icontext = new InitialContext();
|
||||||
|
@ -246,15 +213,13 @@ public class TestNamingEntries extends TestCase
|
||||||
assertEquals(icontext.lookup("resourceA"), "resourceB");
|
assertEquals(icontext.lookup("resourceA"), "resourceB");
|
||||||
|
|
||||||
link = new Link (scope, "jdbc/resourceX", "jdbc/resourceY");
|
link = new Link (scope, "jdbc/resourceX", "jdbc/resourceY");
|
||||||
ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/resourceX");
|
ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/resourceX");
|
||||||
assertNotNull(ne);
|
assertNotNull(ne);
|
||||||
assertTrue(ne instanceof Link);
|
assertTrue(ne instanceof Link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testResourceReferenceable() throws Exception
|
||||||
public void testResourceReferenceable ()
|
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
SomeOtherObject someOtherObj = new SomeOtherObject("100");
|
SomeOtherObject someOtherObj = new SomeOtherObject("100");
|
||||||
InitialContext icontext = new InitialContext();
|
InitialContext icontext = new InitialContext();
|
||||||
|
@ -263,25 +228,24 @@ public class TestNamingEntries extends TestCase
|
||||||
assertNotNull(o);
|
assertNotNull(o);
|
||||||
assertTrue (o instanceof SomeOtherObject);
|
assertTrue (o instanceof SomeOtherObject);
|
||||||
assertEquals(((SomeOtherObject)o).getValue(), 100);
|
assertEquals(((SomeOtherObject)o).getValue(), 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResourceReference ()
|
@Test
|
||||||
throws Exception
|
public void testResourceReference () throws Exception
|
||||||
{
|
{
|
||||||
RefAddr refAddr = new StringRefAddr("val", "10");
|
RefAddr refAddr = new StringRefAddr("val", "10");
|
||||||
Reference ref = new Reference(SomeObject.class.getName(), refAddr, SomeObjectFactory.class.getName(), null);
|
Reference ref = new Reference(SomeObject.class.getName(), refAddr, SomeObjectFactory.class.getName(), null);
|
||||||
|
|
||||||
InitialContext icontext = new InitialContext();
|
InitialContext icontext = new InitialContext();
|
||||||
Resource resource = new Resource (null, "resourceByRef", ref);
|
Resource resource = new Resource (null, "resourceByRef", ref);
|
||||||
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceByRef");
|
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceByRef");
|
||||||
assertNotNull(ne);
|
assertNotNull(ne);
|
||||||
assertTrue (ne instanceof Resource);
|
assertTrue (ne instanceof Resource);
|
||||||
|
|
||||||
Object o = icontext.lookup("resourceByRef");
|
Object o = icontext.lookup("resourceByRef");
|
||||||
assertNotNull (o);
|
assertNotNull (o);
|
||||||
assertTrue (o instanceof SomeObject);
|
assertTrue (o instanceof SomeObject);
|
||||||
|
|
||||||
assertEquals(((SomeObject)o).getValue(), 10);
|
assertEquals(((SomeObject)o).getValue(), 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,25 +4,30 @@
|
||||||
// All rights reserved. This program and the accompanying materials
|
// All rights reserved. This program and the accompanying materials
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
// The Eclipse Public License is available at
|
// The Eclipse Public License is available at
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
// The Apache License v2.0 is available at
|
// The Apache License v2.0 is available at
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
package org.eclipse.jetty.plus.jndi;
|
package org.eclipse.jetty.plus.jndi;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.Name;
|
import javax.naming.Name;
|
||||||
import javax.naming.NameNotFoundException;
|
import javax.naming.NameNotFoundException;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestNamingEntryUtil extends TestCase
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
public class TestNamingEntryUtil
|
||||||
{
|
{
|
||||||
public class MyNamingEntry extends NamingEntry
|
public class MyNamingEntry extends NamingEntry
|
||||||
{
|
{
|
||||||
|
@ -33,24 +38,25 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScopeA extends Object
|
public class ScopeA
|
||||||
{
|
{
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return this.getClass().getName()+"@"+super.hashCode();
|
return this.getClass().getName()+"@"+super.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void testGetNameForScope ()
|
|
||||||
throws Exception
|
@Test
|
||||||
|
public void testGetNameForScope () throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
Name name = NamingEntryUtil.getNameForScope(scope);
|
Name name = NamingEntryUtil.getNameForScope(scope);
|
||||||
assertNotNull(name);
|
assertNotNull(name);
|
||||||
assertEquals(scope.toString(), name.toString());
|
assertEquals(scope.toString(), name.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetContextForScope()
|
@Test
|
||||||
throws Exception
|
public void testGetContextForScope() throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
try
|
try
|
||||||
|
@ -62,11 +68,11 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
{
|
{
|
||||||
//expected
|
//expected
|
||||||
}
|
}
|
||||||
|
|
||||||
InitialContext ic = new InitialContext();
|
InitialContext ic = new InitialContext();
|
||||||
Context scopeContext = ic.createSubcontext(NamingEntryUtil.getNameForScope(scope));
|
Context scopeContext = ic.createSubcontext(NamingEntryUtil.getNameForScope(scope));
|
||||||
assertNotNull(scopeContext);
|
assertNotNull(scopeContext);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Context c = NamingEntryUtil.getContextForScope(scope);
|
Context c = NamingEntryUtil.getContextForScope(scope);
|
||||||
|
@ -77,50 +83,49 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMakeNamingEntryName ()
|
@Test
|
||||||
throws Exception
|
public void testMakeNamingEntryName() throws Exception
|
||||||
{
|
{
|
||||||
Name name = NamingEntryUtil.makeNamingEntryName(null, "fee/fi/fo/fum");
|
Name name = NamingEntryUtil.makeNamingEntryName(null, "fee/fi/fo/fum");
|
||||||
assertNotNull(name);
|
assertNotNull(name);
|
||||||
assertEquals(NamingEntry.__contextName+"/fee/fi/fo/fum", name.toString());
|
assertEquals(NamingEntry.__contextName+"/fee/fi/fo/fum", name.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLookupNamingEntry ()
|
@Test
|
||||||
throws Exception
|
public void testLookupNamingEntry() throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
||||||
assertNull(ne);
|
assertNull(ne);
|
||||||
|
|
||||||
MyNamingEntry mne = new MyNamingEntry(scope, "foo", new Integer(9));
|
MyNamingEntry mne = new MyNamingEntry(scope, "foo", 9);
|
||||||
|
|
||||||
ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
||||||
assertNotNull(ne);
|
assertNotNull(ne);
|
||||||
assertEquals(ne, mne);
|
assertEquals(ne, mne);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLookupNamingEntries ()
|
@Test
|
||||||
throws Exception
|
public void testLookupNamingEntries() throws Exception
|
||||||
{
|
{
|
||||||
ScopeA scope = new ScopeA();
|
ScopeA scope = new ScopeA();
|
||||||
List list = NamingEntryUtil.lookupNamingEntries(scope, MyNamingEntry.class);
|
List list = NamingEntryUtil.lookupNamingEntries(scope, MyNamingEntry.class);
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
|
|
||||||
MyNamingEntry mne1 = new MyNamingEntry(scope, "a/b", new Integer(1));
|
MyNamingEntry mne1 = new MyNamingEntry(scope, "a/b", 1);
|
||||||
MyNamingEntry mne2 = new MyNamingEntry(scope, "a/c", new Integer(2));
|
MyNamingEntry mne2 = new MyNamingEntry(scope, "a/c", 2);
|
||||||
|
|
||||||
ScopeA scope2 = new ScopeA();
|
ScopeA scope2 = new ScopeA();
|
||||||
MyNamingEntry mne3 = new MyNamingEntry(scope2, "a/b", new Integer(3));
|
MyNamingEntry mne3 = new MyNamingEntry(scope2, "a/b", 3);
|
||||||
|
|
||||||
list = NamingEntryUtil.lookupNamingEntries(scope, MyNamingEntry.class);
|
list = NamingEntryUtil.lookupNamingEntries(scope, MyNamingEntry.class);
|
||||||
assertEquals(2, list.size());
|
assertEquals(2, list.size());
|
||||||
assertTrue (list.contains(mne1));
|
assertTrue (list.contains(mne1));
|
||||||
assertTrue (list.contains(mne2));
|
assertTrue (list.contains(mne2));
|
||||||
|
|
||||||
list = NamingEntryUtil.lookupNamingEntries(scope2, MyNamingEntry.class);
|
list = NamingEntryUtil.lookupNamingEntries(scope2, MyNamingEntry.class);
|
||||||
assertEquals(1, list.size());
|
assertEquals(1, list.size());
|
||||||
assertTrue(list.contains(mne3));
|
assertTrue(list.contains(mne3));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,29 +4,30 @@
|
||||||
// All rights reserved. This program and the accompanying materials
|
// All rights reserved. This program and the accompanying materials
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
// The Eclipse Public License is available at
|
// The Eclipse Public License is available at
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
// The Apache License v2.0 is available at
|
// The Apache License v2.0 is available at
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
package org.eclipse.jetty.plus.webapp;
|
package org.eclipse.jetty.plus.webapp;
|
||||||
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.plus.jndi.EnvEntry;
|
import org.eclipse.jetty.plus.jndi.EnvEntry;
|
||||||
import org.eclipse.jetty.plus.jndi.NamingEntry;
|
import org.eclipse.jetty.plus.jndi.NamingEntry;
|
||||||
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestConfiguration extends TestCase
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
public class TestConfiguration
|
||||||
{
|
{
|
||||||
|
|
||||||
public class MyWebAppContext extends WebAppContext
|
public class MyWebAppContext extends WebAppContext
|
||||||
{
|
{
|
||||||
public String toString()
|
public String toString()
|
||||||
|
@ -34,9 +35,9 @@ public class TestConfiguration extends TestCase
|
||||||
return this.getClass().getName()+"@"+super.hashCode();
|
return this.getClass().getName()+"@"+super.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIt ()
|
@Test
|
||||||
throws Exception
|
public void testIt () throws Exception
|
||||||
{
|
{
|
||||||
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
@ -50,14 +51,14 @@ public class TestConfiguration extends TestCase
|
||||||
wac.setServer(server);
|
wac.setServer(server);
|
||||||
wac.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), wac));
|
wac.setClassLoader(new WebAppClassLoader(Thread.currentThread().getContextClassLoader(), wac));
|
||||||
|
|
||||||
//bind some EnvEntrys at the server level
|
//bind some EnvEntrys at the server level
|
||||||
EnvEntry ee1 = new EnvEntry(server, "xxx/a", "100", true);
|
EnvEntry ee1 = new EnvEntry(server, "xxx/a", "100", true);
|
||||||
EnvEntry ee2 = new EnvEntry(server, "yyy/b", "200", false);
|
EnvEntry ee2 = new EnvEntry(server, "yyy/b", "200", false);
|
||||||
EnvEntry ee3 = new EnvEntry(server, "zzz/c", "300", false);
|
EnvEntry ee3 = new EnvEntry(server, "zzz/c", "300", false);
|
||||||
EnvEntry ee4 = new EnvEntry(server, "zzz/d", "400", false);
|
EnvEntry ee4 = new EnvEntry(server, "zzz/d", "400", false);
|
||||||
EnvEntry ee5 = new EnvEntry(server, "zzz/f", "500", true);
|
EnvEntry ee5 = new EnvEntry(server, "zzz/f", "500", true);
|
||||||
|
|
||||||
//bind some EnvEntrys at the webapp level
|
//bind some EnvEntrys at the webapp level
|
||||||
EnvEntry ee6 = new EnvEntry(wac, "xxx/a", "900", true);
|
EnvEntry ee6 = new EnvEntry(wac, "xxx/a", "900", true);
|
||||||
EnvEntry ee7 = new EnvEntry(wac, "yyy/b", "910", true);
|
EnvEntry ee7 = new EnvEntry(wac, "yyy/b", "910", true);
|
||||||
EnvEntry ee8 = new EnvEntry(wac, "zzz/c", "920", false);
|
EnvEntry ee8 = new EnvEntry(wac, "zzz/c", "920", false);
|
||||||
|
@ -69,7 +70,7 @@ public class TestConfiguration extends TestCase
|
||||||
assertNotNull(NamingEntryUtil.lookupNamingEntry(server, "zzz/d"));
|
assertNotNull(NamingEntryUtil.lookupNamingEntry(server, "zzz/d"));
|
||||||
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "xxx/a"));
|
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "xxx/a"));
|
||||||
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "yyy/b"));
|
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "yyy/b"));
|
||||||
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/c"));
|
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/c"));
|
||||||
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/e"));
|
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/e"));
|
||||||
|
|
||||||
Configuration config = new Configuration();
|
Configuration config = new Configuration();
|
||||||
|
|
Loading…
Reference in New Issue