Resolve Bug:681 - Fix config module registration to Service Registry.
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / impl / ConfigTransactionManagerImplTest.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;
9
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
13 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
14
15 import javax.management.InstanceAlreadyExistsException;
16
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19 import static org.mockito.Mockito.mock;
20
21 public class ConfigTransactionManagerImplTest extends
22         AbstractConfigTest {
23
24     @Before
25     public void setUp() {
26         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext));
27
28     }
29
30     @Test
31     public void testSingleton() {
32         ConfigRegistryImpl mockedRegistry = mock(ConfigRegistryImpl.class);
33         try {
34             configRegistryJMXRegistrator.registerToJMX(mockedRegistry);
35             fail();
36         } catch (Exception e) {
37             assertTrue(e instanceof InstanceAlreadyExistsException);
38         }
39     }
40
41     @Test
42     public void testCleanUp() {
43         super.cleanUpConfigTransactionManagerImpl();
44         setUp();
45     }
46
47     @Test
48     public void testRemoteCallsUsingJMX() throws Exception {
49         ConfigTransactionJMXClient transaction = configRegistryClient
50                 .createTransaction();
51         transaction.commit();
52     }
53
54 }