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
|
||||
+ 308854 Update test suite to JUnit4 - Module jetty-http
|
||||
+ 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
|
||||
+ 306353 fixed cross context dispatch to root context.
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -13,10 +13,8 @@
|
|||
|
||||
package org.eclipse.jetty.plus.jndi;
|
||||
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.Name;
|
||||
|
@ -27,16 +25,21 @@ import javax.naming.Referenceable;
|
|||
import javax.naming.StringRefAddr;
|
||||
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()
|
||||
{
|
||||
|
@ -45,9 +48,8 @@ public class TestNamingEntries extends TestCase
|
|||
}
|
||||
|
||||
public class ScopeB extends ScopeA
|
||||
{}
|
||||
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
public static class SomeObject
|
||||
{
|
||||
|
@ -63,20 +65,10 @@ public class TestNamingEntries extends TestCase
|
|||
|
||||
public static class SomeObjectFactory implements ObjectFactory
|
||||
{
|
||||
|
||||
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
|
||||
{
|
||||
Reference ref = (Reference)arg0;
|
||||
|
@ -89,53 +81,32 @@ public class TestNamingEntries extends TestCase
|
|||
String value = (String)refAddr.getContent();
|
||||
|
||||
return new SomeObject(Integer.parseInt(value.trim()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SomeOtherObject extends SomeObject implements Referenceable
|
||||
{
|
||||
|
||||
private String svalue;
|
||||
public SomeOtherObject (String value)
|
||||
{
|
||||
super(Integer.parseInt(value.trim()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Referenceable#getReference()
|
||||
* @return the reference
|
||||
* @throws NamingException
|
||||
*/
|
||||
public Reference getReference() throws NamingException
|
||||
{
|
||||
RefAddr refAddr = new StringRefAddr("val", String.valueOf(getValue()));
|
||||
Reference ref = new Reference(SomeOtherObject.class.getName(), refAddr, SomeOtherObjectFactory.class.getName(), null);
|
||||
return ref;
|
||||
return new Reference(SomeOtherObject.class.getName(), refAddr, SomeOtherObjectFactory.class.getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SomeOtherObjectFactory implements ObjectFactory
|
||||
{
|
||||
|
||||
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
|
||||
{
|
||||
Reference ref = (Reference)arg0;
|
||||
Reference ref = (Reference)arg0;
|
||||
|
||||
RefAddr refAddr = ref.get(0);
|
||||
String valueName = refAddr.getType();
|
||||
|
@ -146,19 +117,18 @@ public class TestNamingEntries extends TestCase
|
|||
|
||||
return new SomeOtherObject(value.trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SomeObject someObject;
|
||||
|
||||
public SomeObject someObject;
|
||||
|
||||
public void setUp ()
|
||||
@Before
|
||||
public void init()
|
||||
{
|
||||
this.someObject = new SomeObject(4);
|
||||
}
|
||||
|
||||
public void testEnvEntryNoScope ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testEnvEntryNoScope() throws Exception
|
||||
{
|
||||
EnvEntry ee = new EnvEntry("nameZ", "zstring", true);
|
||||
List list = NamingEntryUtil.lookupNamingEntries(null, EnvEntry.class);
|
||||
|
@ -171,8 +141,8 @@ public class TestNamingEntries extends TestCase
|
|||
assertEquals ("nameZ", eo.getJndiName());
|
||||
}
|
||||
|
||||
public void testEnvEntryOverride ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testEnvEntryOverride() throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, true);
|
||||
|
@ -189,9 +159,8 @@ public class TestNamingEntries extends TestCase
|
|||
assertEquals(someObject, scopeContext.lookup("nameA"));
|
||||
}
|
||||
|
||||
|
||||
public void testEnvEntryNonOverride ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testEnvEntryNonOverride() throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
EnvEntry ee = new EnvEntry (scope, "nameA", someObject, false);
|
||||
|
@ -208,9 +177,8 @@ public class TestNamingEntries extends TestCase
|
|||
assertEquals(someObject, scopeContext.lookup("nameA"));
|
||||
}
|
||||
|
||||
|
||||
public void testResource ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResource () throws Exception
|
||||
{
|
||||
InitialContext icontext = new InitialContext();
|
||||
|
||||
|
@ -233,9 +201,8 @@ public class TestNamingEntries extends TestCase
|
|||
assertNull(ne);
|
||||
}
|
||||
|
||||
|
||||
public void testLink ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLink () throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
InitialContext icontext = new InitialContext();
|
||||
|
@ -251,10 +218,8 @@ public class TestNamingEntries extends TestCase
|
|||
assertTrue(ne instanceof Link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testResourceReferenceable ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResourceReferenceable() throws Exception
|
||||
{
|
||||
SomeOtherObject someOtherObj = new SomeOtherObject("100");
|
||||
InitialContext icontext = new InitialContext();
|
||||
|
@ -263,11 +228,10 @@ public class TestNamingEntries extends TestCase
|
|||
assertNotNull(o);
|
||||
assertTrue (o instanceof SomeOtherObject);
|
||||
assertEquals(((SomeOtherObject)o).getValue(), 100);
|
||||
|
||||
}
|
||||
|
||||
public void testResourceReference ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResourceReference () throws Exception
|
||||
{
|
||||
RefAddr refAddr = new StringRefAddr("val", "10");
|
||||
Reference ref = new Reference(SomeObject.class.getName(), refAddr, SomeObjectFactory.class.getName(), null);
|
||||
|
|
|
@ -13,16 +13,21 @@
|
|||
package org.eclipse.jetty.plus.jndi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameNotFoundException;
|
||||
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
|
||||
{
|
||||
|
@ -33,15 +38,16 @@ public class TestNamingEntryUtil extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public class ScopeA extends Object
|
||||
public class ScopeA
|
||||
{
|
||||
public String toString()
|
||||
{
|
||||
return this.getClass().getName()+"@"+super.hashCode();
|
||||
}
|
||||
}
|
||||
public void testGetNameForScope ()
|
||||
throws Exception
|
||||
|
||||
@Test
|
||||
public void testGetNameForScope () throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
Name name = NamingEntryUtil.getNameForScope(scope);
|
||||
|
@ -49,8 +55,8 @@ public class TestNamingEntryUtil extends TestCase
|
|||
assertEquals(scope.toString(), name.toString());
|
||||
}
|
||||
|
||||
public void testGetContextForScope()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testGetContextForScope() throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
try
|
||||
|
@ -78,40 +84,40 @@ public class TestNamingEntryUtil extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public void testMakeNamingEntryName ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testMakeNamingEntryName() throws Exception
|
||||
{
|
||||
Name name = NamingEntryUtil.makeNamingEntryName(null, "fee/fi/fo/fum");
|
||||
assertNotNull(name);
|
||||
assertEquals(NamingEntry.__contextName+"/fee/fi/fo/fum", name.toString());
|
||||
}
|
||||
|
||||
public void testLookupNamingEntry ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLookupNamingEntry() throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
||||
assertNull(ne);
|
||||
|
||||
MyNamingEntry mne = new MyNamingEntry(scope, "foo", new Integer(9));
|
||||
MyNamingEntry mne = new MyNamingEntry(scope, "foo", 9);
|
||||
|
||||
ne = NamingEntryUtil.lookupNamingEntry(scope, "foo");
|
||||
assertNotNull(ne);
|
||||
assertEquals(ne, mne);
|
||||
}
|
||||
|
||||
public void testLookupNamingEntries ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLookupNamingEntries() throws Exception
|
||||
{
|
||||
ScopeA scope = new ScopeA();
|
||||
List list = NamingEntryUtil.lookupNamingEntries(scope, MyNamingEntry.class);
|
||||
assertTrue(list.isEmpty());
|
||||
|
||||
MyNamingEntry mne1 = new MyNamingEntry(scope, "a/b", new Integer(1));
|
||||
MyNamingEntry mne2 = new MyNamingEntry(scope, "a/c", new Integer(2));
|
||||
MyNamingEntry mne1 = new MyNamingEntry(scope, "a/b", 1);
|
||||
MyNamingEntry mne2 = new MyNamingEntry(scope, "a/c", 2);
|
||||
|
||||
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);
|
||||
assertEquals(2, list.size());
|
||||
|
@ -121,6 +127,5 @@ public class TestNamingEntryUtil extends TestCase
|
|||
list = NamingEntryUtil.lookupNamingEntries(scope2, MyNamingEntry.class);
|
||||
assertEquals(1, list.size());
|
||||
assertTrue(list.contains(mne3));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,19 @@ package org.eclipse.jetty.plus.webapp;
|
|||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.plus.jndi.EnvEntry;
|
||||
import org.eclipse.jetty.plus.jndi.NamingEntry;
|
||||
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
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 String toString()
|
||||
|
@ -35,8 +36,8 @@ public class TestConfiguration extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public void testIt ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testIt () throws Exception
|
||||
{
|
||||
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
|
|
Loading…
Reference in New Issue