X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fnetty-event-executor-config%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fnetty%2Feventexecutor%2FGlobalEventExecutorModuleTest.java;h=41a773a0d53f150c5f56ca18731f9a436286dc14;hp=6af508829be93eb6b64157562806753596b2ae64;hb=d7ef378979e5cb2916790d5e6c96e3262875885b;hpb=fd51e941751a3c0ef78b2b8d110ded138f763cf4 diff --git a/opendaylight/config/netty-event-executor-config/src/test/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModuleTest.java b/opendaylight/config/netty-event-executor-config/src/test/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModuleTest.java index 6af508829b..41a773a0d5 100644 --- a/opendaylight/config/netty-event-executor-config/src/test/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModuleTest.java +++ b/opendaylight/config/netty-event-executor-config/src/test/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModuleTest.java @@ -1,8 +1,18 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.config.yang.netty.eventexecutor; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import javax.management.InstanceAlreadyExistsException; import javax.management.ObjectName; - import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.config.api.ConflictingVersionException; @@ -15,12 +25,12 @@ import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; public class GlobalEventExecutorModuleTest extends AbstractConfigTest { private GlobalEventExecutorModuleFactory factory; - private final String instanceName = "netty1"; + private final String instanceName = GlobalEventExecutorModuleFactory.SINGLETON_NAME; @Before public void setUp() { factory = new GlobalEventExecutorModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory)); + super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory)); } @Test @@ -29,12 +39,23 @@ public class GlobalEventExecutorModuleTest extends AbstractConfigTest { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); createInstance(transaction, instanceName); - createInstance(transaction, instanceName + 2); + transaction.validateConfig(); CommitStatus status = transaction.commit(); - assertBeanCount(2, factory.getImplementationName()); - assertStatus(status, 2, 0, 0); + assertBeanCount(1, factory.getImplementationName()); + assertStatus(status, 1, 0, 0); + } + + @Test + public void testConflictingName() throws Exception { + ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); + try { + createInstance(transaction, instanceName + "x"); + fail(); + }catch(IllegalArgumentException e){ + assertTrue(e.getMessage() + " failure", e.getMessage().contains("only allowed name is singleton")); + } } @Test