Skip to content

Commit

Permalink
Merge pull request #14 from bitletorg/tests
Browse files Browse the repository at this point in the history
Test saving updated metafile fields.
  • Loading branch information
DCastagna committed Jun 24, 2015
2 parents 01d9264 + 123684d commit e101b51
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/test/java/org/bitlet/wetorrent/MetafileTest.java
Expand Up @@ -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;
Expand All @@ -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"));
Expand All @@ -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.