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.
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
|
|
||||||
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,16 +25,21 @@ 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()
|
||||||
{
|
{
|
||||||
|
@ -45,9 +48,8 @@ public class TestNamingEntries extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScopeB extends ScopeA
|
public class ScopeB extends ScopeA
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class SomeObject
|
public static class SomeObject
|
||||||
{
|
{
|
||||||
|
@ -63,20 +65,10 @@ public class TestNamingEntries extends TestCase
|
||||||
|
|
||||||
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;
|
||||||
|
@ -89,53 +81,32 @@ public class TestNamingEntries extends TestCase
|
||||||
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();
|
||||||
|
@ -146,19 +117,18 @@ public class TestNamingEntries extends TestCase
|
||||||
|
|
||||||
return new SomeOtherObject(value.trim());
|
return new SomeOtherObject(value.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SomeObject someObject;
|
||||||
|
|
||||||
public SomeObject someObject;
|
@Before
|
||||||
|
public void init()
|
||||||
public void setUp ()
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -171,8 +141,8 @@ public class TestNamingEntries extends TestCase
|
||||||
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);
|
||||||
|
@ -189,9 +159,8 @@ public class TestNamingEntries extends TestCase
|
||||||
assertEquals(someObject, scopeContext.lookup("nameA"));
|
assertEquals(someObject, scopeContext.lookup("nameA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testEnvEntryNonOverride ()
|
public void testEnvEntryNonOverride() throws Exception
|
||||||
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,9 +177,8 @@ 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();
|
||||||
|
|
||||||
|
@ -233,9 +201,8 @@ public class TestNamingEntries extends TestCase
|
||||||
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();
|
||||||
|
@ -251,10 +218,8 @@ public class TestNamingEntries extends TestCase
|
||||||
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,11 +228,10 @@ 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);
|
||||||
|
|
|
@ -13,16 +13,21 @@
|
||||||
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,15 +38,16 @@ 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);
|
||||||
|
@ -49,8 +55,8 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
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
|
||||||
|
@ -78,40 +84,40 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
@ -121,6 +127,5 @@ public class TestNamingEntryUtil extends TestCase
|
||||||
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,19 @@ 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()
|
||||||
|
@ -35,8 +36,8 @@ public class TestConfiguration extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIt ()
|
@Test
|
||||||
throws Exception
|
public void testIt () throws Exception
|
||||||
{
|
{
|
||||||
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue