Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/TestPrefixStringMatcher.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/TestPrefixStringMatcher.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/TestPrefixStringMatcher.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/TestPrefixStringMatcher.java Fri Jan 9 06:34:33 2015 @@ -23,98 +23,91 @@ import static org.junit.Assert.*; /** Unit tests for PrefixStringMatcher. */ public class TestPrefixStringMatcher { - private final static int NUM_TEST_ROUNDS= 20; - private final static int MAX_TEST_PREFIXES= 100; - private final static int MAX_PREFIX_LEN= 10; - private final static int NUM_TEST_INPUTS_PER_ROUND= 100; - private final static int MAX_INPUT_LEN= 20; - - private final static char[] alphabet= - new char[] { - 'a', 'b', 'c', 'd', -// 'e', 'f', 'g', 'h', 'i', 'j', -// 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', -// 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', -// '5', '6', '7', '8', '9', '0' - }; + private final static int NUM_TEST_ROUNDS = 20; + private final static int MAX_TEST_PREFIXES = 100; + private final static int MAX_PREFIX_LEN = 10; + private final static int NUM_TEST_INPUTS_PER_ROUND = 100; + private final static int MAX_INPUT_LEN = 20; + + private final static char[] alphabet = new char[] { 'a', 'b', 'c', 'd', + // 'e', 'f', 'g', 'h', 'i', 'j', + // 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + // 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', + // '5', '6', '7', '8', '9', '0' + }; private String makeRandString(int minLen, int maxLen) { - int len= minLen + (int) (Math.random() * (maxLen - minLen)); - char[] chars= new char[len]; - - for (int pos= 0; pos < len; pos++) { - chars[pos]= alphabet[(int) (Math.random() * alphabet.length)]; + int len = minLen + (int) (Math.random() * (maxLen - minLen)); + char[] chars = new char[len]; + + for (int pos = 0; pos < len; pos++) { + chars[pos] = alphabet[(int) (Math.random() * alphabet.length)]; } - + return new String(chars); } - + @Test public void testPrefixMatcher() { - int numMatches= 0; - int numInputsTested= 0; + int numMatches = 0; + int numInputsTested = 0; - for (int round= 0; round < NUM_TEST_ROUNDS; round++) { + for (int round = 0; round < NUM_TEST_ROUNDS; round++) { // build list of prefixes - int numPrefixes= (int) (Math.random() * MAX_TEST_PREFIXES); - String[] prefixes= new String[numPrefixes]; - for (int i= 0; i < numPrefixes; i++) { - prefixes[i]= makeRandString(0, MAX_PREFIX_LEN); + int numPrefixes = (int) (Math.random() * MAX_TEST_PREFIXES); + String[] prefixes = new String[numPrefixes]; + for (int i = 0; i < numPrefixes; i++) { + prefixes[i] = makeRandString(0, MAX_PREFIX_LEN); } - PrefixStringMatcher prematcher= new PrefixStringMatcher(prefixes); + PrefixStringMatcher prematcher = new PrefixStringMatcher(prefixes); // test random strings for prefix matches - for (int i= 0; i < NUM_TEST_INPUTS_PER_ROUND; i++) { - String input= makeRandString(0, MAX_INPUT_LEN); - boolean matches= false; - int longestMatch= -1; - int shortestMatch= -1; - - for (int j= 0; j < prefixes.length; j++) { - - if ((prefixes[j].length() > 0) - && input.startsWith(prefixes[j])) { - - matches= true; - int matchSize= prefixes[j].length(); - - if (matchSize > longestMatch) - longestMatch= matchSize; - - if ( (matchSize < shortestMatch) - || (shortestMatch == -1) ) - shortestMatch= matchSize; + for (int i = 0; i < NUM_TEST_INPUTS_PER_ROUND; i++) { + String input = makeRandString(0, MAX_INPUT_LEN); + boolean matches = false; + int longestMatch = -1; + int shortestMatch = -1; + + for (int j = 0; j < prefixes.length; j++) { + + if ((prefixes[j].length() > 0) && input.startsWith(prefixes[j])) { + + matches = true; + int matchSize = prefixes[j].length(); + + if (matchSize > longestMatch) + longestMatch = matchSize; + + if ((matchSize < shortestMatch) || (shortestMatch == -1)) + shortestMatch = matchSize; } } - if (matches) + if (matches) numMatches++; numInputsTested++; - assertTrue( "'" + input + "' should " + (matches ? "" : "not ") - + "match!", - matches == prematcher.matches(input) ); + assertTrue("'" + input + "' should " + (matches ? "" : "not ") + + "match!", matches == prematcher.matches(input)); if (matches) { - assertTrue( shortestMatch - == prematcher.shortestMatch(input).length()); - assertTrue( input.substring(0, shortestMatch).equals( - prematcher.shortestMatch(input)) ); - - assertTrue( longestMatch - == prematcher.longestMatch(input).length()); - assertTrue( input.substring(0, longestMatch).equals( - prematcher.longestMatch(input)) ); + assertTrue(shortestMatch == prematcher.shortestMatch(input).length()); + assertTrue(input.substring(0, shortestMatch).equals( + prematcher.shortestMatch(input))); + + assertTrue(longestMatch == prematcher.longestMatch(input).length()); + assertTrue(input.substring(0, longestMatch).equals( + prematcher.longestMatch(input))); } } } - System.out.println("got " + numMatches + " matches out of " - + numInputsTested + " tests"); + System.out.println("got " + numMatches + " matches out of " + + numInputsTested + " tests"); } }
Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/TestStringUtil.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/TestStringUtil.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/TestStringUtil.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/TestStringUtil.java Fri Jan 9 06:34:33 2015 @@ -25,37 +25,37 @@ public class TestStringUtil { @Test public void testRightPad() { - String s= "my string"; + String s = "my string"; - String ps= StringUtil.rightPad(s, 0); + String ps = StringUtil.rightPad(s, 0); assertTrue(s.equals(ps)); - ps= StringUtil.rightPad(s, 9); + ps = StringUtil.rightPad(s, 9); assertTrue(s.equals(ps)); - ps= StringUtil.rightPad(s, 10); - assertTrue( (s+" ").equals(ps) ); + ps = StringUtil.rightPad(s, 10); + assertTrue((s + " ").equals(ps)); - ps= StringUtil.rightPad(s, 15); - assertTrue( (s+" ").equals(ps) ); + ps = StringUtil.rightPad(s, 15); + assertTrue((s + " ").equals(ps)); } @Test public void testLeftPad() { - String s= "my string"; + String s = "my string"; - String ps= StringUtil.leftPad(s, 0); + String ps = StringUtil.leftPad(s, 0); assertTrue(s.equals(ps)); - ps= StringUtil.leftPad(s, 9); + ps = StringUtil.leftPad(s, 9); assertTrue(s.equals(ps)); - ps= StringUtil.leftPad(s, 10); - assertTrue( (" "+s).equals(ps) ); + ps = StringUtil.leftPad(s, 10); + assertTrue((" " + s).equals(ps)); - ps= StringUtil.leftPad(s, 15); - assertTrue( (" "+s).equals(ps) ); + ps = StringUtil.leftPad(s, 15); + assertTrue((" " + s).equals(ps)); } Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/TestSuffixStringMatcher.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/TestSuffixStringMatcher.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/TestSuffixStringMatcher.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/TestSuffixStringMatcher.java Fri Jan 9 06:34:33 2015 @@ -23,98 +23,91 @@ import static org.junit.Assert.*; /** Unit tests for SuffixStringMatcher. */ public class TestSuffixStringMatcher { - private final static int NUM_TEST_ROUNDS= 20; - private final static int MAX_TEST_SUFFIXES= 100; - private final static int MAX_SUFFIX_LEN= 10; - private final static int NUM_TEST_INPUTS_PER_ROUND= 100; - private final static int MAX_INPUT_LEN= 20; - - private final static char[] alphabet= - new char[] { - 'a', 'b', 'c', 'd', -// 'e', 'f', 'g', 'h', 'i', 'j', -// 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', -// 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', -// '5', '6', '7', '8', '9', '0' - }; + private final static int NUM_TEST_ROUNDS = 20; + private final static int MAX_TEST_SUFFIXES = 100; + private final static int MAX_SUFFIX_LEN = 10; + private final static int NUM_TEST_INPUTS_PER_ROUND = 100; + private final static int MAX_INPUT_LEN = 20; + + private final static char[] alphabet = new char[] { 'a', 'b', 'c', 'd', + // 'e', 'f', 'g', 'h', 'i', 'j', + // 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + // 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', + // '5', '6', '7', '8', '9', '0' + }; private String makeRandString(int minLen, int maxLen) { - int len= minLen + (int) (Math.random() * (maxLen - minLen)); - char[] chars= new char[len]; - - for (int pos= 0; pos < len; pos++) { - chars[pos]= alphabet[(int) (Math.random() * alphabet.length)]; + int len = minLen + (int) (Math.random() * (maxLen - minLen)); + char[] chars = new char[len]; + + for (int pos = 0; pos < len; pos++) { + chars[pos] = alphabet[(int) (Math.random() * alphabet.length)]; } - + return new String(chars); } - + @Test public void testSuffixMatcher() { - int numMatches= 0; - int numInputsTested= 0; + int numMatches = 0; + int numInputsTested = 0; - for (int round= 0; round < NUM_TEST_ROUNDS; round++) { + for (int round = 0; round < NUM_TEST_ROUNDS; round++) { // build list of suffixes - int numSuffixes= (int) (Math.random() * MAX_TEST_SUFFIXES); - String[] suffixes= new String[numSuffixes]; - for (int i= 0; i < numSuffixes; i++) { - suffixes[i]= makeRandString(0, MAX_SUFFIX_LEN); + int numSuffixes = (int) (Math.random() * MAX_TEST_SUFFIXES); + String[] suffixes = new String[numSuffixes]; + for (int i = 0; i < numSuffixes; i++) { + suffixes[i] = makeRandString(0, MAX_SUFFIX_LEN); } - SuffixStringMatcher sufmatcher= new SuffixStringMatcher(suffixes); + SuffixStringMatcher sufmatcher = new SuffixStringMatcher(suffixes); // test random strings for suffix matches - for (int i= 0; i < NUM_TEST_INPUTS_PER_ROUND; i++) { - String input= makeRandString(0, MAX_INPUT_LEN); - boolean matches= false; - int longestMatch= -1; - int shortestMatch= -1; - - for (int j= 0; j < suffixes.length; j++) { - - if ((suffixes[j].length() > 0) - && input.endsWith(suffixes[j])) { - - matches= true; - int matchSize= suffixes[j].length(); - - if (matchSize > longestMatch) - longestMatch= matchSize; - - if ( (matchSize < shortestMatch) - || (shortestMatch == -1) ) - shortestMatch= matchSize; + for (int i = 0; i < NUM_TEST_INPUTS_PER_ROUND; i++) { + String input = makeRandString(0, MAX_INPUT_LEN); + boolean matches = false; + int longestMatch = -1; + int shortestMatch = -1; + + for (int j = 0; j < suffixes.length; j++) { + + if ((suffixes[j].length() > 0) && input.endsWith(suffixes[j])) { + + matches = true; + int matchSize = suffixes[j].length(); + + if (matchSize > longestMatch) + longestMatch = matchSize; + + if ((matchSize < shortestMatch) || (shortestMatch == -1)) + shortestMatch = matchSize; } } - if (matches) + if (matches) numMatches++; numInputsTested++; - assertTrue( "'" + input + "' should " + (matches ? "" : "not ") - + "match!", - matches == sufmatcher.matches(input) ); + assertTrue("'" + input + "' should " + (matches ? "" : "not ") + + "match!", matches == sufmatcher.matches(input)); if (matches) { - assertTrue( shortestMatch - == sufmatcher.shortestMatch(input).length()); - assertTrue( input.substring(input.length() - shortestMatch).equals( - sufmatcher.shortestMatch(input)) ); - - assertTrue( longestMatch - == sufmatcher.longestMatch(input).length()); - assertTrue( input.substring(input.length() - longestMatch).equals( - sufmatcher.longestMatch(input)) ); + assertTrue(shortestMatch == sufmatcher.shortestMatch(input).length()); + assertTrue(input.substring(input.length() - shortestMatch).equals( + sufmatcher.shortestMatch(input))); + + assertTrue(longestMatch == sufmatcher.longestMatch(input).length()); + assertTrue(input.substring(input.length() - longestMatch).equals( + sufmatcher.longestMatch(input))); } } } - System.out.println("got " + numMatches + " matches out of " - + numInputsTested + " tests"); + System.out.println("got " + numMatches + " matches out of " + + numInputsTested + " tests"); } } Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/TestTableUtil.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/TestTableUtil.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/TestTableUtil.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/TestTableUtil.java Fri Jan 9 06:34:33 2015 @@ -44,10 +44,10 @@ public class TestTableUtil { assertReverse(urlString1, reversedUrlString1); assertReverse(urlString2, reversedUrlString2); assertReverse(urlString3, reversedUrlString3); - assertReverse(urlString4, reversedUrlString4); - assertReverse(urlString5, reversedUrlString5); - assertReverse(urlString5, reversedUrlString5); - assertReverse(urlString6, reversedUrlString6); + assertReverse(urlString4, reversedUrlString4); + assertReverse(urlString5, reversedUrlString5); + assertReverse(urlString5, reversedUrlString5); + assertReverse(urlString6, reversedUrlString6); assertReverse(urlString7, reversedUrlString7); } @@ -62,7 +62,8 @@ public class TestTableUtil { assertUnreverse(reversedUrlString7, urlString7); } - private static void assertReverse(String url, String expectedReversedUrl) throws Exception { + private static void assertReverse(String url, String expectedReversedUrl) + throws Exception { String reversed = TableUtil.reverseUrl(url); assertEquals(expectedReversedUrl, reversed); } Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/TestURLUtil.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/TestURLUtil.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/TestURLUtil.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/TestURLUtil.java Fri Jan 9 06:34:33 2015 @@ -26,8 +26,7 @@ import static org.junit.Assert.*; public class TestURLUtil { @Test - public void testGetDomainName() - throws Exception { + public void testGetDomainName() throws Exception { URL url = null; @@ -77,8 +76,7 @@ public class TestURLUtil { } @Test - public void testGetDomainSuffix() - throws Exception { + public void testGetDomainSuffix() throws Exception { URL url = null; url = new URL("http://lucene.apache.org/nutch"); @@ -130,8 +128,7 @@ public class TestURLUtil { } @Test - public void testGetHostBatches() - throws Exception { + public void testGetHostBatches() throws Exception { URL url; String[] batches; @@ -163,9 +160,8 @@ public class TestURLUtil { } @Test - public void testChooseRepr() - throws Exception { - + public void testChooseRepr() throws Exception { + String aDotCom = "http://www.a.com"; String bDotCom = "http://www.b.com"; String aSubDotCom = "http://www.news.a.com"; @@ -173,71 +169,60 @@ public class TestURLUtil { String aPath = "http://www.a.com/xyz/index.html"; String aPath2 = "http://www.a.com/abc/page.html"; String aPath3 = "http://www.news.a.com/abc/page.html"; - + // 1) different domain them keep dest, temp or perm // a.com -> b.com* assertEquals(bDotCom, URLUtil.chooseRepr(aDotCom, bDotCom, true)); assertEquals(bDotCom, URLUtil.chooseRepr(aDotCom, bDotCom, false)); - + // 2) permanent and root, keep src // *a.com -> a.com?y=1 || *a.com -> a.com/xyz/index.html assertEquals(aDotCom, URLUtil.chooseRepr(aDotCom, aQStr, false)); assertEquals(aDotCom, URLUtil.chooseRepr(aDotCom, aPath, false)); - - //3) permanent and not root and dest root, keep dest - //a.com/xyz/index.html -> a.com* + + // 3) permanent and not root and dest root, keep dest + // a.com/xyz/index.html -> a.com* assertEquals(aDotCom, URLUtil.chooseRepr(aPath, aDotCom, false)); - - //4) permanent and neither root keep dest + + // 4) permanent and neither root keep dest // a.com/xyz/index.html -> a.com/abc/page.html* assertEquals(aPath2, URLUtil.chooseRepr(aPath, aPath2, false)); - - //5) temp and root and dest not root keep src - //*a.com -> a.com/xyz/index.html + + // 5) temp and root and dest not root keep src + // *a.com -> a.com/xyz/index.html assertEquals(aDotCom, URLUtil.chooseRepr(aDotCom, aPath, true)); - - //6) temp and not root and dest root keep dest + + // 6) temp and not root and dest root keep dest // a.com/xyz/index.html -> a.com* assertEquals(aDotCom, URLUtil.chooseRepr(aPath, aDotCom, true)); - //7) temp and neither root, keep shortest, if hosts equal by path else by hosts - // a.com/xyz/index.html -> a.com/abc/page.html* + // 7) temp and neither root, keep shortest, if hosts equal by path else by + // hosts + // a.com/xyz/index.html -> a.com/abc/page.html* // *www.a.com/xyz/index.html -> www.news.a.com/xyz/index.html assertEquals(aPath2, URLUtil.chooseRepr(aPath, aPath2, true)); assertEquals(aPath, URLUtil.chooseRepr(aPath, aPath3, true)); - //8) temp and both root keep shortest sub domain + // 8) temp and both root keep shortest sub domain // *www.a.com -> www.news.a.com assertEquals(aDotCom, URLUtil.chooseRepr(aDotCom, aSubDotCom, true)); } - + // from RFC3986 section 5.4.1 private static String baseString = "http://a/b/c/d;p?q"; private static String[][] targets = new String[][] { - // unknown protocol {"g:h" , "g:h"}, - {"g" , "http://a/b/c/g"}, - { "./g" , "http://a/b/c/g"}, - { "g/" , "http://a/b/c/g/"}, - { "/g" , "http://a/g"}, - { "//g" , "http://g"}, - { "?y" , "http://a/b/c/d;p?y"}, - { "g?y" , "http://a/b/c/g?y"}, - { "#s" , "http://a/b/c/d;p?q#s"}, - { "g#s" , "http://a/b/c/g#s"}, - { "g?y#s" , "http://a/b/c/g?y#s"}, - { ";x" , "http://a/b/c/;x"}, - { "g;x" , "http://a/b/c/g;x"}, - { "g;x?y#s" , "http://a/b/c/g;x?y#s"}, - { "" , "http://a/b/c/d;p?q"}, - { "." , "http://a/b/c/"}, - { "./" , "http://a/b/c/"}, - { ".." , "http://a/b/"}, - { "../" , "http://a/b/"}, - { "../g" , "http://a/b/g"}, - { "../.." , "http://a/"}, - { "../../" , "http://a/"}, - { "../../g" , "http://a/g"} - }; + // unknown protocol {"g:h" , "g:h"}, + { "g", "http://a/b/c/g" }, { "./g", "http://a/b/c/g" }, + { "g/", "http://a/b/c/g/" }, { "/g", "http://a/g" }, + { "//g", "http://g" }, { "?y", "http://a/b/c/d;p?y" }, + { "g?y", "http://a/b/c/g?y" }, { "#s", "http://a/b/c/d;p?q#s" }, + { "g#s", "http://a/b/c/g#s" }, { "g?y#s", "http://a/b/c/g?y#s" }, + { ";x", "http://a/b/c/;x" }, { "g;x", "http://a/b/c/g;x" }, + { "g;x?y#s", "http://a/b/c/g;x?y#s" }, { "", "http://a/b/c/d;p?q" }, + { ".", "http://a/b/c/" }, { "./", "http://a/b/c/" }, + { "..", "http://a/b/" }, { "../", "http://a/b/" }, + { "../g", "http://a/b/g" }, { "../..", "http://a/" }, + { "../../", "http://a/" }, { "../../g", "http://a/g" } }; @Test public void testResolveURL() throws Exception { @@ -249,7 +234,8 @@ public class TestURLUtil { // test NUTCH-566 URL u566 = new URL("http://www.fleurie.org/entreprise.asp"); abs = URLUtil.resolveURL(u566, "?id_entrep=111"); - assertEquals("http://www.fleurie.org/entreprise.asp?id_entrep=111", abs.toString()); + assertEquals("http://www.fleurie.org/entreprise.asp?id_entrep=111", + abs.toString()); URL base = new URL(baseString); assertEquals("base url parsing", baseString, base.toString()); for (int i = 0; i < targets.length; i++) { @@ -257,31 +243,39 @@ public class TestURLUtil { assertEquals(targets[i][1], targets[i][1], u.toString()); } } - + @Test public void testToUNICODE() throws Exception { - assertEquals("http://www.çevir.com", URLUtil.toUNICODE("http://www.xn--evir-zoa.com")); - assertEquals("http://uni-tübingen.de/", URLUtil.toUNICODE("http://xn--uni-tbingen-xhb.de/")); + assertEquals("http://www.çevir.com", + URLUtil.toUNICODE("http://www.xn--evir-zoa.com")); + assertEquals("http://uni-tübingen.de/", + URLUtil.toUNICODE("http://xn--uni-tbingen-xhb.de/")); assertEquals( "http://www.medizin.uni-tübingen.de:8080/search.php?q=abc#p1", - URLUtil.toUNICODE("http://www.medizin.xn--uni-tbingen-xhb.de:8080/search.php?q=abc#p1")); - + URLUtil + .toUNICODE("http://www.medizin.xn--uni-tbingen-xhb.de:8080/search.php?q=abc#p1")); + } - + @Test public void testToASCII() throws Exception { - assertEquals("http://www.xn--evir-zoa.com", URLUtil.toASCII("http://www.çevir.com")); - assertEquals("http://xn--uni-tbingen-xhb.de/", URLUtil.toASCII("http://uni-tübingen.de/")); + assertEquals("http://www.xn--evir-zoa.com", + URLUtil.toASCII("http://www.çevir.com")); + assertEquals("http://xn--uni-tbingen-xhb.de/", + URLUtil.toASCII("http://uni-tübingen.de/")); assertEquals( "http://www.medizin.xn--uni-tbingen-xhb.de:8080/search.php?q=abc#p1", - URLUtil.toASCII("http://www.medizin.uni-tübingen.de:8080/search.php?q=abc#p1")); + URLUtil + .toASCII("http://www.medizin.uni-tübingen.de:8080/search.php?q=abc#p1")); } @Test public void testFileProtocol() throws Exception { // keep one single slash NUTCH-XXX - assertEquals("file:/path/file.html", URLUtil.toASCII("file:/path/file.html")); - assertEquals("file:/path/file.html", URLUtil.toUNICODE("file:/path/file.html")); + assertEquals("file:/path/file.html", + URLUtil.toASCII("file:/path/file.html")); + assertEquals("file:/path/file.html", + URLUtil.toUNICODE("file:/path/file.html")); } } Modified: nutch/branches/2.x/src/test/org/apache/nutch/util/WritableTestUtils.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/util/WritableTestUtils.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/util/WritableTestUtils.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/util/WritableTestUtils.java Fri Jan 9 06:34:33 2015 @@ -35,23 +35,22 @@ public class WritableTestUtils { TestCase.assertEquals(before, writeRead(before, conf)); } - /** Utility method for testing writables. */ public static Writable writeRead(Writable before, Configuration conf) - throws Exception { - + throws Exception { + DataOutputBuffer dob = new DataOutputBuffer(); before.write(dob); - + DataInputBuffer dib = new DataInputBuffer(); dib.reset(dob.getData(), dob.getLength()); - - Writable after = (Writable)before.getClass().newInstance(); + + Writable after = (Writable) before.getClass().newInstance(); if (conf != null) { - ((Configurable)after).setConf(conf); + ((Configurable) after).setConf(conf); } after.readFields(dib); return after; } - + } Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestCrawlCycle.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestCrawlCycle.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestCrawlCycle.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestCrawlCycle.java Fri Jan 9 06:34:33 2015 @@ -59,13 +59,15 @@ public class TestCrawlCycle { public void setUp() { JobInfo jobInfo = new JobInfo(); jobInfo.setState(State.FINISHED); - given(executor.executeRemoteJob(any(RemoteCommand.class))).willReturn(jobInfo); + given(executor.executeRemoteJob(any(RemoteCommand.class))).willReturn( + jobInfo); } @Test public void shouldInvokeCrawlStartedAndFinished() { // given - List<RemoteCommand> commands = newArrayList(RemoteCommandBuilder.instance(INJECT).build()); + List<RemoteCommand> commands = newArrayList(RemoteCommandBuilder.instance( + INJECT).build()); Crawl crawl = new Crawl(); crawlingCycle = new CrawlingCycle(listener, executor, crawl, commands); @@ -81,14 +83,16 @@ public class TestCrawlCycle { @Test public void shouldInvokeOnError() { // given - List<RemoteCommand> commands = newArrayList(RemoteCommandBuilder.instance(INJECT).build()); + List<RemoteCommand> commands = newArrayList(RemoteCommandBuilder.instance( + INJECT).build()); Crawl crawl = new Crawl(); crawlingCycle = new CrawlingCycle(listener, executor, crawl, commands); JobInfo jobInfo = new JobInfo(); jobInfo.setMsg("Some error message"); jobInfo.setState(State.FAILED); - given(executor.executeRemoteJob(any(RemoteCommand.class))).willReturn(jobInfo); + given(executor.executeRemoteJob(any(RemoteCommand.class))).willReturn( + jobInfo); // when crawlingCycle.executeCrawlCycle(); @@ -101,7 +105,8 @@ public class TestCrawlCycle { public void shouldCalculateProgress() { // given RemoteCommand firstCommand = RemoteCommandBuilder.instance(INJECT).build(); - RemoteCommand secondCommand = RemoteCommandBuilder.instance(GENERATE).build(); + RemoteCommand secondCommand = RemoteCommandBuilder.instance(GENERATE) + .build(); List<RemoteCommand> commands = newArrayList(firstCommand, secondCommand); Crawl crawl = new Crawl(); Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestNutchClientFactory.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestNutchClientFactory.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestNutchClientFactory.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestNutchClientFactory.java Fri Jan 9 06:34:33 2015 @@ -27,7 +27,7 @@ import org.mockito.runners.MockitoJUnitR @RunWith(MockitoJUnitRunner.class) public class TestNutchClientFactory { - + @InjectMocks private NutchClientFactory factory; @@ -55,7 +55,7 @@ public class TestNutchClientFactory { // then assertSame(client, client2); } - + @Test public void shouldReturnNewClientForOtherInstance() { // given Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandExecutor.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandExecutor.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandExecutor.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandExecutor.java Fri Jan 9 06:34:33 2015 @@ -42,7 +42,8 @@ public class TestRemoteCommandExecutor { private NutchClient client; @InjectMocks - private RemoteCommandExecutor remoteExecutor = new RemoteCommandExecutor(client); + private RemoteCommandExecutor remoteExecutor = new RemoteCommandExecutor( + client); @Before public void setUp() { @@ -52,7 +53,8 @@ public class TestRemoteCommandExecutor { @Test public void shouldExecuteCommandRemotely() { // given - RemoteCommand command = RemoteCommandBuilder.instance(JobType.INJECT).build(); + RemoteCommand command = RemoteCommandBuilder.instance(JobType.INJECT) + .build(); JobInfo jobInfo = new JobInfo(); jobInfo.setState(State.FINISHED); given(client.getJobInfo(anyString())).willReturn(jobInfo); Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandsBatchFactory.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandsBatchFactory.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandsBatchFactory.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/client/TestRemoteCommandsBatchFactory.java Fri Jan 9 06:34:33 2015 @@ -42,8 +42,9 @@ import com.google.common.collect.Lists; public class TestRemoteCommandsBatchFactory { private RemoteCommandsBatchFactory factory; - private List<JobType> executionSequence = Lists.newArrayList(INJECT, GENERATE, FETCH, PARSE, - UPDATEDB, INDEX, GENERATE, FETCH, PARSE, UPDATEDB, INDEX); + private List<JobType> executionSequence = Lists.newArrayList(INJECT, + GENERATE, FETCH, PARSE, UPDATEDB, INDEX, GENERATE, FETCH, PARSE, + UPDATEDB, INDEX); @Before public void setUp() { @@ -61,7 +62,8 @@ public class TestRemoteCommandsBatchFact // then for (int i = 0; i < commands.size(); i++) { - assertTrue(commands.get(i).getJobConfig().getType() == executionSequence.get(i)); + assertTrue(commands.get(i).getJobConfig().getType() == executionSequence + .get(i)); } } @@ -75,8 +77,10 @@ public class TestRemoteCommandsBatchFact List<RemoteCommand> commands = factory.createCommands(crawl); // then - String batchId = (String) commands.get(1).getJobConfig().getArgs().get("batch"); - String secondBatchId = (String) commands.get(7).getJobConfig().getArgs().get("batch"); + String batchId = (String) commands.get(1).getJobConfig().getArgs() + .get("batch"); + String secondBatchId = (String) commands.get(7).getJobConfig().getArgs() + .get("batch"); assertNotEquals(batchId, secondBatchId); } } Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/service/NutchServiceTest.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/service/NutchServiceTest.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/service/NutchServiceTest.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/service/NutchServiceTest.java Fri Jan 9 06:34:33 2015 @@ -40,7 +40,8 @@ public class NutchServiceTest { public void shouldReturnEmptyMapOnException() { // given given(clientFactory.getClient(any(NutchInstance.class))).willReturn(client); - given(client.getNutchConfig("default")).willThrow(new ClientHandlerException("Error!")); + given(client.getNutchConfig("default")).willThrow( + new ClientHandlerException("Error!")); // when Map<String, String> config = nutchService.getNutchConfig(1L); Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/view/SpringConfigForTests.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/view/SpringConfigForTests.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/view/SpringConfigForTests.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/view/SpringConfigForTests.java Fri Jan 9 06:34:33 2015 @@ -29,7 +29,8 @@ public class SpringConfigForTests { @Bean public JdbcConnectionSource getConnectionSource() throws SQLException { - JdbcConnectionSource source = new JdbcConnectionSource("jdbc:h2:mem:", new H2DatabaseType()); + JdbcConnectionSource source = new JdbcConnectionSource("jdbc:h2:mem:", + new H2DatabaseType()); source.initialize(); return source; } Modified: nutch/branches/2.x/src/test/org/apache/nutch/webui/view/TestColorEnumLabel.java URL: http://svn.apache.org/viewvc/nutch/branches/2.x/src/test/org/apache/nutch/webui/view/TestColorEnumLabel.java?rev=1650447&r1=1650446&r2=1650447&view=diff ============================================================================== --- nutch/branches/2.x/src/test/org/apache/nutch/webui/view/TestColorEnumLabel.java (original) +++ nutch/branches/2.x/src/test/org/apache/nutch/webui/view/TestColorEnumLabel.java Fri Jan 9 06:34:33 2015 @@ -33,8 +33,8 @@ public class TestColorEnumLabel extends public void shouldRenderCorrectText() { // given Model<ConnectionStatus> model = Model.of(ConnectionStatus.CONNECTED); - ColorEnumLabel<ConnectionStatus> label = new ColorEnumLabelBuilder<ConnectionStatus>("status") - .withModel(model).build(); + ColorEnumLabel<ConnectionStatus> label = new ColorEnumLabelBuilder<ConnectionStatus>( + "status").withModel(model).build(); // when tester.startComponentInPage(label); @@ -47,13 +47,14 @@ public class TestColorEnumLabel extends public void shouldChangeColorOfLabel() { // given Model<ConnectionStatus> model = Model.of(ConnectionStatus.CONNECTED); - ColorEnumLabel<ConnectionStatus> label = new ColorEnumLabelBuilder<ConnectionStatus>("status") - .withEnumColor(CONNECTED, Success).withModel(model).build(); + ColorEnumLabel<ConnectionStatus> label = new ColorEnumLabelBuilder<ConnectionStatus>( + "status").withEnumColor(CONNECTED, Success).withModel(model).build(); // when tester.startComponentInPage(label); // then - assertTrue(tester.getTagByWicketId("status").getAttributeEndsWith("class", "success")); + assertTrue(tester.getTagByWicketId("status").getAttributeEndsWith("class", + "success")); } }
