2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.remote.rpc;
12 import akka.actor.ActorSystem;
13 import com.typesafe.config.ConfigFactory;
14 import junit.framework.Assert;
15 import org.junit.After;
16 import org.junit.Test;
17 import org.opendaylight.controller.remote.rpc.utils.AkkaConfigurationReader;
18 import org.osgi.framework.Bundle;
19 import org.osgi.framework.BundleContext;
21 import static org.junit.Assert.fail;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
25 public class ActorSystemFactoryTest {
26 ActorSystem system = null;
29 public void testActorSystemCreation(){
30 BundleContext context = mock(BundleContext.class);
31 when(context.getBundle()).thenReturn(mock(Bundle.class));
33 AkkaConfigurationReader reader = mock(AkkaConfigurationReader.class);
34 when(reader.read()).thenReturn(ConfigFactory.load());
36 ActorSystemFactory.createInstance(context, reader);
37 system = ActorSystemFactory.getInstance();
38 Assert.assertNotNull(system);
39 // Check illegal state exception
42 ActorSystemFactory.createInstance(context, reader);
43 fail("Illegal State exception should be thrown, while creating actor system second time");
44 } catch (IllegalStateException e) {
49 public void cleanup() throws InterruptedException {