Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/management/AgentCheckTest.java
38833 views
/*1* Copyright (c) 2004, 2012, 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*/2223/**24* @test25* @bug 501360526* @summary Localize log messages from the management agents27*28* @author Tim Bell29*/30import sun.management.Agent;3132public class AgentCheckTest {3334public static void main(String[] args){35String [][] testStrings = {36{"agent.err.error", "", ""},37{"jmxremote.ConnectorBootstrap.starting", "", ""},38{"jmxremote.ConnectorBootstrap.noAuthentication", "", ""},39{"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""},40{"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""},41{"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""},42{"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""},43{"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""},44{"jmxremote.AdaptorBootstrap.getTargetList.initialize1", "", ""},45{"jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Phony hostname", "Phony port"},46{"jmxremote.AdaptorBootstrap.getTargetList.terminate", "Phony exception", ""},47};4849boolean pass = true;50System.out.println("Start...");51for (int ii = 0; ii < testStrings.length; ii++) {52String key = testStrings[ii][0];53String p1 = testStrings[ii][1];54String p2 = testStrings[ii][2];55String ss = Agent.getText(key, p1, p2);56if (ss.startsWith("missing resource key")) {57pass = false;58System.out.println(" lookup failed for key = " + key);59}60}61if (!pass) {62throw new Error ("Resource lookup(s) failed; Test failed");63}64System.out.println("...Finished.");65}66}676869