Author: etnu
Date: Sat Jun 7 21:09:47 2008
New Revision: 664434
URL: http://svn.apache.org/viewvc?rev=664434&view=rev
Log:
Added abstract specifiers to abstract base tests so that they're not run by
themselves, producing errors.
Modified:
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpFetcherTest.java
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/abdera/SocialApiProviderTestFixture.java
Modified:
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpFetcherTest.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpFetcherTest.java?rev=664434&r1=664433&r2=664434&view=diff
==============================================================================
---
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpFetcherTest.java
(original)
+++
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpFetcherTest.java
Sat Jun 7 21:09:47 2008
@@ -2,6 +2,12 @@
import static org.junit.Assert.assertEquals;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import junitx.framework.ArrayAssert;
+
import java.net.URI;
import java.net.URLEncoder;
import java.util.Arrays;
@@ -9,40 +15,33 @@
import java.util.List;
import java.util.Map;
-import junitx.framework.ArrayAssert;
-
-import org.apache.shindig.gadgets.http.EchoServer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
/**
* Holds test cases that all HttpFetcher implementations should pass. This
* starts up an HTTP server and runs tests against it.
*/
-public class AbstractHttpFetcherTest {
+public abstract class AbstractHttpFetcherTest {
private static final int ECHO_PORT = 9003;
private static final String BASE_URL = "http://localhost:9003/";
private static EchoServer server;
protected HttpFetcher fetcher = null;
-
+
private String encode(String content) throws Exception {
return URLEncoder.encode(content, "UTF-8");
}
-
+
@BeforeClass
public static void setUpOnce() throws Exception {
server = new EchoServer();
server.start(ECHO_PORT);
}
-
+
@AfterClass
public static void tearDownOnce() throws Exception {
if (server != null) {
server.stop();
}
}
-
+
@Test public void testHttpFetch() throws Exception {
String content = "Hello, world!";
HttpRequest request = new HttpRequest(new URI(
@@ -51,16 +50,16 @@
assertEquals(200, response.getHttpStatusCode());
assertEquals(content, response.getResponseAsString());
}
-
+
@Test public void testHttp404() throws Exception {
String content = "Hello, world!";
HttpRequest request = new HttpRequest(new URI(
BASE_URL + "?body=" + encode(content) + "&status=404"));
HttpResponse response = fetcher.fetch(request);
assertEquals(404, response.getHttpStatusCode());
- assertEquals(content, response.getResponseAsString());
+ assertEquals(content, response.getResponseAsString());
}
-
+
@Test public void testHttp403() throws Exception {
String content = "Hello, world!";
HttpRequest request = new HttpRequest(new URI(
@@ -71,7 +70,7 @@
assertEquals(content, response.getResponseAsString());
assertEquals("some auth data", response.getHeader("WWW-Authenticate"));
}
-
+
@Test public void testHttp403NoBody() throws Exception {
String content = "";
HttpRequest request = new HttpRequest(new URI(
@@ -80,9 +79,9 @@
HttpResponse response = fetcher.fetch(request);
assertEquals(403, response.getHttpStatusCode());
assertEquals(content, response.getResponseAsString());
- assertEquals("some auth data", response.getHeader("WWW-Authenticate"));
+ assertEquals("some auth data", response.getHeader("WWW-Authenticate"));
}
-
+
@Test public void testHttp401NoBody() throws Exception {
String content = "";
HttpRequest request = new HttpRequest(new URI(
@@ -91,16 +90,16 @@
HttpResponse response = fetcher.fetch(request);
assertEquals(401, response.getHttpStatusCode());
assertEquals(content, response.getResponseAsString());
- assertEquals("some auth data", response.getHeader("WWW-Authenticate"));
+ assertEquals("some auth data", response.getHeader("WWW-Authenticate"));
}
-
+
@Test public void testDelete() throws Exception {
HttpRequest request = new HttpRequest("DELETE", new URI(BASE_URL),
null, null, null);
HttpResponse response = fetcher.fetch(request);
assertEquals("DELETE", response.getHeader("x-method"));
}
-
+
@Test public void testPost_noBody() throws Exception {
HttpRequest request = new HttpRequest("POST", new URI(BASE_URL),
null, null, null);
@@ -108,7 +107,7 @@
assertEquals("POST", response.getHeader("x-method"));
assertEquals("", response.getResponseAsString());
}
-
+
@Test public void testPost_withBody() throws Exception {
byte[] body = new byte[5000];
for (int i=0; i < body.length; ++i) {
@@ -122,7 +121,7 @@
assertEquals("POST", response.getHeader("x-method"));
ArrayAssert.assertEquals(body, response.getResponseAsBytes());
}
-
+
@Test public void testPut_noBody() throws Exception {
HttpRequest request = new HttpRequest("PUT", new URI(BASE_URL),
null, null, null);
@@ -130,7 +129,7 @@
assertEquals("PUT", response.getHeader("x-method"));
assertEquals("", response.getResponseAsString());
}
-
+
@Test public void testPut_withBody() throws Exception {
byte[] body = new byte[5000];
for (int i=0; i < body.length; ++i) {
@@ -144,7 +143,7 @@
assertEquals("PUT", response.getHeader("x-method"));
ArrayAssert.assertEquals(body, response.getResponseAsBytes());
}
-
+
@Test public void testHugeBody() throws Exception {
byte[] body = new byte[1024*1024]; // 1 MB
for (int i=0; i < body.length; ++i) {
Modified:
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/abdera/SocialApiProviderTestFixture.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/abdera/SocialApiProviderTestFixture.java?rev=664434&r1=664433&r2=664434&view=diff
==============================================================================
---
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/abdera/SocialApiProviderTestFixture.java
(original)
+++
incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/abdera/SocialApiProviderTestFixture.java
Sat Jun 7 21:09:47 2008
@@ -21,7 +21,7 @@
import org.apache.abdera.protocol.server.RequestContext;
-public class SocialApiProviderTestFixture extends EasyMockTestCase {
+public abstract class SocialApiProviderTestFixture extends EasyMockTestCase {
public final String base = "/social/rest/";
public final RequestContext request = mock(RequestContext.class);
public final SocialApiProvider provider = new SocialApiProvider();