03380392e89c658e276c9af2f65ebbec1529a262
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / impl / util / ObjectNameUtilTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.config.manager.impl.util;
9
10 import java.util.Set;
11
12 import javax.management.ObjectName;
13
14 import org.junit.After;
15 import org.junit.Before;
16 import org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest;
17
18 import com.google.common.base.Throwables;
19 import com.google.common.collect.Sets;
20
21 public class ObjectNameUtilTest extends AbstractLockedPlatformMBeanServerTest {
22     private Set<ObjectName> unregisterONs;
23
24     @Before
25     public void initUnregisterList() {
26         unregisterONs = Sets.newHashSet();
27     }
28
29     @After
30     public void unregisterONs() {
31         Exception lastException = null;
32         for (ObjectName on : unregisterONs) {
33             try {
34                 platformMBeanServer.unregisterMBean(on);
35             } catch (Exception e) {
36                 lastException = e;
37             }
38         }
39         if (lastException != null) {
40             Throwables.propagate(lastException);
41         }
42     }
43 }