import java.io.InputStream;
import java.security.SecureRandom;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Session;
-
import org.apache.catalina.core.StandardContext;
-
/**
* Named Benchmarks so it is not automatically executed as part of the unit
* tests.
*/
-public class Benchmarks extends TestCase {
+public class Benchmarks {
/*
* Results on markt's 4-core Windows dev box
* 4 threads - ~3,500ms
* 16 threads - ~14,465ms
*/
+ @Test
public void testManagerBaseGenerateSessionId() throws Exception {
doTestManagerBaseGenerateSessionId(1, 1000000);
doTestManagerBaseGenerateSessionId(1, 1000000);
* 4 threads - ~11,700ms
* 16 threads - ~45,600ms
*/
+ @Test
public void testManagerBaseCreateSession() throws LifecycleException {
doTestManagerBaseCreateSession(1, 1000000);
doTestManagerBaseCreateSession(2, 1000000);
* 2 threads - ~725ms ~5,200ms
* 4 threads - ~1,265ms ~10,500ms
*/
+ @Test
public void testSecureRandomVsDevURandom() throws Exception {
doTestSecureRandomVsDevURandom(1, 1000000);
doTestSecureRandomVsDevURandom(2, 1000000);
import java.io.FileInputStream;
import java.io.IOException;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
/**
* The design of the session manager depends on the thread-safety - or not - of
* Named Threading so it is not automatically executed as part of the unit
* tests.
*/
-public class Threading extends TestCase {
+public class Threading {
/**
* {@link FileInputStream#read(byte[])} and related methods are all native
* methods so it isn't immediately obvious if they are thread-safe or not.
*
+ * <pre>
* Windows JDK 1.6.0_22_x64 - Thread safe
* OSX JDK 1.6.0_22_x64 - Not thread safe
+ * </pre>
*
* Therefore, have to assume that {@link FileInputStream#read(byte[])} is
* not thread safe.
*/
+ @Test
public void testFileInputStream() throws Exception {
doTestFileInputStream(1);
doTestFileInputStream(2);
// Assumes "ant release" has been run
// Will need to be updated as new releases are made
File file = new File(
- "./output/release/v7.0.6-dev/bin/apache-tomcat-7.0.6-dev.zip");
+ "./output/release/v7.0.20-dev/bin/apache-tomcat-7.0.20-dev.zip");
FileInputStream fis = new FileInputStream(file);
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import junit.framework.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;
+
+import org.junit.Test;
import org.apache.catalina.Container;
import org.apache.catalina.Loader;
* @author Peter Rossbach
* @version $Revision$
*/
-public class TestContextConfigAnnotation extends TestCase {
+public class TestContextConfigAnnotation {
+ @Test
public void testAnnotation() throws Exception {
WebXml webxml = new WebXml();
ContextConfig config = new ContextConfig();
}
+ @Test
public void testOverwriteAnnotation() throws Exception {
WebXml webxml = new WebXml();
ServletDef servletDef = new ServletDef();
assertNull(servletDef.getJspFile());
}
+ @Test
public void testNoMapping() throws Exception {
WebXml webxml = new WebXml();
ContextConfig config = new ContextConfig();
}
+ @Test
public void testSetupWebXMLNoMapping() throws Exception {
WebXml webxml = new WebXml();
ServletDef servletDef = new ServletDef();
assertEquals(servletDef, servletDef1);
}
+ @Test
public void testDuplicateMapping() throws Exception {
WebXml webxml = new WebXml();
ContextConfig config = new ContextConfig();
assertNull(servletDef);
}
+ @Test
public void testFilterMapping() throws Exception {
WebXml webxml = new WebXml();
ContextConfig config = new ContextConfig();
assertEquals("Servlet says: ",fdef.getParameterMap().get("message"));
}
+ @Test
public void testOverwriteFilterMapping() throws Exception {
WebXml webxml = new WebXml();
FilterDef filterDef = new FilterDef();
}
+ @Test
public void testDuplicateFilterMapping() throws Exception {
WebXml webxml = new WebXml();
ContextConfig config = new ContextConfig();
assertNull(filterDef);
}
+ @Test
public void testCheckHandleTypes() throws Exception {
ContextConfig config = new ContextConfig();
*/
package org.apache.catalina.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class TestContextName extends TestCase {
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class TestContextName {
private ContextName cn1;
private ContextName cn2;
private ContextName cn15;
private ContextName cn16;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
cn1 = new ContextName(null, null);
cn2 = new ContextName("", null);
cn3 = new ContextName("/", null);
cn16 = new ContextName("foo#bar##E");
}
+ @Test
public void testGetBaseName() {
assertEquals("ROOT", cn1.getBaseName());
assertEquals("ROOT", cn2.getBaseName());
assertEquals("foo#bar##E", cn16.getBaseName());
}
+ @Test
public void testGetPath() {
assertEquals("", cn1.getPath());
assertEquals("", cn2.getPath());
assertEquals("/foo/bar", cn16.getPath());
}
+ @Test
public void testGetVersion() {
assertEquals("", cn1.getVersion());
assertEquals("", cn2.getVersion());
assertEquals("E", cn16.getVersion());
}
+ @Test
public void testGetName() {
assertEquals("", cn1.getName());
assertEquals("", cn2.getName());
assertEquals("/foo/bar##E", cn16.getName());
}
+ @Test
public void testGetDisplayName() {
assertEquals("/", cn1.getDisplayName());
assertEquals("/", cn2.getDisplayName());
assertEquals("/foo/bar##E", cn16.getDisplayName());
}
+ @Test
public void testConstructorString() {
doTestConstructorString(cn1);
doTestConstructorString(cn2);
package org.apache.catalina.util;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-public class TestRequestUtil extends TestCase {
+import org.junit.Test;
+public class TestRequestUtil {
+
+ @Test
public void testNormalizeString() {
assertEquals("/something",RequestUtil.normalize("//something"));
assertEquals("/some/thing",RequestUtil.normalize("some//thing"));
assertEquals("/",RequestUtil.normalize("//"));
}
+ @Test
public void testURLDecodeStringInvalid() {
// %n rather than %nn should throw an IAE according to the Javadoc
Exception exception = null;
assertTrue(exception instanceof IllegalArgumentException);
}
+ @Test
public void testURLDecodeStringValidIso88591Start() {
String result = RequestUtil.URLDecode("%41xxxx", "ISO-8859-1");
assertEquals("Axxxx", result);
}
+ @Test
public void testURLDecodeStringValidIso88591Middle() {
String result = RequestUtil.URLDecode("xx%41xx", "ISO-8859-1");
assertEquals("xxAxx", result);
}
+ @Test
public void testURLDecodeStringValidIso88591End() {
String result = RequestUtil.URLDecode("xxxx%41", "ISO-8859-1");
assertEquals("xxxxA", result);
}
+ @Test
public void testURLDecodeStringValidUtf8Start() {
String result = RequestUtil.URLDecode("%c3%aaxxxx", "UTF-8");
assertEquals("\u00eaxxxx", result);
}
+ @Test
public void testURLDecodeStringValidUtf8Middle() {
String result = RequestUtil.URLDecode("xx%c3%aaxx", "UTF-8");
assertEquals("xx\u00eaxx", result);
}
+ @Test
public void testURLDecodeStringValidUtf8End() {
String result = RequestUtil.URLDecode("xxxx%c3%aa", "UTF-8");
package org.apache.catalina.util;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class TestServerInfo extends TestCase {
+public class TestServerInfo {
/**
* Test that prints the server version info.
*/
+ @Test
public void testServerInfo() {
ServerInfo.main(new String[0]);
}