clean up test sources

rename to current package names and move to default location
pull/1/head
reger 11 years ago
parent d346520ed6
commit c8d437b69a

@ -1,111 +0,0 @@
package de.anomic.data;
import junit.framework.TestCase;
public class DiffTest extends TestCase {
final static boolean _1 = true; // temporary variables to make the matrix more readable
final static boolean __ = false;
boolean[][] matrix =
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,_1,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,_1,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,_1,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,_1,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{_1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,_1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,_1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,_1,__,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,_1,__,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,_1,__,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
,{__,__,__,__,__,__,_1,__,__,__,__,__,__,__,__,__,__,_1,_1,_1}
};
/*
boolean[][] matrix = // [x][y] // a another test matrix
{
// 0 1 2 3 4 5 // X == 6
{__,__,__,__,__,__} // 0
,{_1,__,__,__,__,__} // 1
,{__,_1,__,__,__,__} // 2
,{__,__,_1,__,__,__} // 3
,{__,__,__,_1,__,__} // 4
,{__,__,__,__,_1,__} // 5
,{__,__,__,__,__,_1} // 6
}; // Y == 7
*/
/** the old buggy version */
private static int[] findDiagonalOld(int x, int y, boolean[][] matrix, int minLength) {
int rx, ry, yy, xx, i;
// Zeilenweise nach Diagonalen mit mindest-Laenge minLength suchen
for (yy=y; yy<matrix.length; yy++)
for (xx=x; xx<matrix[yy].length; xx++)
if (matrix[yy][xx]) {
rx = xx;
ry = yy;
for (i=1; (yy + i)<matrix.length && (xx + i)<matrix[yy].length; i++)
if (!matrix[yy + i][xx + i]) break;
if (i <= minLength && yy + i < matrix.length && xx + i < matrix[yy].length) {
// vorzeitig abgebrochen => zuwenige chars in Diagonale => weitersuchen
continue;
} else {
return new int[] { rx, ry, i };
}
}
return null;
}
/** the fixed version */
private static int[] findDiagonalNew(int x, int y, boolean[][] matrix, int minLength) {
int rx, ry, yy, xx, i;
for (yy=y; yy<matrix.length; yy++)
for (xx=x; xx<matrix[yy].length; xx++)
if (matrix[yy][xx]) { // reverse order! [y][x]
rx = xx;
ry = yy;
for (i=1; (yy + i)<matrix.length && (xx + i)<matrix[yy].length; i++)
if (!matrix[yy + i][xx + i])
break;
if (i >= minLength)
return new int[] { rx, ry, i }; // swap back the x and y axes for better readability
}
return null;
}
public void testReplace()
{
int[] vectorOld;
int[] vectorNew;
int minLength = 6;
int x = 0;
int y = 0;
System.out.println("matrix.length: " + matrix.length) ;
System.out.println("matrix[0].length: " + matrix[0].length) ;
vectorOld = findDiagonalOld(x, y, matrix, minLength);
vectorNew = findDiagonalNew(x, y, matrix, minLength);
System.out.print("vectorOld: [ ");
if (vectorOld != null)
for (int i = 0; i < vectorOld.length; i++)
System.out.print(vectorOld[i] + ", ");
System.out.println("]");
System.out.print("vectorNew: [ ");
if (vectorNew != null)
for (int i = 0; i < vectorNew.length; i++)
System.out.print(vectorNew[i] + ", ");
System.out.println("]");
}
}

@ -1,12 +1,12 @@
package net.yacy.cora.document.id;
import java.net.MalformedURLException;
import junit.framework.TestCase;
import org.junit.Test;
public class DigestURLTest extends TestCase {
@Test
public void testIdentPort() throws MalformedURLException {
String[][] testStrings = new String[][]{
new String[]{"http://www.yacy.net:", "http://www.yacy.net/"},

@ -79,13 +79,16 @@ public class MultiProtocolURLTest {
// valid IPv6 local loopback addresses
testurls.put("http://[0:0:0:0:0:0:0:1]/index.html", Boolean.TRUE);
testurls.put("http://[::1]/index.html", Boolean.TRUE);
testurls.put("http://[::1]:8090/index.html", Boolean.TRUE);
testurls.put("http://[0::1]/index.html", Boolean.TRUE);
// test urls for issue with IPv6 misinterpretation
// test urls for possible issue with IPv6 misinterpretation
testurls.put("http://fcedit.com", Boolean.FALSE);
testurls.put("http://fdedit.com", Boolean.FALSE);
testurls.put("http://fe8edit.com", Boolean.FALSE);
// valid IPv6 examples taken from http://www.ietf.org/rfc/rfc2732.txt cap 2.
testurls.put("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html", Boolean.FALSE);
testurls.put("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html", Boolean.TRUE); // ip is link-local (fe80/10)
testurls.put("http://[1080:0:0:0:8:800:200C:417A]/index.html", Boolean.FALSE);
testurls.put("http://[3ffe:2a00:100:7031::1]", Boolean.FALSE);
testurls.put("http://[1080::8:800:200C:417A]/foo", Boolean.FALSE);
@ -98,8 +101,8 @@ public class MultiProtocolURLTest {
MultiProtocolURL uri = new MultiProtocolURL(u);
boolean result = uri.isLocal();
assertEquals(u, testurls.get(u), result);
System.out.println ("testIsLocal: " + u + " -> " + result);
assertEquals(u, testurls.get(u), result);
}
}

@ -44,20 +44,15 @@ public class EmbeddedSolrConnectorTest {
* Test of query solr via jetty
*/
@Test
public void testQuery() {
public void testQuery() throws IOException {
System.out.println("adding test document to solr");
SolrInputDocument doc = new SolrInputDocument();
doc.addField(CollectionSchema.id.name(), "ABCD0000abcd");
doc.addField(CollectionSchema.title.name(), "Lorem ipsum");
doc.addField(CollectionSchema.host_s.name(), "yacy.net");
doc.addField(CollectionSchema.text_t.name(), "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
try {
solr.add(doc);
} catch (final IOException ex) {
fail("IOException adding test document to Solr");
} catch (final SolrException ex) {
fail("SolrExceptin adding test document to Solr");
}
solr.add(doc);
solr.commit(true);
System.out.println("query solr");

@ -1,17 +1,15 @@
package de.anomic.kelondro.util;
package net.yacy.cora.protocol;
import java.util.Date;
import net.yacy.cora.protocol.HeaderFramework;
import junit.framework.TestCase;
import org.junit.Test;
public class DateFormatterTest extends TestCase {
public class HeaderFrameworkTest extends TestCase {
/**
* Test of httpHeader date parsing routine
*/
@Test
public void testParseHTTPDate() {
Date parsedDate = HeaderFramework.parseHTTPDate("Tue, 08 Jul 2003 21:22:46 GMT");

@ -1,4 +1,4 @@
package de.anomic.document;
package net.yacy.document;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
@ -12,10 +12,6 @@ import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import net.yacy.cora.document.id.AnchorURL;
import net.yacy.document.AbstractParser;
import net.yacy.document.Document;
import net.yacy.document.Parser;
import net.yacy.document.parser.docParser;
import net.yacy.document.parser.odtParser;
import net.yacy.document.parser.ooxmlParser;

@ -1,13 +1,12 @@
package de.anomic.document.parser;
package net.yacy.document.parser;
import java.nio.charset.Charset;
import net.yacy.document.parser.htmlParser;
import junit.framework.TestCase;
import org.junit.Test;
public class htmlParserTest extends TestCase {
@Test
public void testGetRealCharsetEncoding() {
String[][] testStrings = new String[][] {
new String[]{null,null},

@ -1,8 +1,8 @@
package de.anomic.yacy;
package net.yacy.peers.operation;
import net.yacy.peers.operation.yacyVersion;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
public class yacyVersionTest extends TestCase {
@ -10,6 +10,7 @@ public class yacyVersionTest extends TestCase {
* Test method for 'yacy.combinedVersionString2PrettyString(String)'
* @author Bost
*/
@Test
public void testCombinedVersionString2PrettyString() {
Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("")); // not a number
Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion(" ")); // not a number
Loading…
Cancel
Save