Skip to content

Commit

Permalink
Test code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jul 19, 2024
1 parent a33e373 commit 8c42052
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions src/test/java/rife/bld/wrapper/TestWrapperExtensionResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void testNoExtensions()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -38,7 +38,7 @@ void testNoExtensions()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), Collections.emptySet(), Collections.emptySet(), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(3, files2.size());
Collections.sort(files2);
Expand All @@ -60,8 +60,8 @@ void testUpdateExtensions()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -74,7 +74,7 @@ void testUpdateExtensions()
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(10, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -103,8 +103,8 @@ void testUpdateExtensionsOverride1()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -119,7 +119,7 @@ properties, new Properties(),
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(10, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -148,8 +148,8 @@ void testUpdateExtensionsOverride2()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -164,7 +164,7 @@ properties, new Properties(),
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(11, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -194,8 +194,8 @@ void testUpdateExtensionsSources()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -206,7 +206,7 @@ void testUpdateExtensionsSources()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(17, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -242,8 +242,8 @@ void testUpdateExtensionsJavadoc()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -254,7 +254,7 @@ void testUpdateExtensionsJavadoc()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, true);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(17, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -290,8 +290,8 @@ void testUpdateExtensionsBoth()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -302,7 +302,7 @@ void testUpdateExtensionsBoth()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, true);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(24, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -345,8 +345,8 @@ void testUpdateExtensionsBothOverride()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -361,7 +361,7 @@ properties, new Properties(),
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, true);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(24, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -404,8 +404,8 @@ void testResolvedRepository()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -419,7 +419,7 @@ void testResolvedRepository()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of("testrepo"), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(10, files2.size());
Collections.sort(files2);
Expand All @@ -441,15 +441,15 @@ void testResolvedRepository()
}

@Test
void testCheckHash()
void testCheckCache()
throws Exception {
var tmp1 = Files.createTempDirectory("test1").toFile();
var tmp2 = Files.createTempDirectory("test2").toFile();
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -460,7 +460,7 @@ void testCheckHash()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files = tmp2.listFiles();
assertEquals(10, files.length);
Arrays.stream(files).forEach(file -> {
Expand Down Expand Up @@ -492,15 +492,15 @@ void testCheckHash()
}

@Test
void testDeleteHash()
void testDeleteCache()
throws Exception {
var tmp1 = Files.createTempDirectory("test1").toFile();
var tmp2 = Files.createTempDirectory("test2").toFile();
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -511,7 +511,7 @@ void testDeleteHash()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files = tmp2.listFiles();
assertEquals(10, files.length);
Arrays.stream(files).forEach(file -> {
Expand All @@ -536,7 +536,7 @@ void testDeleteHash()
bld-wrapper.jar
bld-wrapper.properties
bld.cache""", String.join("\n", files3));
hash_file.delete();
assertTrue(cache_file.delete());

resolver.updateExtensions();
var files4 = FileUtils.getFileList(tmp2);
Expand All @@ -560,15 +560,15 @@ void testDeleteHash()
}

@Test
void testUpdateHash()
void testUpdateCache()
throws Exception {
var tmp1 = Files.createTempDirectory("test1").toFile();
var tmp2 = Files.createTempDirectory("test2").toFile();
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -579,7 +579,7 @@ void testUpdateHash()
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files = tmp2.listFiles();
assertEquals(10, files.length);
Arrays.stream(files).forEach(file -> {
Expand All @@ -604,7 +604,7 @@ void testUpdateHash()
bld-wrapper.jar
bld-wrapper.properties
bld.cache""", String.join("\n", files3));
FileUtils.writeString("updated", hash_file);
FileUtils.writeString("updated", cache_file);

resolver.updateExtensions();
var files4 = FileUtils.getFileList(tmp2);
Expand Down Expand Up @@ -635,8 +635,8 @@ void testAddExtension()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -647,7 +647,7 @@ void testAddExtension()
var resolver1 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver1.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(10, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -694,8 +694,8 @@ void testRemoveExtension()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -706,7 +706,7 @@ void testRemoveExtension()
var resolver1 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1", "org.jsoup:jsoup:1.15.4"), false, false);
resolver1.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(11, files2.size());
Collections.sort(files2);
Expand Down Expand Up @@ -747,8 +747,8 @@ void testOverrideExtension()
try {
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());

var hash_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(hash_file.exists());
var cache_file = new File(tmp2, BldCache.BLD_CACHE);
assertFalse(cache_file.exists());
var files1 = FileUtils.getFileList(tmp2);
assertEquals(2, files1.size());
Collections.sort(files1);
Expand All @@ -761,7 +761,7 @@ void testOverrideExtension()
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
resolver1.updateExtensions();

assertTrue(hash_file.exists());
assertTrue(cache_file.exists());
var files2 = FileUtils.getFileList(tmp2);
assertEquals(10, files2.size());
Collections.sort(files2);
Expand Down

0 comments on commit 8c42052

Please sign in to comment.