Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2010-05-11 11:52:12 -0400
committerSimone Bordet2010-05-11 11:52:12 -0400
commit2a37d805b35c4a126eaf04f648c13dd682b3c380 (patch)
tree4b937883cb1bd13016ab1912b5a5d7b6a4550987
parent8f6bde3ccd0be902a7bfaf00c9049077544e67ce (diff)
downloadorg.eclipse.jetty.project-2a37d805b35c4a126eaf04f648c13dd682b3c380.tar.gz
org.eclipse.jetty.project-2a37d805b35c4a126eaf04f648c13dd682b3c380.tar.xz
org.eclipse.jetty.project-2a37d805b35c4a126eaf04f648c13dd682b3c380.zip
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
-rw-r--r--VERSION.txt1
-rw-r--r--jetty-plus/pom.xml5
-rw-r--r--jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntries.java160
-rw-r--r--jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntryUtil.java71
-rw-r--r--jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/TestConfiguration.java25
5 files changed, 117 insertions, 145 deletions
diff --git a/VERSION.txt b/VERSION.txt
index b1c6c7a975..96fbb26ff3 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -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.
diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml
index efe0507a64..f1fc458288 100644
--- a/jetty-plus/pom.xml
+++ b/jetty-plus/pom.xml
@@ -13,7 +13,7 @@
</properties>
<build>
<plugins>
-<!--
+<!--
COMMENTED OUT UNTIL CORRECT CONFIG IS FOUND FOR Export uses clauses
-->
<plugin>
@@ -39,7 +39,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
- <archive>
+ <archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
@@ -79,6 +79,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>${junit4-version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntries.java b/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntries.java
index b2a85af440..d18998b5b2 100644
--- a/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntries.java
+++ b/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntries.java
@@ -4,19 +4,17 @@
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// 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
// The Apache License v2.0 is available at
// 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;
-
import java.util.Hashtable;
import java.util.List;
-
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
@@ -27,138 +25,110 @@ 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()
{
return this.getClass().getName()+"@"+super.hashCode();
}
}
-
+
public class ScopeB extends ScopeA
- {}
-
-
-
+ {
+ }
+
public static class SomeObject
{
private int value;
public SomeObject (int value)
{this.value = value;}
-
+
public int getValue ()
{
return this.value;
}
}
-
+
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;
-
+
RefAddr refAddr = ref.get(0);
String valueName = refAddr.getType();
if (!valueName.equalsIgnoreCase("val"))
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
-
+
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();
if (!valueName.equalsIgnoreCase("val"))
throw new RuntimeException("Unrecognized refaddr type = "+valueName);
-
+
String value = (String)refAddr.getContent();
-
+
return new SomeOtherObject(value.trim());
}
-
}
-
- public SomeObject someObject;
-
- public void setUp ()
+ private SomeObject someObject;
+
+ @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);
@@ -170,10 +140,10 @@ public class TestNamingEntries extends TestCase
EnvEntry eo = (EnvEntry)o;
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);
@@ -188,10 +158,9 @@ public class TestNamingEntries extends TestCase
assertNotNull(namingEntriesContext);
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,34 +177,32 @@ 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();
-
+
Resource resource = new Resource (null, "resourceA/b/c", someObject);
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceA/b/c");
assertNotNull(ne);
assertTrue(ne instanceof Resource);
assertEquals(icontext.lookup("resourceA/b/c"), someObject);
-
+
Object scope = new ScopeA();
Resource resource2 = new Resource (scope, "resourceB", someObject);
ne = NamingEntryUtil.lookupNamingEntry(scope, "resourceB");
assertNotNull(ne);
assertTrue(ne instanceof Resource);
-
+
ne = NamingEntryUtil.lookupNamingEntry(null, "resourceB");
assertNull(ne);
-
+
ne = NamingEntryUtil.lookupNamingEntry(new ScopeB(), "resourceB");
assertNull(ne);
}
-
-
- public void testLink ()
- throws Exception
+
+ @Test
+ public void testLink () throws Exception
{
ScopeA scope = new ScopeA();
InitialContext icontext = new InitialContext();
@@ -246,15 +213,13 @@ public class TestNamingEntries extends TestCase
assertEquals(icontext.lookup("resourceA"), "resourceB");
link = new Link (scope, "jdbc/resourceX", "jdbc/resourceY");
- ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/resourceX");
+ ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/resourceX");
assertNotNull(ne);
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,25 +228,24 @@ 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);
-
+
InitialContext icontext = new InitialContext();
Resource resource = new Resource (null, "resourceByRef", ref);
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceByRef");
assertNotNull(ne);
assertTrue (ne instanceof Resource);
-
+
Object o = icontext.lookup("resourceByRef");
assertNotNull (o);
assertTrue (o instanceof SomeObject);
-
+
assertEquals(((SomeObject)o).getValue(), 10);
}
}
diff --git a/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntryUtil.java b/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntryUtil.java
index af407897f3..ad56aa295d 100644
--- a/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntryUtil.java
+++ b/jetty-plus/src/test/java/org/eclipse/jetty/plus/jndi/TestNamingEntryUtil.java
@@ -4,25 +4,30 @@
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// 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
// The Apache License v2.0 is available at
// 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;
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;
+
+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 extends TestCase
+public class TestNamingEntryUtil
{
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()
{
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);
assertNotNull(name);
assertEquals(scope.toString(), name.toString());
}
-
- public void testGetContextForScope()
- throws Exception
+
+ @Test
+ public void testGetContextForScope() throws Exception
{
ScopeA scope = new ScopeA();
try
@@ -62,11 +68,11 @@ public class TestNamingEntryUtil extends TestCase
{
//expected
}
-
+
InitialContext ic = new InitialContext();
Context scopeContext = ic.createSubcontext(NamingEntryUtil.getNameForScope(scope));
assertNotNull(scopeContext);
-
+
try
{
Context c = NamingEntryUtil.getContextForScope(scope);
@@ -77,50 +83,49 @@ public class TestNamingEntryUtil extends TestCase
fail(e.getMessage());
}
}
-
- 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());
assertTrue (list.contains(mne1));
assertTrue (list.contains(mne2));
-
+
list = NamingEntryUtil.lookupNamingEntries(scope2, MyNamingEntry.class);
assertEquals(1, list.size());
assertTrue(list.contains(mne3));
-
}
}
diff --git a/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/TestConfiguration.java b/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/TestConfiguration.java
index 0b2516b2a9..0abd5e5726 100644
--- a/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/TestConfiguration.java
+++ b/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/TestConfiguration.java
@@ -4,29 +4,30 @@
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// 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
// The Apache License v2.0 is available at
// 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;
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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-public class TestConfiguration extends TestCase
+public class TestConfiguration
{
-
public class MyWebAppContext extends WebAppContext
{
public String toString()
@@ -34,9 +35,9 @@ public class TestConfiguration extends TestCase
return this.getClass().getName()+"@"+super.hashCode();
}
}
-
- public void testIt ()
- throws Exception
+
+ @Test
+ public void testIt () throws Exception
{
ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
@@ -50,14 +51,14 @@ public class TestConfiguration extends TestCase
wac.setServer(server);
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 ee2 = new EnvEntry(server, "yyy/b", "200", false);
EnvEntry ee3 = new EnvEntry(server, "zzz/c", "300", false);
EnvEntry ee4 = new EnvEntry(server, "zzz/d", "400", false);
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 ee7 = new EnvEntry(wac, "yyy/b", "910", true);
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(wac, "xxx/a"));
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "yyy/b"));
- assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/c"));
+ assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/c"));
assertNotNull(NamingEntryUtil.lookupNamingEntry(wac, "zzz/e"));
Configuration config = new Configuration();

Back to the top