test/java/module/modinit/JRepoDependenciesTest.java

Print this page




  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 import java.io.*;
  25 import java.module.*;
  26 import java.util.*;
  27 import sun.module.tools.JRepo;
  28 
  29 /**
  30  * @test
  31  * @library ../tools ../tools/jrepo
  32  * @compile -XDignore.symbol.file
  33  *    RunMTest.java
  34  *    classp/MainX.java
  35  *    JRepoDependenciesTest.java
  36  * @run main/othervm
  37  *    -DTestDescriptionFactory.classname=JRepoDependenciesTest$MyFactory
  38  *    JRepoDependenciesTest
  39  */
  40 public class JRepoDependenciesTest {
  41     private static final boolean debug = Boolean.getBoolean("module.tools.debug");
  42 
  43     private static PrintStream outStream = null;
  44 
  45     private static final String[] tests = {
  46         "basic/import.mtest",
  47         "circular/circular2.mtest",
  48         "importpolicy/import1.mtest",
  49         "importpolicy/optional1.mtest",
  50         "importpolicy/optional2.mtest",
  51         "importpolicy/recurse1.mtest",


 114             if (debug) System.err.println("adding arg " + token);
 115             args.add(token);
 116         }
 117         if (debug) System.err.println("args length is " + args.size());
 118         return args.toArray(new String[0]);
 119     }
 120 
 121     public static class MyFactory extends RunMTest.TestDescriptionFactory {
 122 
 123         protected RunMTest.TestDescription doCreate(String name) {
 124             return new MyTestDescription(name);
 125         }
 126     }
 127 
 128     public static class MyTestDescription extends RunMTest.TestDescription {
 129         MyTestDescription(String name) {
 130             super(name);
 131         }
 132 
 133         protected void runTest(RunMTest mTest) throws Exception {
 134             Repository parent = sun.module.repository.RepositoryConfig.getSystemRepository();
 135             Repository repository = Modules.newLocalRepository(
 136                 mTest.getName(), mTest.outputDirectory, null, parent);
 137 
 138             File file = mTest.file;
 139             char SEP = File.separatorChar;
 140             String mString = SEP + "mtest" + SEP;
 141             String cPath = file.getCanonicalPath();
 142             int k = cPath.lastIndexOf(mString);
 143             String subdir;
 144             if (k == -1) {
 145                 subdir = file.getName();
 146             } else {
 147                 subdir = cPath.substring(k + mString.length());
 148             }
 149             resultStream.println(">>>Test " + subdir);
 150 
 151             JRepo jr = new JRepo(resultStream, new PrintStream(System.err), null);
 152 
 153             try {
 154                 check(jr.run(getArgs(




  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 import java.io.*;
  25 import java.module.*;
  26 import java.util.*;
  27 import sun.module.tools.JRepo;
  28 
  29 /**
  30  * @test

  31  * @compile -XDignore.symbol.file
  32  *    RunMTest.java
  33  *    classp/MainX.java
  34  *    JRepoDependenciesTest.java
  35  * @run main/othervm
  36  *    -DTestDescriptionFactory.classname=JRepoDependenciesTest$MyFactory
  37  *    JRepoDependenciesTest
  38  */
  39 public class JRepoDependenciesTest {
  40     private static final boolean debug = Boolean.getBoolean("module.tools.debug");
  41 
  42     private static PrintStream outStream = null;
  43 
  44     private static final String[] tests = {
  45         "basic/import.mtest",
  46         "circular/circular2.mtest",
  47         "importpolicy/import1.mtest",
  48         "importpolicy/optional1.mtest",
  49         "importpolicy/optional2.mtest",
  50         "importpolicy/recurse1.mtest",


 113             if (debug) System.err.println("adding arg " + token);
 114             args.add(token);
 115         }
 116         if (debug) System.err.println("args length is " + args.size());
 117         return args.toArray(new String[0]);
 118     }
 119 
 120     public static class MyFactory extends RunMTest.TestDescriptionFactory {
 121 
 122         protected RunMTest.TestDescription doCreate(String name) {
 123             return new MyTestDescription(name);
 124         }
 125     }
 126 
 127     public static class MyTestDescription extends RunMTest.TestDescription {
 128         MyTestDescription(String name) {
 129             super(name);
 130         }
 131 
 132         protected void runTest(RunMTest mTest) throws Exception {
 133             Repository parent = sun.module.repository.RepositoryConfig.getApplicationRepository();
 134             Repository repository = Modules.newLocalRepository(
 135                 mTest.getName(), mTest.outputDirectory, null, parent);
 136 
 137             File file = mTest.file;
 138             char SEP = File.separatorChar;
 139             String mString = SEP + "mtest" + SEP;
 140             String cPath = file.getCanonicalPath();
 141             int k = cPath.lastIndexOf(mString);
 142             String subdir;
 143             if (k == -1) {
 144                 subdir = file.getName();
 145             } else {
 146                 subdir = cPath.substring(k + mString.length());
 147             }
 148             resultStream.println(">>>Test " + subdir);
 149 
 150             JRepo jr = new JRepo(resultStream, new PrintStream(System.err), null);
 151 
 152             try {
 153                 check(jr.run(getArgs(