Path: blob/master/test/jdk/javax/crypto/SecretKeyFactory/TestFailOver.java
41149 views
/*1* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.File;24import java.nio.file.Path;25import java.nio.file.Paths;26import java.util.ArrayList;27import java.util.List;28import jdk.test.lib.compiler.CompilerUtils;29import jdk.test.lib.process.OutputAnalyzer;30import jdk.test.lib.process.ProcessTools;3132/*33* @test34* @bug 6370923 818056835* @summary SecretKeyFactory failover does not work36* @library /test/lib37* @build jdk.test.lib.compiler.CompilerUtils38* @run main TestFailOver39*/40public class TestFailOver {4142private static final Path SRC = Paths.get(System.getProperty("test.src"));43private static final String P1_JAR44= SRC.resolve("P1.jar").toFile().getAbsolutePath();45private static final String P2_JAR46= SRC.resolve("P2.jar").toFile().getAbsolutePath();47private static final String SEC_PROP48= SRC.resolve("security.properties").toFile().getAbsolutePath();49private static final String JF_NAME = "FailOverTest";50private static final Path SRC_PATH = SRC.resolve(JF_NAME + ".java");51private static final Path COMPILE_PATH = Paths.get(".");52private static final String PS = File.pathSeparator;5354public static void main(String[] args) throws Exception {5556List<String> params = getParameters();57// Compile all source files.58boolean done = CompilerUtils.compile(SRC_PATH, COMPILE_PATH,59params.toArray(String[]::new));60if (!done) {61throw new RuntimeException("Test setup failed.");62}63params.add(0, "-Djava.security.properties=" + SEC_PROP);64params.add(JF_NAME);65OutputAnalyzer oa = ProcessTools.executeTestJava(66params.toArray(String[]::new));67System.out.println(oa.getOutput());68oa.shouldHaveExitValue(0);69}7071private static List<String> getParameters() {7273List<String> cmds = new ArrayList<>();74cmds.add("-cp");75cmds.add(P1_JAR + PS + P2_JAR + PS + COMPILE_PATH);76return cmds;77}7879}808182