diff --git a/tests/src/test/java/org/teavm/classlib/java/text/NumberFormatTest.java b/tests/src/test/java/org/teavm/classlib/java/text/NumberFormatTest.java index 48997d661..fa4120e3b 100644 --- a/tests/src/test/java/org/teavm/classlib/java/text/NumberFormatTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/text/NumberFormatTest.java @@ -4,13 +4,15 @@ import static org.junit.Assert.*; import java.text.NumberFormat; import java.util.Currency; import java.util.Locale; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.teavm.junit.SkipJVM; +import org.teavm.junit.TeaVMProperties; +import org.teavm.junit.TeaVMProperty; import org.teavm.junit.TeaVMTestRunner; @RunWith(TeaVMTestRunner.class) +@TeaVMProperties(@TeaVMProperty(key = "java.util.Locale.available", value = "en, en_US, en_GB, ru, ru_RU")) public class NumberFormatTest { @Test public void formatsNumber() { diff --git a/tools/junit/src/main/java/org/teavm/junit/TeaVMProperties.java b/tools/junit/src/main/java/org/teavm/junit/TeaVMProperties.java index ee4270837..97e2a04ea 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TeaVMProperties.java +++ b/tools/junit/src/main/java/org/teavm/junit/TeaVMProperties.java @@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) +@Target(ElementType.TYPE) public @interface TeaVMProperties { TeaVMProperty[] value(); } diff --git a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java index a8b9006b2..9e1f23c87 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java +++ b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.CountDownLatch; @@ -352,6 +353,10 @@ public class TeaVMTestRunner extends Runner { new TestExceptionPlugin().install(vm); new TestEntryPointTransformer(runnerType.getName(), methodHolder.getReference()).install(vm); + Properties properties = new Properties(); + applyProperties(method.getDeclaringClass(), properties); + vm.setProperties(properties); + try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) { MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException", Throwable.class, String.class); @@ -367,6 +372,18 @@ public class TeaVMTestRunner extends Runner { return result; } + private void applyProperties(Class cls, Properties result) { + if (cls.getSuperclass() != null) { + applyProperties(cls.getSuperclass(), result); + } + TeaVMProperties properties = cls.getAnnotation(TeaVMProperties.class); + if (properties != null) { + for (TeaVMProperty property : properties.value()) { + result.setProperty(property.key(), property.value()); + } + } + } + private MethodDescriptor getDescriptor(Method method) { ValueType[] signature = Stream.concat(Arrays.stream(method.getParameterTypes()).map(ValueType::parse), Stream.of(ValueType.parse(method.getReturnType())))