--- /dev/null Tue Dec 12 11:11:44 2017 +++ new/test/jdk/sanity/Test8192837.java Tue Dec 12 11:11:43 2017 @@ -0,0 +1,103 @@ + +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8192837 + * @summary Test to verify release file not contains close repo info if it's open bundle + */ + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class Test8192837 { + + Test8192837(String sDataFile) { + // Read data files + readFile(sDataFile); + } + + private void readFile(String sFile) { + String sFishForSOURCE = null; + + File fFile = new File(sFile); + + // open the stream to read in for Entries + try (BufferedReader bRead = + new BufferedReader(new FileReader(sFile))) { + + // this is the string read + String sReadIn; + + // let's read some strings! + while ((sReadIn = bRead.readLine()) != null) { + sReadIn.trim(); + + // throw out blank lines + if (sReadIn.length() == 0) + continue; + + // grab the line + if (sReadIn.startsWith("SOURCE=")) + sFishForSOURCE = sReadIn; + } + } catch (FileNotFoundException eExcept) { + throw new RuntimeException("File " + sFile + + " not found reading data!", eExcept); + } catch (IOException eExcept) { + throw new RuntimeException("Unexpected problem reading data!", + eExcept); + } + + // was SOURCE even found? + if (sFishForSOURCE == null) { + throw new RuntimeException("SOURCE line was not found!"); + } else { + // OK it was found, did it have closed/open in it? + if (sFishForSOURCE.contains("closed") || sFishForSOURCE.contains("open")) { + System.out.println("The offending string: " + sFishForSOURCE); + throw new RuntimeException("The test failed, closed/open found!"); + } + } + + // Everything was fine + System.out.println("The test passed!"); + } + + public static void main(String args[]) { + String sJdkPath = System.getProperty("test.jdk"); + String sRuntime = System.getProperty("java.runtime.name"); + + System.out.println("JDK Path : " + sJdkPath); + System.out.println("Runtime Name : " + sRuntime); + + if (sRuntime.contains("OpenJDK")) + new Test8192837(sJdkPath + "/release"); + else + System.out.println("Not an OpenJDK."); + } +}