Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java
38859 views
1/**2* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it under6* the terms of the GNU General Public License version 2 only, as published by7* the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT ANY10* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR11* A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more12* details (a copy is included in the LICENSE file that accompanied this code).13*14* You should have received a copy of the GNU General Public License version 215* along with this work; if not, write to the Free Software Foundation, Inc., 5116* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA or19* visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.security.auth.login.LoginContext;2425/**26* @test27* @bug 805046128* @summary Test should throw Configuration error if configuration file contains29* syntax error30* @build SampleLoginModule JAASConfigSyntaxTest31* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutApplication.config JAASConfigSyntaxTest32* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutBraces.config JAASConfigSyntaxTest33* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutFlag.config JAASConfigSyntaxTest34* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutLoginModule.config JAASConfigSyntaxTest35* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutSemiColen.config JAASConfigSyntaxTest36*/37public class JAASConfigSyntaxTest {3839private static final String TEST_NAME = "JAASConfigSyntaxTest";4041public static void main(String[] args) throws Exception {42try {43LoginContext lc = new LoginContext(TEST_NAME);44lc.login();45throw new RuntimeException("Test Case Failed, did not get "46+ "expected exception");47} catch (Exception ex) {48if (ex.getMessage().contains("java.io.IOException: "49+ "Configuration Error:")) {50System.out.println("Test case passed");51} else {52throw new RuntimeException(ex);53}54}55}56}575859