Permalink
Browse files

Merge pull request #14 from bitletorg/tests

Test saving updated metafile fields.
  • Loading branch information...
DCastagna committed Jun 24, 2015
2 parents 01d9264 + 123684d commit e101b51f86614b43dc86b1b8076615334f741c16
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/test/java/org/bitlet/wetorrent/MetafileTest.java
@@ -20,6 +20,8 @@
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.Collections;
import java.util.LinkedList;
@@ -38,7 +40,6 @@ public void readMetafile() throws Exception {
InputStream stream = MetafileTest.class.getResourceAsStream(TEST_TORRENT_PATH);
Metafile metafile = new Metafile(stream);
assertEquals("http://torrent.ubuntu.com:6969/announce", metafile.getAnnounce());
List announceList = new LinkedList();
List firstList = new LinkedList();
firstList.add(toByteBuffer("http://torrent.ubuntu.com:6969/announce"));
@@ -57,4 +58,16 @@ public void readMetafile() throws Exception {
assertEquals(524288L, metafile.getPieceLength().longValue());
assertEquals(2196, metafile.getPieces().size());
}
@Test
public void updateManifestComment() throws Exception {
InputStream stream = MetafileTest.class.getResourceAsStream(TEST_TORRENT_PATH);
Metafile metafile = new Metafile(stream);
metafile.setComment("foo");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
metafile.print(outputStream);
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
Metafile metafileWithUpdatedFields = new Metafile(inputStream);
assertEquals("foo", metafile.getComment());
}
}

0 comments on commit e101b51

Please sign in to comment.