-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make changes file reproducible (#712)
- Loading branch information
1 parent
7d59333
commit 12fea7b
Showing
8 changed files
with
172 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,34 @@ | |
package org.vafer.jdeb.changes; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.util.TimeZone; | ||
|
||
import static java.nio.charset.StandardCharsets.*; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.vafer.jdeb.debian.BinaryPackageControlFile; | ||
import org.vafer.jdeb.debian.ChangesFile; | ||
|
||
public class ChangesFileBuilderTestCase { | ||
|
||
private TimeZone defaultTimeZone; | ||
|
||
@Before | ||
public void before() { | ||
defaultTimeZone = TimeZone.getDefault(); | ||
} | ||
|
||
@After | ||
public void after() { | ||
TimeZone.setDefault(defaultTimeZone); | ||
} | ||
|
||
@Test | ||
public void testChangedByNotSet() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
"release distribution=production, date=14:00 13.01.2007, version=12324, urgency=low\n" + | ||
|
@@ -44,6 +60,7 @@ public void testChangedByNotSet() throws Exception { | |
|
||
assertNotNull(changeSets); | ||
assertEquals(1, changeSets.length); | ||
assertEquals(1168718400000L, changeSets[0].getDate().getTime()); | ||
|
||
ChangesFile changesFile = new ChangesFile(); | ||
changesFile.setChanges(provider.getChangesSets()); | ||
|
@@ -55,6 +72,7 @@ public void testChangedByNotSet() throws Exception { | |
|
||
@Test | ||
public void testChangedByFromControl() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
"release distribution=production, date=14:00 13.01.2007, version=12324, urgency=low\n" + | ||
|
@@ -72,6 +90,7 @@ public void testChangedByFromControl() throws Exception { | |
|
||
assertNotNull(changeSets); | ||
assertEquals(1, changeSets.length); | ||
assertEquals(1168718400000L, changeSets[0].getDate().getTime()); | ||
|
||
ChangesFile changesFile = new ChangesFile(); | ||
changesFile.setChanges(provider.getChangesSets()); | ||
|
@@ -83,6 +102,7 @@ public void testChangedByFromControl() throws Exception { | |
|
||
@Test | ||
public void testChangedByFromChangesProvider() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
"release distribution=production, date=14:00 13.01.2007, version=12324, urgency=low, [email protected]\n" + | ||
|
@@ -100,6 +120,7 @@ public void testChangedByFromChangesProvider() throws Exception { | |
|
||
assertNotNull(changeSets); | ||
assertEquals(1, changeSets.length); | ||
assertEquals(1168718400000L, changeSets[0].getDate().getTime()); | ||
|
||
ChangesFile changesFile = new ChangesFile(); | ||
changesFile.setChanges(provider.getChangesSets()); | ||
|
@@ -108,4 +129,33 @@ public void testChangedByFromChangesProvider() throws Exception { | |
assertNotNull(changesFile); | ||
assertEquals("[email protected]", changesFile.get("Changed-By")); | ||
} | ||
|
||
@Test | ||
public void testReproducible() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
"release distribution=production, date=14:00 13.01.2007, version=12324, urgency=low\n" + | ||
" * change1\n" + | ||
" * change2\n"; | ||
|
||
BinaryPackageControlFile packageControlFile = new BinaryPackageControlFile(); | ||
packageControlFile.set("Package", "package"); | ||
packageControlFile.set("Version", "version"); | ||
packageControlFile.set("Date", "Mon, 20 Aug 2007 15:25:57 +0200"); | ||
|
||
final TextfileChangesProvider provider = new TextfileChangesProvider(new ByteArrayInputStream(input.getBytes(UTF_8)), packageControlFile, 1175385600000L); | ||
final ChangeSet[] changeSets = provider.getChangesSets(); | ||
|
||
assertNotNull(changeSets); | ||
assertEquals(1, changeSets.length); | ||
assertEquals(1168696800000L, changeSets[0].getDate().getTime()); | ||
|
||
ChangesFile changesFile = new ChangesFile(); | ||
changesFile.setChanges(provider.getChangesSets()); | ||
changesFile.initialize(packageControlFile); | ||
|
||
assertNotNull(changesFile); | ||
assertEquals(null, changesFile.get("Changed-By")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,10 @@ | |
package org.vafer.jdeb.changes; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.util.TimeZone; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.Assert; | ||
|
||
|
@@ -26,8 +29,21 @@ | |
|
||
public final class TextfileChangesProviderTestCase extends Assert { | ||
|
||
private TimeZone defaultTimeZone; | ||
|
||
@Before | ||
public void before() { | ||
defaultTimeZone = TimeZone.getDefault(); | ||
} | ||
|
||
@After | ||
public void after() { | ||
TimeZone.setDefault(defaultTimeZone); | ||
} | ||
|
||
@Test | ||
public void testParsing() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
" * change1\n" + | ||
|
@@ -50,10 +66,13 @@ public void testParsing() throws Exception { | |
|
||
assertNotNull(changeSets); | ||
assertEquals(3, changeSets.length); | ||
assertEquals(1168718400000L, changeSets[1].getDate().getTime()); | ||
assertEquals(1168452000000L, changeSets[2].getDate().getTime()); | ||
} | ||
|
||
@Test | ||
public void testDistributionFromChangesProvider() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
"release distribution=production\n" + | ||
|
@@ -79,7 +98,39 @@ public void testDistributionFromChangesProvider() throws Exception { | |
|
||
assertEquals("production", changeSets[0].getDistribution()); | ||
assertEquals("staging", changeSets[1].getDistribution()); | ||
assertEquals(1168718400000L, changeSets[1].getDate().getTime()); | ||
assertEquals("development", changeSets[2].getDistribution()); | ||
assertEquals(1168452000000L, changeSets[2].getDate().getTime()); | ||
} | ||
|
||
@Test | ||
public void testReproducible() throws Exception { | ||
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); | ||
|
||
final String input = | ||
" * change1\n" + | ||
" * change2\n" + | ||
"release date=14:00 13.01.2007, version=12324, urgency=low, [email protected]\n" + | ||
" * change1\n" + | ||
" * change2\n" + | ||
"release date=12:00 10.01.2007, version=10324, urgency=low, [email protected]\n" + | ||
" * change1\n" + | ||
" * change2\n"; | ||
|
||
BinaryPackageControlFile packageControlFile = new BinaryPackageControlFile(); | ||
packageControlFile.set("Package", "package"); | ||
packageControlFile.set("Version", "version"); | ||
packageControlFile.set("Distribution", "distribution"); | ||
packageControlFile.set("Date", "Mon, 20 Aug 2007 15:25:57 +0200"); | ||
|
||
final TextfileChangesProvider provider = new TextfileChangesProvider(new ByteArrayInputStream(input.getBytes(UTF_8)), packageControlFile, 1175385600000L); | ||
final ChangeSet[] changeSets = provider.getChangesSets(); | ||
|
||
assertNotNull(changeSets); | ||
assertEquals(3, changeSets.length); | ||
assertEquals(1175385600000L, changeSets[0].getDate().getTime()); | ||
assertEquals(1168696800000L, changeSets[1].getDate().getTime()); | ||
assertEquals(1168430400000L, changeSets[2].getDate().getTime()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters