Skip to content
Permalink
Browse files
Fix SevenZArchiveEntryTest.
  • Loading branch information
garydgregory committed May 5, 2022
1 parent d26e578 commit 2b643c3ea8ca54e802793544164d71981a9b128b
Showing 1 changed file with 23 additions and 17 deletions.
@@ -17,35 +17,41 @@
*/
package org.apache.commons.compress.archivers.sevenz;

import org.junit.Assert;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.Arrays;

import org.junit.jupiter.api.Test;

/**
* Tests {@link SevenZArchiveEntry}.
*/
public class SevenZArchiveEntryTest {

@Test
public void shouldThrowIfNoLastModifiedDateIsSet() {
new SevenZArchiveEntry().getLastModifiedDate();
assertThrows(UnsupportedOperationException.class, () -> new SevenZArchiveEntry().getLastModifiedDate());
}

@Test
public void shouldThrowIfNoCreationDateIsSet() {
new SevenZArchiveEntry().getCreationDate();
assertThrows(UnsupportedOperationException.class, () -> new SevenZArchiveEntry().getCreationDate());
}

@Test
public void shouldThrowIfNoAccessDateIsSet() {
new SevenZArchiveEntry().getAccessDate();
assertThrows(UnsupportedOperationException.class, () -> new SevenZArchiveEntry().getAccessDate());
}

@Test
public void noMethodsIsDifferentFromSomeMethods() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.COPY)));
Assert.assertNotEquals(z1, z2);
Assert.assertNotEquals(z2, z1);
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}

@Test
@@ -55,8 +61,8 @@ public void oneMethodsIsDifferentFromTwoMethods() {
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.COPY)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER),
new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
Assert.assertNotEquals(z1, z2);
Assert.assertNotEquals(z2, z1);
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}

@Test
@@ -67,8 +73,8 @@ public void sameMethodsYieldEqualEntries() {
new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER),
new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
Assert.assertEquals(z1, z2);
Assert.assertEquals(z2, z1);
assertEquals(z1, z2);
assertEquals(z2, z1);
}

@Test
@@ -79,8 +85,8 @@ public void methodOrderMattersInEquals() {
new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER),
new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
Assert.assertNotEquals(z1, z2);
Assert.assertNotEquals(z2, z1);
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}

@Test
@@ -91,10 +97,10 @@ public void methodConfigurationMattersInEquals() {
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 1)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2)));
z3.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2)));
Assert.assertNotEquals(z1, z2);
Assert.assertNotEquals(z2, z1);
Assert.assertEquals(z3, z2);
Assert.assertEquals(z2, z3);
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
assertEquals(z3, z2);
assertEquals(z2, z3);
}

}

0 comments on commit 2b643c3

Please sign in to comment.