Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Unreleased
----------

#### Dependency upgrades

- **junit**: 4.13.2 → 5.12.2

1.3.0
-----

Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
119 changes: 0 additions & 119 deletions src/main/java/org/archive/util/TmpDirTestCase.java

This file was deleted.

31 changes: 16 additions & 15 deletions src/test/java/org/archive/extract/RealCDXExtractorOutputTest.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package org.archive.extract;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RealCDXExtractorOutputTest extends TestCase {

public class RealCDXExtractorOutputTest {

@Test
public void testEscapeResolvedUrl() throws Exception {
String context ="http://www.uni-giessen.de/cms/studium/dateien/informationberatung/merkblattpdf";
String spec = "http://fss.plone.uni-giessen.de/fß/studium/dateien/informationberatung/merkblattpdf/file/Mérkblatt zur Gestaltung von Nachteilsausgleichen.pdf?föo=bar#änchor";
String escaped = RealCDXExtractorOutput.resolve(context, spec);
assertTrue(escaped.indexOf(" ") < 0);
URI parsed = new URI(escaped);
assertEquals("änchor", parsed.getFragment());
String context = "http://www.uni-giessen.de/cms/studium/dateien/informationberatung/merkblattpdf";
String spec = "http://fss.plone.uni-giessen.de/fß/studium/dateien/informationberatung/merkblattpdf/file/Mérkblatt zur Gestaltung von Nachteilsausgleichen.pdf?föo=bar#änchor";
String escaped = RealCDXExtractorOutput.resolve(context, spec);
assertTrue(escaped.indexOf(" ") < 0);
URI parsed = new URI(escaped);
assertEquals("änchor", parsed.getFragment());
}

@Test
public void testNoDoubleEscaping() throws Exception {
String spec = "https://www.google.com/search?q=java+escape+url+spaces&ie=utf-8&oe=utf-8";
String resolved = RealCDXExtractorOutput.resolve(spec, spec);
assertTrue(spec.equals(resolved));
String spec = "https://www.google.com/search?q=java+escape+url+spaces&ie=utf-8&oe=utf-8";
String resolved = RealCDXExtractorOutput.resolve(spec, spec);
assertTrue(spec.equals(resolved));
}
}
10 changes: 4 additions & 6 deletions src/test/java/org/archive/format/dns/DNSResponseParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;

import org.archive.format.dns.DNSParseException;
import org.archive.format.dns.DNSRecord;
import org.archive.format.dns.DNSResponse;
import org.archive.format.dns.DNSResponseParser;
import org.junit.jupiter.api.Test;

import junit.framework.TestCase;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class DNSResponseParserTest extends TestCase {
public class DNSResponseParserTest {
DNSResponseParser parser = new DNSResponseParser();
@Test
public void testParse() throws DNSParseException, IOException {
verifyResults("20110328212258\nfarm6.static.flickr.a06.yahoodns.net.\t300\tIN\tA\t98.136.170.121\n",
"20110328212258",new String[][] {{"farm6.static.flickr.a06.yahoodns.net.","300","IN","A","98.136.170.121"}});
Expand Down
38 changes: 23 additions & 15 deletions src/test/java/org/archive/format/gzip/GZIPMemberSeriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
import org.archive.util.ByteOp;
import org.archive.util.IAUtils;
import org.archive.util.TestUtils;
import org.archive.format.gzip.GZIPFormatException;
import org.archive.format.gzip.GZIPMemberSeries;
import org.archive.format.gzip.GZIPSeriesMember;
import org.archive.streamcontext.ByteArrayWrappedStream;
import org.archive.streamcontext.SimpleStream;
import org.archive.streamcontext.Stream;

import com.google.common.io.ByteStreams;
import com.google.common.primitives.Bytes;

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

public class GZIPMemberSeriesTest extends TestCase {
import static org.junit.jupiter.api.Assertions.*;

public class GZIPMemberSeriesTest {

@Test
public void testSingle() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
Expand All @@ -38,6 +38,7 @@ public void testSingle() throws IndexOutOfBoundsException, FileNotFoundException
assertNull(s.getNextMember());
}

@Test
public void testSingleEmpty() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("empty.gz");
Expand All @@ -59,6 +60,7 @@ public void testSingleEmpty() throws IndexOutOfBoundsException, FileNotFoundExce
assertTrue(s.gotEOF());
}

@Test
public void testDouble() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
Expand All @@ -81,14 +83,14 @@ public void testDouble() throws IndexOutOfBoundsException, FileNotFoundException
assertNull(s.getNextMember());
}


@Test
public void testSingleCRCStrict() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
byte abcd[] = ByteStreams.toByteArray(is);
byte oldb = abcd[abcd.length-1];
abcd[abcd.length-1] = (byte) (abcd[abcd.length-1] + 1);
assertFalse(oldb == abcd[abcd.length-1]);
assertNotEquals(oldb, abcd[abcd.length - 1]);

ByteArrayInputStream bais = new ByteArrayInputStream(abcd);
Stream stream = new SimpleStream(bais);
Expand Down Expand Up @@ -117,14 +119,15 @@ public void testSingleCRCStrict() throws IndexOutOfBoundsException, FileNotFound
}
assertNotNull(e);
}


@Test
public void testSingleCRCLAX() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
byte abcd[] = ByteStreams.toByteArray(is);
byte oldb = abcd[abcd.length-1];
abcd[abcd.length-1] = (byte) (abcd[abcd.length-1] + 1);
assertFalse(oldb == abcd[abcd.length-1]);
assertNotEquals(oldb, abcd[abcd.length - 1]);

ByteArrayInputStream bais = new ByteArrayInputStream(abcd);
Stream stream = new SimpleStream(bais);
Expand Down Expand Up @@ -154,15 +157,16 @@ public void testSingleCRCLAX() throws IndexOutOfBoundsException, FileNotFoundExc
assertNull(e);
assertNull(s.getNextMember());
}


@Test
public void testDoubleCRC1LAX() throws IndexOutOfBoundsException, FileNotFoundException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
byte abcd[] = ByteStreams.toByteArray(is);
byte abcdorig[] = ByteOp.copy(abcd);
byte oldb = abcd[abcd.length-1];
abcd[abcd.length-1] = (byte) (abcd[abcd.length-1] + 1);
assertFalse(oldb == abcd[abcd.length-1]);
assertNotEquals(oldb, abcd[abcd.length - 1]);

byte both[] = Bytes.concat(abcd,abcdorig);

Expand Down Expand Up @@ -195,7 +199,8 @@ public void testDoubleCRC1LAX() throws IndexOutOfBoundsException, FileNotFoundEx
assertNotNull(m);
TestUtils.assertStreamEquals(m,"abcd".getBytes(IAUtils.UTF8));
}


@Test
public void testSingleDeflateError() throws IndexOutOfBoundsException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
Expand Down Expand Up @@ -240,7 +245,7 @@ public void testSingleDeflateError() throws IndexOutOfBoundsException, IOExcepti
assertNull(m);
}


@Test
public void testDoubleDeflateError() throws IndexOutOfBoundsException, IOException {

InputStream is = getClass().getResourceAsStream("abcd.gz");
Expand Down Expand Up @@ -290,7 +295,8 @@ public void testDoubleDeflateError() throws IndexOutOfBoundsException, IOExcepti
assertFalse(s.gotIOError());

}


@Test
public void testDoubleBiggerDeflateErrOnFirst() throws IOException {
String resource = "double-single-inflate-error.gz";
InputStream is = getClass().getResourceAsStream(resource);
Expand Down Expand Up @@ -333,7 +339,8 @@ public void testDoubleBiggerDeflateErrOnFirst() throws IOException {


}


@Test
public void testAutoSkip() throws IOException {
InputStream is = getClass().getResourceAsStream("abcd.gz");
byte abcd[] = ByteStreams.toByteArray(is);
Expand Down Expand Up @@ -375,6 +382,7 @@ public void testAutoSkip() throws IOException {
assertTrue(s.gotEOF());
}

@Test
public void testWgetProblem() throws IndexOutOfBoundsException, FileNotFoundException, IOException {
InputStream is = getClass().getResourceAsStream("IAH-urls-wget.warc.gz");
new GZIPDecoder().parseHeader(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

import org.archive.util.IAUtils;

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

public class GZIPMemberWriterTest extends TestCase {
public class GZIPMemberWriterTest {

@Test
public void testWrite() throws IOException {
File outFile = File.createTempFile("tmp", ".gz");
GZIPMemberWriter gzw = new GZIPMemberWriter(new FileOutputStream(outFile));
Expand Down
Loading