|
21 | 21 | * questions.
|
22 | 22 | */
|
23 | 23 |
|
| 24 | +import static jdk.jpackage.test.JPackageStringBundle.MAIN; |
| 25 | + |
24 | 26 | import java.nio.file.Path;
|
25 | 27 | import java.util.Map;
|
26 |
| - |
27 | 28 | import jdk.jpackage.test.Annotations.Parameter;
|
28 | 29 | import jdk.jpackage.test.Annotations.Test;
|
29 | 30 | import jdk.jpackage.test.FileAssociations;
|
| 31 | +import jdk.jpackage.test.JPackageCommand; |
30 | 32 | import jdk.jpackage.test.PackageTest;
|
31 | 33 | import jdk.jpackage.test.PackageType;
|
32 | 34 | import jdk.jpackage.test.TKit;
|
@@ -111,46 +113,42 @@ public static void test(boolean includeDescription) {
|
111 | 113 | public static void testNoMime() {
|
112 | 114 | final Path propFile = TKit.workDir().resolve("fa.properties");
|
113 | 115 |
|
114 |
| - PackageTest packageTest = new PackageTest().excludeTypes(PackageType.MAC); |
115 |
| - |
116 |
| - packageTest.configureHelloApp().addRunOnceInitializer(() -> { |
| 116 | + initPackageTest().addRunOnceInitializer(() -> { |
117 | 117 | TKit.createPropertiesFile(propFile, Map.of(
|
118 | 118 | "extension", "foo",
|
119 | 119 | "description", "bar"
|
120 | 120 | ));
|
121 | 121 | }).addInitializer(cmd -> {
|
122 |
| - cmd.addArguments("--file-associations", propFile).saveConsoleOutput(true); |
123 |
| - }).setExpectedExitCode(1).addBundleVerifier((cmd, result) -> { |
124 |
| - TKit.assertTextStream( |
125 |
| - "No MIME types were specified for File Association number 1") |
126 |
| - .apply(result.getOutput().stream()); |
127 |
| - TKit.assertTextStream( |
128 |
| - "Advice to fix: Specify MIME type for File Association number 1") |
129 |
| - .apply(result.getOutput().stream()); |
| 122 | + cmd.addArguments("--file-associations", propFile); |
| 123 | + cmd.validateOutput( |
| 124 | + MAIN.cannedFormattedString("error.no-content-types-for-file-association", 1), |
| 125 | + MAIN.cannedFormattedString("error.no-content-types-for-file-association.advice", 1)); |
130 | 126 | }).run();
|
131 | 127 | }
|
132 | 128 |
|
133 | 129 | @Test
|
134 | 130 | public static void testTooManyMimes() {
|
135 | 131 | final Path propFile = TKit.workDir().resolve("fa.properties");
|
136 | 132 |
|
137 |
| - PackageTest packageTest = new PackageTest().excludeTypes(PackageType.MAC); |
138 |
| - |
139 |
| - packageTest.configureHelloApp().addRunOnceInitializer(() -> { |
| 133 | + initPackageTest().addRunOnceInitializer(() -> { |
140 | 134 | TKit.createPropertiesFile(propFile, Map.of(
|
141 | 135 | "mime-type", "application/x-jpackage-foo, application/x-jpackage-bar",
|
142 | 136 | "extension", "foo",
|
143 | 137 | "description", "bar"
|
144 | 138 | ));
|
145 | 139 | }).addInitializer(cmd -> {
|
146 |
| - cmd.addArguments("--file-associations", propFile).saveConsoleOutput(true); |
147 |
| - }).setExpectedExitCode(1).addBundleVerifier((cmd, result) -> { |
148 |
| - TKit.assertTextStream( |
149 |
| - "More than one MIME types was specified for File Association number 1") |
150 |
| - .apply(result.getOutput().stream()); |
151 |
| - TKit.assertTextStream( |
152 |
| - "Advice to fix: Specify only one MIME type for File Association number 1") |
153 |
| - .apply(result.getOutput().stream()); |
| 140 | + cmd.addArguments("--file-associations", propFile); |
| 141 | + cmd.validateOutput( |
| 142 | + MAIN.cannedFormattedString("error.too-many-content-types-for-file-association", 1), |
| 143 | + MAIN.cannedFormattedString("error.too-many-content-types-for-file-association.advice", 1)); |
154 | 144 | }).run();
|
155 | 145 | }
|
| 146 | + |
| 147 | + private static PackageTest initPackageTest() { |
| 148 | + return new PackageTest() |
| 149 | + .excludeTypes(PackageType.MAC) |
| 150 | + .configureHelloApp() |
| 151 | + .addInitializer(JPackageCommand::setFakeRuntime) |
| 152 | + .setExpectedExitCode(1); |
| 153 | + } |
156 | 154 | }
|
0 commit comments