langtools/test/tools/javac/ClassPathTest/ClassPathTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2016, 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.
    25  * @test
    25  * @test
    26  * @bug 4241229 4785453
    26  * @bug 4241229 4785453
    27  * @summary Test -classpath option and classpath defaults.
    27  * @summary Test -classpath option and classpath defaults.
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    30  *          jdk.compiler/com.sun.tools.javac.file
       
    31  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.compiler/com.sun.tools.javac.main
    32  *          jdk.jdeps/com.sun.tools.javap
    31  * @build toolbox.ToolBox toolbox.JavacTask
    33  * @build ToolBox
       
    34  * @run main ClassPathTest
    32  * @run main ClassPathTest
    35  */
    33  */
    36 
    34 
    37 import java.nio.file.Paths;
    35 import java.nio.file.Paths;
       
    36 
       
    37 import toolbox.JavacTask;
       
    38 import toolbox.Task;
       
    39 import toolbox.ToolBox;
    38 
    40 
    39 // Original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
    41 // Original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
    40 public class ClassPathTest {
    42 public class ClassPathTest {
    41 
    43 
    42     private static final String ClassPathTest1Src =
    44     private static final String ClassPathTest1Src =
    98 //        Without the -cp . parameter the command will fail seems like when called
   100 //        Without the -cp . parameter the command will fail seems like when called
    99 //        from the command line, the current dir is added to the classpath
   101 //        from the command line, the current dir is added to the classpath
   100 //        automatically but this is not happening when called using ProcessBuilder
   102 //        automatically but this is not happening when called using ProcessBuilder
   101 
   103 
   102 //        testJavac success ClassPathTest3.java
   104 //        testJavac success ClassPathTest3.java
   103         tb.new JavacTask(ToolBox.Mode.EXEC)
   105         new JavacTask(tb, Task.Mode.EXEC)
   104                 .classpath(".")
   106                 .classpath(".")
   105                 .files("ClassPathTest3.java")
   107                 .files("ClassPathTest3.java")
   106                 .run();
   108                 .run();
   107 
   109 
   108 //        testJavac failure ClassPathTest1.java
   110 //        testJavac failure ClassPathTest1.java
   109         tb.new JavacTask(ToolBox.Mode.EXEC)
   111         new JavacTask(tb, Task.Mode.EXEC)
   110                 .classpath(".")
   112                 .classpath(".")
   111                 .files("ClassPathTest1.java")
   113                 .files("ClassPathTest1.java")
   112                 .run(ToolBox.Expect.FAIL);
   114                 .run(Task.Expect.FAIL);
   113 
   115 
   114 //        testJavac success ClassPathTest2.java
   116 //        testJavac success ClassPathTest2.java
   115         tb.new JavacTask(ToolBox.Mode.EXEC)
   117         new JavacTask(tb, Task.Mode.EXEC)
   116                 .envVar("CLASSPATH", "bar")
   118                 .envVar("CLASSPATH", "bar")
   117                 .files("ClassPathTest2.java")
   119                 .files("ClassPathTest2.java")
   118                 .run();
   120                 .run();
   119 
   121 
   120 //        testJavac failure ClassPathTest1.java
   122 //        testJavac failure ClassPathTest1.java
   121         tb.new JavacTask(ToolBox.Mode.EXEC)
   123         new JavacTask(tb, Task.Mode.EXEC)
   122                 .envVar("CLASSPATH", "bar")
   124                 .envVar("CLASSPATH", "bar")
   123                 .files("ClassPathTest1.java")
   125                 .files("ClassPathTest1.java")
   124                 .run(ToolBox.Expect.FAIL);
   126                 .run(Task.Expect.FAIL);
   125 
   127 
   126 //        testJavac failure ClassPathTest3.java
   128 //        testJavac failure ClassPathTest3.java
   127         tb.new JavacTask(ToolBox.Mode.EXEC)
   129         new JavacTask(tb, Task.Mode.EXEC)
   128                 .envVar("CLASSPATH", "bar")
   130                 .envVar("CLASSPATH", "bar")
   129                 .files("ClassPathTest3.java")
   131                 .files("ClassPathTest3.java")
   130                 .run(ToolBox.Expect.FAIL);
   132                 .run(Task.Expect.FAIL);
   131 
   133 
   132 //        testJavac success -classpath foo ClassPathTest1.java
   134 //        testJavac success -classpath foo ClassPathTest1.java
   133         tb.new JavacTask(ToolBox.Mode.EXEC)
   135         new JavacTask(tb, Task.Mode.EXEC)
   134                 .envVar("CLASSPATH", "bar")
   136                 .envVar("CLASSPATH", "bar")
   135                 .classpath("foo")
   137                 .classpath("foo")
   136                 .files("ClassPathTest1.java")
   138                 .files("ClassPathTest1.java")
   137                 .run();
   139                 .run();
   138 
   140 
   139 //        testJavac failure -classpath foo ClassPathTest2.java
   141 //        testJavac failure -classpath foo ClassPathTest2.java
   140         tb.new JavacTask(ToolBox.Mode.EXEC)
   142         new JavacTask(tb, Task.Mode.EXEC)
   141                 .envVar("CLASSPATH", "bar")
   143                 .envVar("CLASSPATH", "bar")
   142                 .classpath("foo")
   144                 .classpath("foo")
   143                 .files("ClassPathTest2.java")
   145                 .files("ClassPathTest2.java")
   144                 .run(ToolBox.Expect.FAIL);
   146                 .run(Task.Expect.FAIL);
   145 
   147 
   146 //        testJavac failure -classpath foo ClassPathTest3.java
   148 //        testJavac failure -classpath foo ClassPathTest3.java
   147         tb.new JavacTask(ToolBox.Mode.EXEC)
   149         new JavacTask(tb, Task.Mode.EXEC)
   148                 .envVar("CLASSPATH", "bar")
   150                 .envVar("CLASSPATH", "bar")
   149                 .classpath("foo")
   151                 .classpath("foo")
   150                 .files("ClassPathTest3.java")
   152                 .files("ClassPathTest3.java")
   151                 .run(ToolBox.Expect.FAIL);
   153                 .run(Task.Expect.FAIL);
   152     }
   154     }
   153 
   155 
   154 }
   156 }