Added more tests for Bucket store
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / ActorSystemFactoryTest.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.remote.rpc;
10
11
12 import akka.actor.ActorSystem;
13 import junit.framework.Assert;
14 import org.junit.After;
15 import org.junit.Test;
16 import org.osgi.framework.Bundle;
17 import org.osgi.framework.BundleContext;
18
19 import static org.junit.Assert.fail;
20 import static org.mockito.Mockito.mock;
21 import static org.mockito.Mockito.when;
22
23 public class ActorSystemFactoryTest {
24   ActorSystem system = null;
25
26   @Test
27   public void testActorSystemCreation(){
28     BundleContext context = mock(BundleContext.class);
29     when(context.getBundle()).thenReturn(mock(Bundle.class));
30     ActorSystemFactory.createInstance(context);
31     system = ActorSystemFactory.getInstance();
32     Assert.assertNotNull(system);
33     // Check illegal state exception
34
35     try {
36       ActorSystemFactory.createInstance(context);
37       fail("Illegal State exception should be thrown, while creating actor system second time");
38     } catch (IllegalStateException e) {
39     }
40   }
41
42   @After
43   public void cleanup() throws InterruptedException {
44     if(system != null) {
45       system.shutdown();
46     }
47   }
48
49 }