Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extensions.configure<ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtensio

// Extra details provided for unit tests
tasks.withType<Test> {
useJUnit()
useJUnitPlatform()

// ignoreFailures: Specifies whether the build should break when the verifications performed by this task fail.
ignoreFailures = true
Expand Down
10 changes: 9 additions & 1 deletion gestalt-android-testbed/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
testOptions {
unitTests.all {
it.useJUnitPlatform()
}
}
packagingOptions {
merge "META-INF/annotations/*"
}
Expand All @@ -45,7 +50,10 @@ dependencies {
implementation(libs.slf4j.api)
implementation("com.github.tony19:logback-android:1.3.0-3")
implementation(project(":testpack:testpack-api"))
testImplementation(libs.junit)
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testRuntimeOnly(libs.junit.platform.launcher)
// androidTest runs on-device via AndroidJUnitRunner, which is JUnit4-only - not migrated.
androidTestImplementation("androidx.test:runner:1.6.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package org.terasology.gestalt.android.testbed;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Example local unit test, which will execute on the development machine (host).
Expand Down
1 change: 0 additions & 1 deletion gestalt-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dependencies {
implementation(libs.guava)

implementation("androidx.appcompat:appcompat:1.7.0")
testImplementation(libs.junit)
androidTestImplementation("androidx.test:runner:1.6.2")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")

Expand Down
4 changes: 3 additions & 1 deletion gestalt-asset-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ dependencies {
api(libs.jcip)

testAnnotationProcessor(project(":gestalt-inject-java"))
testImplementation(libs.junit)
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testRuntimeOnly(libs.junit.platform.launcher)
testImplementation(libs.logback)
testImplementation(libs.mockito)
}
Expand Down
11 changes: 9 additions & 2 deletions gestalt-asset-core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@ com.googlecode.gentyref:gentyref:1.2.0=annotationProcessor,runtimeClasspath,test
com.squareup:javapoet:1.13.0=annotationProcessor,testAnnotationProcessor
com.toasttab.android:gummy-bears-api-24:0.15.0=signature
javax.inject:javax.inject:1=annotationProcessor,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
junit:junit:4.12=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.17.7=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.17.7=testCompileClasspath,testRuntimeClasspath
net.jcip:jcip-annotations:1.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-compat-qual:2.5.2=annotationProcessor,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.17=annotationProcessor,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.24=animalsniffer
org.codehaus.mojo:animal-sniffer:1.24=animalsniffer
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
org.javassist:javassist:3.27.0-GA=runtimeClasspath,testRuntimeClasspath
org.jspecify:jspecify:1.0.0=testCompileClasspath
org.junit.jupiter:junit-jupiter-api:6.1.3=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:6.1.3=testRuntimeClasspath
org.junit.platform:junit-platform-commons:6.1.3=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:6.1.3=testRuntimeClasspath
org.junit.platform:junit-platform-launcher:6.1.3=testRuntimeClasspath
org.junit:junit-bom:6.1.3=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.23.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm:9.7=animalsniffer
org.slf4j:slf4j-api:1.7.25=annotationProcessor,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
empty=
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.gestalt.assets.management.AssetTypeManager;

Expand All @@ -33,8 +33,8 @@
import virtualModules.test.stubs.text.TextData;
import virtualModules.test.stubs.text.TextFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.collect.ImmutableSet;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.gestalt.assets.management.Context;
import org.terasology.gestalt.assets.management.ContextManager;
Expand All @@ -37,9 +37,9 @@
import virtualModules.test.stubs.text.TextData;
import virtualModules.test.stubs.text.TextFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.collect.ImmutableSet;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.naming.Name;

import java.io.IOException;
Expand All @@ -29,11 +29,11 @@
import virtualModules.test.stubs.text.TextData;
import virtualModules.test.stubs.text.TextFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

package org.terasology.gestalt.assets;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.assets.exceptions.InvalidUrnException;
import org.terasology.gestalt.naming.Name;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Immortius
Expand All @@ -42,7 +43,7 @@ public class ResourceUrnTest {
@Test
public void moduleAndResourceConstructor() {
ResourceUrn urn = new ResourceUrn(TEST_MODULE, TEST_RESOURCE);
Assert.assertEquals(new Name(TEST_MODULE), urn.getModuleName());
Assertions.assertEquals(new Name(TEST_MODULE), urn.getModuleName());
assertEquals(new Name(TEST_RESOURCE), urn.getResourceName());
assertTrue(urn.getFragmentName().isEmpty());
assertEquals(URN_STRING, urn.toString());
Expand Down Expand Up @@ -105,9 +106,9 @@ public void fragmentInstanceConstructor() {
assertEquals(URN_FRAGMENT_INSTANCE_STRING, urn.toString());
}

@Test(expected = InvalidUrnException.class)
@Test
public void invalidUrnStringConstructor() {
new ResourceUrn("blerg");
assertThrows(InvalidUrnException.class, () -> new ResourceUrn("blerg"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.terasology.gestalt.assets.module;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.gestalt.assets.format.producer.AssetFileDataProducer;
import org.terasology.gestalt.module.ModuleEnvironment;
Expand All @@ -30,9 +30,9 @@
import virtualModules.test.stubs.text.TextFileFormat;
import virtualModules.test.stubs.text.TextMetadataFileFormat;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Immortius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.terasology.gestalt.assets.module;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.assets.AssetData;
import org.terasology.gestalt.assets.AssetDataProducer;
import org.terasology.gestalt.assets.AssetFactory;
Expand All @@ -41,9 +41,9 @@
import virtualModules.test.stubs.text.TextData;
import virtualModules.test.stubs.text.TextFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

import com.google.common.collect.ImmutableSet;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.terasology.gestalt.module.ModuleEnvironment;
import org.terasology.gestalt.naming.Name;

import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Immortius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.terasology.gestalt.assets.module.autoreload;

import com.google.common.collect.SetMultimap;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.gestalt.assets.AssetType;
Expand All @@ -41,10 +41,12 @@
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.Optional;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class ModuleEnvironmentWatcherTest {

Expand Down Expand Up @@ -95,21 +97,45 @@ public Optional<ResourceUrn> deltaFileDeleted(FileReference file, Name module, N
}
};
AssetType<Text, TextData> assetType = new AssetType<>(Text.class, new TextFactory());
ResourceUrn urn = new ResourceUrn(module.getId(), new Name("test.txt"));
watcher.register("text", subscriber, assetType);
watcher.checkForChanges();
Files.createDirectories(tempDirectory.resolve("assets").resolve("text"));
watcher.checkForChanges();
Files.createFile(tempDirectory.resolve("assets").resolve("text").resolve("test.txt"));
SetMultimap<AssetType<?, ?>, ResourceUrn> changed = watcher.checkForChanges();
assertTrue(changed.containsEntry(assetType, new ResourceUrn(module.getId(), new Name("test.txt"))));
awaitChange(watcher, assetType, urn);
try (Writer writer = Files.newBufferedWriter(tempDirectory.resolve("assets").resolve("text").resolve("test.txt"))) {
writer.write("This is my text");
}
changed = watcher.checkForChanges();
assertTrue(changed.containsEntry(assetType, new ResourceUrn(module.getId(), new Name("test.txt"))));
awaitChange(watcher, assetType, urn);
FilesUtil.recursiveDelete(tempDirectory);
watcher.checkForChanges();

}

/**
* checkForChanges() does a single non-blocking WatchService poll - the OS delivers file
* events asynchronously (inotify/FSEvents/etc.), so a change made just before calling it can
* still be in flight and not show up in that one poll, especially under CI's slower/virtualized
* filesystems. Retries for up to 5s instead of asserting on a single poll's result, so the test
* doesn't flake on delivery timing while still failing for real if the change never arrives.
*/
private static void awaitChange(ModuleEnvironmentWatcher watcher, AssetType<?, ?> assetType, ResourceUrn urn) throws IOException {
Instant deadline = Instant.now().plus(Duration.ofSeconds(5));
SetMultimap<AssetType<?, ?>, ResourceUrn> changed;
do {
changed = watcher.checkForChanges();
if (changed.containsEntry(assetType, urn)) {
return;
}
try {
Thread.sleep(20);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted while waiting for a file change to be detected", e);
}
} while (Instant.now().isBefore(deadline));
fail("Expected " + urn + " to show up as changed within 5s, last poll's result: " + changed);
}

}
4 changes: 3 additions & 1 deletion gestalt-di/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ dependencies {
implementation(libs.guava)
api(project(":gestalt-inject"))

testImplementation(libs.junit)
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testRuntimeOnly(libs.junit.platform.launcher)
testImplementation(libs.logback)
testImplementation(libs.mockito)

Expand Down
11 changes: 9 additions & 2 deletions gestalt-di/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@ com.googlecode.gentyref:gentyref:1.2.0=testAnnotationProcessor,testRuntimeClassp
com.squareup:javapoet:1.13.0=testAnnotationProcessor
com.toasttab.android:gummy-bears-api-24:0.15.0=signature
javax.inject:javax.inject:1=compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
junit:junit:4.12=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.17.7=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.17.7=testCompileClasspath,testRuntimeClasspath
net.jcip:jcip-annotations:1.0=testRuntimeClasspath
net.sf.trove4j:trove4j:3.0.3=testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-compat-qual:2.5.2=compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.17=compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.24=animalsniffer
org.codehaus.mojo:animal-sniffer:1.24=animalsniffer
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
org.javassist:javassist:3.27.0-GA=testRuntimeClasspath
org.jspecify:jspecify:1.0.0=testCompileClasspath
org.junit.jupiter:junit-jupiter-api:6.1.3=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:6.1.3=testRuntimeClasspath
org.junit.platform:junit-platform-commons:6.1.3=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:6.1.3=testRuntimeClasspath
org.junit.platform:junit-platform-launcher:6.1.3=testRuntimeClasspath
org.junit:junit-bom:6.1.3=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.23.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.ow2.asm:asm:9.7=animalsniffer
org.slf4j:slf4j-api:1.7.25=compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor
Loading