Skip to content

Commit

Permalink
suppress JUnit 4 dependency through hbase-client.
Browse files Browse the repository at this point in the history
rewrite WbmPersistLoadProcessorTest for JUnit 3.
  (also disable a test that depends on production CDX server)
  • Loading branch information
kngenie committed Aug 26, 2014
1 parent fc38175 commit f343ce2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<artifactId>jets3t</artifactId>
<groupId>net.java.dev.jets3t</groupId>
</exclusion>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.archive.modules.recrawl.wbm;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -17,6 +13,8 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

import junit.framework.TestCase;

import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.HttpClient;
Expand All @@ -34,13 +32,11 @@
import org.archive.util.Base32;
import org.archive.util.DateUtils;
import org.easymock.EasyMock;
import org.junit.Test;

import com.google.common.util.concurrent.ExecutionList;

/**
* unit test for {@link WbmPersistLoadProcessor}.
* depends on WBM index query API.
*
* TODO:
* <ul>
Expand All @@ -50,8 +46,8 @@
* @author kenji
*
*/
public class WbmPersistLoadProcessorTest {
@Test
public class WbmPersistLoadProcessorTest extends TestCase {

public void testBuildURL() throws Exception {
WbmPersistLoadProcessor t = new WbmPersistLoadProcessor();
t.setQueryURL("http://web.archive.org/cdx/search/cdx?url=$u&startDate=$s&limit=1");
Expand Down Expand Up @@ -97,8 +93,11 @@ private byte[] sha1Digest(String text) throws NoSuchAlgorithmException {
return md.digest(text.getBytes());
}

@Test
public void testInnerProcessResultSingleShotWithMock() throws Exception {
/**
* this test is disabled because it talks to production CDX server.
* @throws Exception
*/
public void _testInnerProcessResultSingleShotWithMock() throws Exception {
// because AbstractHttpClient marks most execute(...) methods final, it is very tiresome to implement
// a stub by implementing HttpClient interface. So I use EasyMock.
HttpClient client = EasyMock.createMock(HttpClient.class);
Expand Down Expand Up @@ -158,7 +157,6 @@ public void testInnerProcessResultSingleShotWithMock() throws Exception {
fhp.process(curi);
}

@Test
public void testInnerProcessResultSingleShotWithRealServer() throws Exception {
WbmPersistLoadProcessor t = new WbmPersistLoadProcessor();
//CrawlURI curi = new CrawlURI(UURIFactory.getInstance("http://archive.org/"));
Expand Down Expand Up @@ -195,11 +193,10 @@ public void run() {

/**
* test for performance.
* not annotated as test case. run this through main().
* not named as test case. run this through main().
* @throws Exception
*/
//@Test
public void testInnerProcessResultMany() throws Exception {
public void measureInnerProcessResultMany() throws Exception {
final WbmPersistLoadProcessor t = new WbmPersistLoadProcessor();
InputStream is = getClass().getResourceAsStream("/test-url-list.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
Expand All @@ -219,6 +216,6 @@ public void testInnerProcessResultMany() throws Exception {
}

public static void main() throws Exception {
(new WbmPersistLoadProcessorTest()).testInnerProcessResultMany();
(new WbmPersistLoadProcessorTest()).measureInnerProcessResultMany();
}
}

0 comments on commit f343ce2

Please sign in to comment.