jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java
changeset 43729 21db38703675
parent 43185 d75d9ff8d4e7
equal deleted inserted replaced
43728:e188ba772b26 43729:21db38703675
   153 
   153 
   154         for (String arch : ARCHITECTURES) {
   154         for (String arch : ARCHITECTURES) {
   155             String[] winput = new String[input.length];
   155             String[] winput = new String[input.length];
   156             String[] woutput = new String[expectedOutput.length];
   156             String[] woutput = new String[expectedOutput.length];
   157             for (int i = 0; i < input.length; i++) {
   157             for (int i = 0; i < input.length; i++) {
   158                 winput[i] = "/java.base/native" + arch + input[i];
   158                 winput[i] = "/java.base/lib" + arch + input[i];
   159             }
   159             }
   160             for (int i = 0; i < expectedOutput.length; i++) {
   160             for (int i = 0; i < expectedOutput.length; i++) {
   161                 woutput[i] = "/java.base/native" + arch + expectedOutput[i];
   161                 woutput[i] = "/java.base/lib" + arch + expectedOutput[i];
   162             }
   162             }
   163             doCheckVM(vm, winput, jvmcfg, woutput, expectdJvmCfg);
   163             doCheckVM(vm, winput, jvmcfg, woutput, expectdJvmCfg);
   164         }
   164         }
   165     }
   165     }
   166 
   166 
   167     private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception {
   167     private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception {
   168         // Create a pool with jvm.cfg and the input paths.
   168         // Create a pool with jvm.cfg and the input paths.
   169         byte[] jvmcfgContent = jvmcfg.getBytes();
   169         byte[] jvmcfgContent = jvmcfg.getBytes();
   170         ResourcePoolManager poolMgr = new ResourcePoolManager();
   170         ResourcePoolManager poolMgr = new ResourcePoolManager();
   171         poolMgr.add(
   171         poolMgr.add(
   172             ResourcePoolEntry.create("/java.base/native/jvm.cfg",
   172             ResourcePoolEntry.create("/java.base/lib/jvm.cfg",
   173                 ResourcePoolEntry.Type.NATIVE_LIB, jvmcfgContent));
   173                 ResourcePoolEntry.Type.NATIVE_LIB, jvmcfgContent));
   174 
   174 
   175         // java.base/module-info.class is used by exclude vm plugin
   175         // java.base/module-info.class is used by exclude vm plugin
   176         // to get current osName(). We read it from jrt-fs and add a
   176         // to get current osName(). We read it from jrt-fs and add a
   177         // ResourcePoolEntry
   177         // ResourcePoolEntry
   190             config.put(ExcludeVMPlugin.NAME, vm);
   190             config.put(ExcludeVMPlugin.NAME, vm);
   191         }
   191         }
   192         p.configure(config);
   192         p.configure(config);
   193         ResourcePool out = p.transform(poolMgr.resourcePool(), outMgr.resourcePoolBuilder());
   193         ResourcePool out = p.transform(poolMgr.resourcePool(), outMgr.resourcePoolBuilder());
   194 
   194 
   195         String newContent = new String(out.findEntry("/java.base/native/jvm.cfg").get().contentBytes());
   195         String newContent = new String(out.findEntry("/java.base/lib/jvm.cfg").get().contentBytes());
   196 
   196 
   197         if (!expectdJvmCfg.equals(newContent)) {
   197         if (!expectdJvmCfg.equals(newContent)) {
   198             throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
   198             throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
   199         }
   199         }
   200 
   200 
   207             });
   207             });
   208             throw new Exception("Invalid output size " + out.entryCount() + " expected " + (expectedOutput.length + 2));
   208             throw new Exception("Invalid output size " + out.entryCount() + " expected " + (expectedOutput.length + 2));
   209         }
   209         }
   210 
   210 
   211         out.entries().forEach(md -> {
   211         out.entries().forEach(md -> {
   212             if (md.path().equals("/java.base/native/jvm.cfg") ||
   212             if (md.path().equals("/java.base/lib/jvm.cfg") ||
   213                 md.path().equals("/java.base/module-info.class")) {
   213                 md.path().equals("/java.base/module-info.class")) {
   214                 return;
   214                 return;
   215             }
   215             }
   216             boolean contained = false;
   216             boolean contained = false;
   217             for (String o : expectedOutput) {
   217             for (String o : expectedOutput) {