1 2 /* 3 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /* 26 * @test 27 * @bug 8192837 28 * @summary Test to verify release file not contains close repo info if it's open bundle 29 */ 30 31 import java.io.BufferedReader; 32 import java.io.File; 33 import java.io.FileReader; 34 import java.io.FileNotFoundException; 35 import java.io.IOException; 36 37 public class Test8192837 { 38 39 Test8192837(String sDataFile) { 40 // Read data files 41 readFile(sDataFile); 42 } 43 44 private void readFile(String sFile) { 45 String sFishForSOURCE = null; 46 47 File fFile = new File(sFile); 48 49 // open the stream to read in for Entries 50 try (BufferedReader bRead = 51 new BufferedReader(new FileReader(sFile))) { 52 53 // this is the string read 54 String sReadIn; 55 56 // let's read some strings! 57 while ((sReadIn = bRead.readLine()) != null) { 58 sReadIn.trim(); 59 60 // throw out blank lines 61 if (sReadIn.length() == 0) 62 continue; 63 64 // grab the line 65 if (sReadIn.startsWith("SOURCE=")) 66 sFishForSOURCE = sReadIn; 67 } 68 } catch (FileNotFoundException eExcept) { 69 throw new RuntimeException("File " + sFile + 70 " not found reading data!", eExcept); 71 } catch (IOException eExcept) { 72 throw new RuntimeException("Unexpected problem reading data!", 73 eExcept); 74 } 75 76 // was SOURCE even found? 77 if (sFishForSOURCE == null) { 78 throw new RuntimeException("SOURCE line was not found!"); 79 } else { 80 // OK it was found, did it have closed/open in it? 81 if (sFishForSOURCE.contains("closed") || sFishForSOURCE.contains("open")) { 82 System.out.println("The offending string: " + sFishForSOURCE); 83 throw new RuntimeException("The test failed, closed/open found!"); 84 } 85 } 86 87 // Everything was fine 88 System.out.println("The test passed!"); 89 } 90 91 public static void main(String args[]) { 92 String sJdkPath = System.getProperty("test.jdk"); 93 String sRuntime = System.getProperty("java.runtime.name"); 94 95 System.out.println("JDK Path : " + sJdkPath); 96 System.out.println("Runtime Name : " + sRuntime); 97 98 if (sRuntime.contains("OpenJDK")) 99 new Test8192837(sJdkPath + "/release"); 100 else 101 System.out.println("Not an OpenJDK."); 102 } 103 }