Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test saving updated metafile fields. #14

Merged
merged 1 commit into from Jun 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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());
}
}