equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 |
26 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 |
27 * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379 |
27 * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379 8218547 |
28 * @summary Argument parsing validation. |
28 * @summary Argument parsing validation. |
29 * @modules jdk.compiler |
29 * @modules jdk.compiler |
30 * jdk.zipfs |
30 * jdk.zipfs |
31 * @compile -XDignore.symbol.file Arrrghs.java |
31 * @compile -XDignore.symbol.file Arrrghs.java |
32 * @run main/othervm Arrrghs |
32 * @run main/othervm Arrrghs |
34 |
34 |
35 |
35 |
36 import java.io.File; |
36 import java.io.File; |
37 import java.io.FileNotFoundException; |
37 import java.io.FileNotFoundException; |
38 import java.io.IOException; |
38 import java.io.IOException; |
|
39 import java.nio.file.Files; |
|
40 import java.nio.file.Paths; |
|
41 import java.nio.file.Path; |
39 import java.util.ArrayList; |
42 import java.util.ArrayList; |
40 import java.util.Arrays; |
43 import java.util.Arrays; |
41 import java.util.HashMap; |
44 import java.util.HashMap; |
42 import java.util.List; |
45 import java.util.List; |
43 import java.util.Map; |
46 import java.util.Map; |
52 * History: these set of tests were part of Arrrghs.sh. The MKS shell |
55 * History: these set of tests were part of Arrrghs.sh. The MKS shell |
53 * implementations were notoriously buggy. Implementing these tests purely |
56 * implementations were notoriously buggy. Implementing these tests purely |
54 * in Java is not only portable but also robust. |
57 * in Java is not only portable but also robust. |
55 * |
58 * |
56 */ |
59 */ |
57 |
|
58 /* |
|
59 * SIGH, On Windows all strings are quoted, we need to unwrap it |
|
60 */ |
|
61 private static String removeExtraQuotes(String in) { |
|
62 if (isWindows) { |
|
63 // Trim the string and remove the enclosed quotes if any. |
|
64 in = in.trim(); |
|
65 if (in.startsWith("\"") && in.endsWith("\"")) { |
|
66 return in.substring(1, in.length()-1); |
|
67 } |
|
68 } |
|
69 return in; |
|
70 } |
|
71 |
60 |
72 // the pattern we hope to see in the output |
61 // the pattern we hope to see in the output |
73 static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*"); |
62 static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*"); |
74 |
63 |
75 void checkArgumentParsing(String inArgs, String... expArgs) throws IOException { |
64 void checkArgumentParsing(String inArgs, String... expArgs) throws IOException { |
488 if (!tr.testStatus) |
477 if (!tr.testStatus) |
489 System.out.println(tr); |
478 System.out.println(tr); |
490 } |
479 } |
491 |
480 |
492 /* |
481 /* |
|
482 * Tests -jar command on a jar file with "long" (> 260 chars) full path on Windows |
|
483 */ |
|
484 @Test |
|
485 void testLongPathJarFile() throws IOException { |
|
486 if (!isWindows) { |
|
487 return; |
|
488 } |
|
489 // put the jar file to a location with long path |
|
490 String longPathPart = "longpathtest_longpathtest/"; |
|
491 String longPathStr = longPathPart.repeat(15); |
|
492 Path longPath = Paths.get(longPathStr); |
|
493 Path jarPath = Files.createDirectories(longPath).resolve("elp.jar"); |
|
494 File elp = jarPath.toFile(); |
|
495 createJar(elp, new File("Foo"), "public static void main(String[] args){ System.out.println(\"Hello from ELP\"); }"); |
|
496 System.out.println("execute " + elp.getAbsolutePath()); |
|
497 TestResult tr = doExec(javaCmd, "-jar", elp.getAbsolutePath()); |
|
498 tr.checkPositive(); |
|
499 tr.contains("Hello from ELP"); |
|
500 } |
|
501 |
|
502 /* |
493 * Tests various dispositions of the main method, these tests are limited |
503 * Tests various dispositions of the main method, these tests are limited |
494 * to English locales as they check for error messages that are localized. |
504 * to English locales as they check for error messages that are localized. |
495 */ |
505 */ |
496 @Test |
506 @Test |
497 void testMainMethod() throws FileNotFoundException { |
507 void testMainMethod() throws FileNotFoundException { |