mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-10-04 19:34:48 -04:00
Major test overhaul, now uses JUnit 4 annotation style tests.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package com.twelvemonkeys.servlet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.*;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* GenericFilterTestCase
|
||||
* <p/>
|
||||
@@ -18,6 +22,7 @@ public final class GenericFilterTestCase extends FilterAbstractTestCase {
|
||||
return new GenericFilterImpl();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitOncePerRequest() {
|
||||
// Default FALSE
|
||||
GenericFilter filter = new GenericFilterImpl();
|
||||
@@ -63,6 +68,7 @@ public final class GenericFilterTestCase extends FilterAbstractTestCase {
|
||||
filter.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterOnlyOnce() {
|
||||
final GenericFilterImpl filter = new GenericFilterImpl();
|
||||
filter.setOncePerRequest(true);
|
||||
@@ -91,6 +97,7 @@ public final class GenericFilterTestCase extends FilterAbstractTestCase {
|
||||
filter.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterMultiple() {
|
||||
final GenericFilterImpl filter = new GenericFilterImpl();
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
package com.twelvemonkeys.servlet;
|
||||
|
||||
import com.twelvemonkeys.io.OutputStreamAbstractTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletResponse;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* TrimWhiteSpaceFilterTestCase
|
||||
@@ -23,7 +25,6 @@ public class TrimWhiteSpaceFilterTestCase extends FilterAbstractTestCase {
|
||||
}
|
||||
|
||||
public static final class TrimWSFilterOutputStreamTestCase extends OutputStreamAbstractTestCase {
|
||||
|
||||
protected OutputStream makeObject() {
|
||||
// NOTE: ByteArrayOutputStream does not implement flush or close...
|
||||
return makeOutputStream(new ByteArrayOutputStream(16));
|
||||
@@ -33,6 +34,7 @@ public class TrimWhiteSpaceFilterTestCase extends FilterAbstractTestCase {
|
||||
return new TrimWhiteSpaceFilter.TrimWSFilterOutputStream(pWrapped);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrimWSOnlyWS() throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(64);
|
||||
OutputStream trim = makeOutputStream(out);
|
||||
@@ -46,6 +48,7 @@ public class TrimWhiteSpaceFilterTestCase extends FilterAbstractTestCase {
|
||||
assertEquals("Should be trimmed", "\"\"", '"' + new String(out.toByteArray()) + '"');
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrimWSLeading() throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(64);
|
||||
OutputStream trim = makeOutputStream(out);
|
||||
@@ -60,6 +63,7 @@ public class TrimWhiteSpaceFilterTestCase extends FilterAbstractTestCase {
|
||||
assertEquals("Should be trimmed", '"' + trimmed + '"', '"' + new String(out.toByteArray()) + '"');
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrimWSOffsetLength() throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(64);
|
||||
OutputStream trim = makeOutputStream(out);
|
||||
|
@@ -341,7 +341,8 @@ public class ImageFilterTestCase {
|
||||
|
||||
// NOTE:
|
||||
// We verify that the image is the same in both ImageFilter implementations, to make sure the image is only
|
||||
// decoded once, then encoded once
|
||||
// decoded once, then encoded once.
|
||||
// But this test is not necessarily 100% reliable...
|
||||
}
|
||||
|
||||
@Test(expected = ServletException.class)
|
||||
|
Reference in New Issue
Block a user