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