Path: blob/master/test/jdk/javax/management/ObjectName/DelegateNameWildcardNameTest.java
41149 views
/*1* Copyright (c) 2005, 2015, 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 478040026* @summary Test that MBeanServerDelegate.DELEGATE_NAME and ObjectName.WILDCARD27* public constants have been initialized properly.28* @author Luis-Miguel Alventosa29*30* @run clean DelegateNameWildcardNameTest31* @run build DelegateNameWildcardNameTest32* @run main DelegateNameWildcardNameTest33*/3435import javax.management.MBeanServerDelegate;36import javax.management.ObjectName;3738public class DelegateNameWildcardNameTest {3940public static void main(String[] args) throws Exception {4142System.out.println(43"Test that <MBeanServerDelegate.DELEGATE_NAME> equals " +44"<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>");45final ObjectName delegateName =46new ObjectName("JMImplementation:type=MBeanServerDelegate");47if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME))48throw new AssertionError("Unexpected value: " +49"MBeanServerDelegate.DELEGATE_NAME = " +50MBeanServerDelegate.DELEGATE_NAME);51System.out.println("MBeanServerDelegate.DELEGATE_NAME = " +52"new ObjectName(\"" + delegateName + "\")");5354System.out.println("Test that <ObjectName.WILDCARD> " +55"equals <new ObjectName(\"*:*\")>");56final ObjectName wildcardName = new ObjectName("*:*");57if (!wildcardName.equals(ObjectName.WILDCARD))58throw new AssertionError("Unexpected value: " +59"ObjectName.WILDCARD = " +60ObjectName.WILDCARD);61System.out.println("ObjectName.WILDCARD = " +62"new ObjectName(\"" + wildcardName + "\")");6364System.out.println("Test passes: constants were initialized properly");65}66}676869