Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/management/relation/RelationNotificationSourceTest.java
38839 views
/*1* Copyright (c) 2005, 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 489267426* @summary Test that RelationNotification can be constructed with ObjectName.27* @author Eamonn McManus28* @run clean RelationNotificationSourceTest29* @run build RelationNotificationSourceTest30* @run main RelationNotificationSourceTest31*/3233import java.util.Collections;34import javax.management.*;35import javax.management.relation.*;36import static javax.management.relation.RelationNotification.*;3738public class RelationNotificationSourceTest {39public static void main(String[] args) throws Exception {40ObjectName name1 = new ObjectName("a:n=1");41ObjectName name2 = new ObjectName("a:n=2");42ObjectName name = new ObjectName("a:b=c");43Notification n1 =44new RelationNotification(RELATION_BASIC_REMOVAL,45name,461234L,47System.currentTimeMillis(),48"message",49"id",50"typeName",51name1,52Collections.singletonList(name2));53if (!name.equals(n1.getSource()))54throw new Exception("FAILED: source is " + n1.getSource());55Notification n2 =56new RelationNotification(RELATION_BASIC_UPDATE,57name,581234L,59System.currentTimeMillis(),60"message",61"id",62"typeName",63name1,64"role",65Collections.singletonList(name2),66Collections.singletonList(name2));67if (!name.equals(n2.getSource()))68throw new Exception("FAILED: source is " + n2.getSource());69System.out.println("TEST PASSED");70}71}727374