|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +import jdk.test.lib.process.OutputAnalyzer; |
| 25 | +import jdk.test.lib.process.ProcessTools; |
| 26 | +import java.io.IOException; |
| 27 | +import org.junit.jupiter.params.ParameterizedTest; |
| 28 | +import org.junit.jupiter.params.provider.ValueSource; |
| 29 | + |
| 30 | +/* @test |
| 31 | + * @summary Unit tests for formatter |
| 32 | + * @library /test/lib |
| 33 | + * @compile Basic.java |
| 34 | + * @compile BasicBoolean.java |
| 35 | + * @compile BasicBooleanObject.java |
| 36 | + * @compile BasicByte.java |
| 37 | + * @compile BasicByteObject.java |
| 38 | + * @compile BasicChar.java |
| 39 | + * @compile BasicCharObject.java |
| 40 | + * @compile BasicShort.java |
| 41 | + * @compile BasicShortObject.java |
| 42 | + * @compile BasicInt.java |
| 43 | + * @compile BasicIntObject.java |
| 44 | + * @compile BasicLong.java |
| 45 | + * @compile BasicLongObject.java |
| 46 | + * @compile BasicBigInteger.java |
| 47 | + * @compile BasicFloat.java |
| 48 | + * @compile BasicFloatObject.java |
| 49 | + * @compile BasicDouble.java |
| 50 | + * @compile BasicDoubleObject.java |
| 51 | + * @compile BasicBigDecimal.java |
| 52 | + * @compile BasicDateTime.java |
| 53 | + * @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937 |
| 54 | + * 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122 |
| 55 | + * 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 6476168 |
| 56 | + * 8059175 8204229 |
| 57 | + * |
| 58 | + * @run junit BasicTestLauncher |
| 59 | + */ |
| 60 | +public class BasicTestLauncher { |
| 61 | + // Locale flag for testJVM |
| 62 | + private static final String JAVA_OPTS = "-Djava.locale.providers=CLDR"; |
| 63 | + // Test class |
| 64 | + private static final String TEST_CLASS = "Basic"; |
| 65 | + |
| 66 | + /** |
| 67 | + * Executes Formatter Basic tests |
| 68 | + * @param timeZone the time zone to run tests against |
| 69 | + */ |
| 70 | + @ParameterizedTest |
| 71 | + @ValueSource(strings = { "US/Pacific", "Asia/Novosibirsk" }) |
| 72 | + void testTimeZone(String timeZone) throws IOException{ |
| 73 | + System.out.printf("$$$ Testing against %s!%n", timeZone); |
| 74 | + OutputAnalyzer output = RunTest(timeZone); |
| 75 | + CheckTest(output); |
| 76 | + System.out.printf("$$$ %s passed as expected!%n", timeZone); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Creates and runs the testJVM process using Basic class |
| 81 | + * @param timeZone the time zone to be set in the testJVM environment |
| 82 | + */ |
| 83 | + private static OutputAnalyzer RunTest(String timeZone) throws IOException{ |
| 84 | + // Build and run Basic class with correct configuration |
| 85 | + ProcessBuilder pb = ProcessTools.createTestJvm(JAVA_OPTS, TEST_CLASS); |
| 86 | + pb.environment().put("TZ", timeZone); |
| 87 | + Process process = pb.start(); |
| 88 | + return new OutputAnalyzer(process); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Validates if the testJVM process passed all tests |
| 93 | + * @param output is an Output Analyzer for the testJVM |
| 94 | + * @throws RuntimeException for all testJVM failures |
| 95 | + */ |
| 96 | + private static void CheckTest(OutputAnalyzer output){ |
| 97 | + output.shouldHaveExitValue(0) |
| 98 | + .reportDiagnosticSummary(); |
| 99 | + } |
| 100 | +} |
0 commit comments