/* * Copyright (c) 2018, 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 8193660 * @summary Check SOURCE line in "release" file for closedjdk * @run main CheckSource
*/
// open the stream to read in for Entries try (BufferedReader buffRead = new BufferedReader(new FileReader(fileName))) {
// this is the string read
String readIn;
// let's read some strings! while ((readIn = buffRead.readLine()) != null) {
readIn = readIn.trim();
// throw out blank lines if (readIn.length() == 0) continue;
// grab SOURCE line if (readIn.startsWith("SOURCE=")) {
fishForSOURCE = readIn; continue;
}
// grab IMPLEMENTOR line if (readIn.startsWith("IMPLEMENTOR=")) {
implementor = readIn; continue;
}
}
} catch (FileNotFoundException fileExcept) { thrownew RuntimeException("File " + fileName + " not found reading data!", fileExcept);
} catch (IOException ioExcept) { thrownew RuntimeException("Unexpected problem reading data!",
ioExcept);
}
// was SOURCE even found? if (fishForSOURCE == null) { thrownew RuntimeException("SOURCE line was not found!");
}
System.out.println("The source string found: " + fishForSOURCE);
// Extract the value of SOURCE=
Pattern valuePattern = Pattern.compile("SOURCE=\"(.*)\"");
Matcher valueMatcher = valuePattern.matcher(fishForSOURCE); if (!valueMatcher.matches()) { thrownew RuntimeException("SOURCE string has bad format, should be SOURCE=\"<value>\"");
}
String valueString = valueMatcher.group(1);
// Check if implementor is Oracle boolean isOracle = (implementor != null) && implementor.contains("Oracle Corporation");
String[] values = valueString.split(" ");
// First value MUST start with ".:" regardless of Oracle or OpenJDK
String rootRegexp = "\\." + SRC_HASH_REGEXP; if (!values[0].matches(rootRegexp)) { thrownew RuntimeException("The test failed, first element did not match regexp: "+ rootRegexp);
}
// If it's an Oracle build, it can be either OpenJDK or OracleJDK. Other // builds may have any number of additional elements in any format. if (isOracle) { if (isOpenJDK) { if (values.length != 1) { thrownew RuntimeException("The test failed, wrong number of elements in SOURCE list." + " Should be 1 for Oracle built OpenJDK.");
}
} else { if (values.length != 2) { thrownew RuntimeException("The test failed, wrong number of elements in SOURCE list." + " Should be 2 for OracleJDK.");
} // Second value MUST start with "open:" for OracleJDK
String openRegexp = "open" + SRC_HASH_REGEXP; if (!values[1].matches(openRegexp)) { thrownew RuntimeException("The test failed, second element did not match regexp: " + openRegexp);
}
}
}
// Everything was fine
System.out.println("The test passed!");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.