RSS

Category Archives: Java

Bringing together Docker, Grunt, Maven, EmberJS & MongoDB

Abstract : Will it work? … How can I be sure? … Am I forgetting something? … questions that pile up slowly and ruin our confidence once we cannot clearly answer them. For reasons like these we write tests – to be confident, to be certain, to sleep better. Yet, writing tests is one part of the problem. Getting them executed in an environment close to the production one is another . … and so, more questions pile up : How do we keep a snapshot of our production environment for testing purposes? What if our app needs to run in different environments? Can we keep multiple virtual environment snapshots? How many? Can we have test parallelization? Is the sandboxing guaranteed? and so on, and so on …

In this post, we are going to take a look at orchestrating Maven, Grunt & Docker to provide the basis for setting up integration tests.

Read more @ ingini.org

 
Leave a comment

Posted by on June 17, 2014 in Docker, EmberJS, Grunt, Guice, Java, Jetty, Jongo, MongoDB

 

Tags: , , , , , , , ,

MongoDB With Jongo – Sleeves Up!

Abstract : In this post you will find a brief introduction to Jongo – a fast, easy-to-use, Java-based querying library for MongoDB. There are plenty of articles discussing MongoDB around the Internet and it’s documentation is quite good. Thus, here you won’t find any introduction to MongoDB nor am I going to convince you to use it or not. In this article I’m going to show you that querying MongoDB from Java can be easy. Don’t be afraid from the size of the post, most of it is simple code and data samples.

Goal : Basic use of Jongo for querying MongoDB.

Acknowledgement : My gratitude goes to the open source community and especially to:

Benoit Guérout creator of Jongo

Yves Amsellem co-creator of Jongo

Xavier Bourguignon for his open-mind and open-heart

Code : You can download the full source of the project from GitHub

Read more @ ingini.org

 
Leave a comment

Posted by on June 3, 2013 in Java, Jongo, MongoDB

 

Tags: , , ,

AKKA ask pattern: For those times when you have to block

Abstract : Since you are here, chances are, you are in one of those situations where you have to come up with a blocking solution using AKKA. Thus I’m going to skip the actor model introduction which is necessary to understand how AKKA actor model implementation works (you can read more about the actor model on the AKKA docs website). In this post you will find out how you can take advantage of AKKA’s ask pattern to do blocking when necessary.

Goal : Develop a “fire-and-await-confirmation” system based on AKKA ask pattern

Acknowledgement : My gratitude goes to the open source community and especially to:

Jonas Bonér (@jboner) for the creation of AKKA

Viktor Klang (@viktorklang) for his attention to the details

Maxime Nowak (@maximenowak) for his eye-opening discussions and “religious” clean-coding

Code : You can download the full source of the project from GitHub

Full post : Read more @ ingini.org

 
Leave a comment

Posted by on April 1, 2013 in Actor Model, AKKA, Java, Spring

 

Tags: , , ,

Chatting Through JActor

Abstract : Nearly 40 years ago Carl Hewitt, Peter Bishop and Richard Steiger introduced the actor model. Since then it has been built in some languages (such as Scala, Erlang, etc.) and has been implemented by several frameworks. One (of not so many) Java actor frameworks is the JActor framework – “a high-throughput Java Actor framework” (as described by its author Bill la Forge). In this post we are going to take a (brief) look at JActor framework by building a simple backbone for chatting (j)actors.

Goal : Build a simple chat application using JActor framework

Acknowledgement: My gratitude goes to the open source community and especially to:

Bill la Forge creator of JActor framework

Code : Project code can be found @ GitHub under Apache License, Version 2.0

Full post : Read more @ ingini.org

 
Leave a comment

Posted by on November 23, 2012 in JActor, Java, Uncategorized

 

Tags: , , , , , , , , , , ,

Chasing Heisenbugs from an AKKA actor integration test with awaitility

Abstract : Ever had an impression you’re changing what you’re observing by simply observing it? If you so, you may have hit a Heisenbug ([1], [2]). Well, OK, I agree that a more precise definition of “observing” is needed and that we can differentiate between active and passive observing. The thing is one can hardly be a fully passive observer, especially when it comes to testing multi-threaded programs. Assuming you’re really working on the program and not simply looking a video tutorial in which case you will be a fully passive observer (and I would be wondering how the heck you’ve tumbled on my article). In short, when working on (including testing) a program we may introduce Heisenbugs through levels of indirection which are usually hard to spot. In C/C++ such a level of indirection represents uninitialized auto variables which can change every time you run you program. In Java a source of many indirection levels is the platform independence provided by the JVM. In JavaScript a source of Heisenbugs can be processing uncontrolled (browser dependent) events such as the scroll event.

Goal : Chase and fix a Heisenbug within an AKKA actor integration test using Awaitility

Acknowledgement: My gratitude goes to the open source community

An AKKA actor based program : I’ve already given an example of an AKKA actor base program here and you can find the source code here. So to save you and me some time, I’m going to re-use it.

Naïve test case : First we are going to build a test case which is prone to Heisenbugs and then we are going to fix it. I’m going to use JUnit, Spring Test Framework, Mockito, FEST-Assert, and FEST-Reflect to build up the following integration test case (access article’s full source code):

import akka.actor.ActorRef;
import org.honeysoft.akka.Bootstrap;
import org.honeysoft.akka.service.IBusinessService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.fest.reflect.core.Reflection.field;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@ContextConfiguration(classes = {Bootstrap.class})
@RunWith(SpringJUnit4ClassRunner.class)
public class BusinessActorTest {

    @Autowired
    @Qualifier(Bootstrap.BUSINESS_ACTOR)
    private ActorRef businessActorRef;

    @Autowired
    private IBusinessService businessService;

    @Mock
    private Logger mockBusinessServiceLogger;

    @Before
    public void beforeEach() {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void shouldBeValidWhenNoOneIsNull() {
        //GIVEN
        field("logger").ofType(Logger.class).in(businessService).postDecorateWith(mockBusinessServiceLogger);

        //WHEN
        String testString = "test-string";
        businessActorRef.tell(testString);

        //THEN
        verify(mockBusinessServiceLogger, times(1)).info(anyString(), eq(testString));
    }
}

The thing is that this test case is prone to Heisenbugs. More precisely, the verification (at line 50) may pass some times and may fail others. Depending on the speed of execution and thread priority it can happen that the verification comes before the businessService receives the testString for processing. Luckily we have Awaitility at our disposal so the fix is straightforward:

import akka.actor.ActorRef;
import com.jayway.awaitility.Awaitility;
import com.jayway.awaitility.Duration;
import org.fest.assertions.Assertions;
import org.honeysoft.akka.Bootstrap;
import org.honeysoft.akka.service.IBusinessService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import static org.fest.reflect.core.Reflection.field;

@ContextConfiguration(classes = {Bootstrap.class})
@RunWith(SpringJUnit4ClassRunner.class)
public class BusinessActorTest {

    @Autowired
    @Qualifier(Bootstrap.BUSINESS_ACTOR)
    private ActorRef businessActorRef;

    @Autowired
    private IBusinessService businessService;

    @Before
    public void beforeEach() {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void shouldBeValidWhenNoOneIsNull() throws Exception {
        //GIVEN
        final ConcurrentMap<String, Object> threadSafeMap = new ConcurrentHashMap<String, Object>(1);
        field("logger").ofType(Logger.class).in(businessService).postDecorateWith(new TestLogger(threadSafeMap));

        //WHEN
        String testString = "test-string";
        businessActorRef.tell(testString);

        //THEN
        Awaitility.waitAtMost(Duration.FIVE_SECONDS).until(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                return !threadSafeMap.isEmpty();
            }
        });

        Assertions.assertThat(threadSafeMap).hasSize(1);
        Assertions.assertThat(threadSafeMap.values().iterator().next()).isEqualTo(testString);
    }

    private static final class TestLogger implements Logger {

        private final ConcurrentMap<String, Object> map;

        private TestLogger(ConcurrentMap<String, Object> map) {
            this.map = map;
        }

        @Override
        public void info(String format, Object arg) {
            map.put(format, arg);
        }

        //Other overridden methods go here
    }
}

So what happened is that instead of mocking our logger target we’ve created a thread-safe TestLogger to help us. Then we’ve added an awaitility block to either wait for at most 5 secs or until our piggy-bag map is not empty. Well, that was all. Not too painful right?

 

Tags: , , , , , , , , , , , , ,

AKKA actor dependency injection using Spring

Abstract : Dependency Injection (DI) is refine flavour of Inversion of Control (IoC) design pattern. One of the software frameworks out there which provides DI implementation is Spring. AKKA on the other hand is “a toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on the JVM“. In this article we are going to concentrate on the actor model implemented by AKKA and more specifically on dependency injection in the UntypedActor class, as well as, injecting AKKA actor in a Spring enabled service.

Goal : Create a software bridge between Spring and an AKKA actor to ensure basic dependency injection

Acknowledgement : My gratitude goes to the open source community

We are going to use the following components to reach our goal: AKKA version 2.0.2, Spring 3.1.1.RELEASE, FEST Reflect 1.4, Logback 1.0.6, CGLIB 2.2, and Maven to glue everything together. All programming will be done in Java and you can find all files on GitHub. Don’t hesitate to fork the project and improve it. Here is the Maven POM file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.honeysoft.akka</groupId>
    <artifactId>akka-di</artifactId>
    <version>1.0</version>

    <properties>
        <akka.version>2.0.2</akka.version>
        <spring.version>3.1.1.RELEASE</spring.version>
        <fest-reflect.version>1.4</fest-reflect.version>
        <logback.version>1.0.6</logback.version>
    </properties>

    <dependencies>
        <!-- Akka dependencies  -->
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor</artifactId>
            <version>${akka.version}</version>
        </dependency>

        <!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Tools -->
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-reflect</artifactId>
            <version>${fest-reflect.version}</version>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>akka.repository</id>
            <name>Akka Maven Repository</name>
            <url>http://repo.akka.io/releases/</url>
        </repository>
    </repositories>
 </project>

Good. Once you have all what’s needed we can start by building our simple business service which we are going to inject in our actor, here it is:

package org.honeysoft.akka.service;

public interface IBusinessService {

    void doBusiness(Object o);
}

… and it’s implementation:

package org.honeysoft.akka.service.impl;

import org.honeysoft.akka.service.IBusinessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class BusinessService implements IBusinessService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void doBusiness(Object o) {
        logger.info("Doing business with {}", o);
    }
}

As we can seen there is nothing fancy in our simple business service. All that it’s doing is logging an information about doing business with someone. Note, however, that it’s annotated with @Service this allows it to be discovered, created and injected by Spring.

Now, let’s see our actor:

package org.honeysoft.akka.actor;

import akka.actor.UntypedActor;
import org.honeysoft.akka.service.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;

public class BusinessActor extends UntypedActor {

    @Autowired
    private IBusinessService businessService;

    @Override
    public void onReceive(Object o) throws Exception {
        businessService.doBusiness(o);
    }
}

Once more, nothing special, just injecting our business service using the @Autowired annotation. Now comes the interesting part. We are going to need a custom implementation of akka.actor.Props class:

package org.honeysoft.akka.di;

import akka.actor.Props;
import akka.actor.UntypedActorFactory;
import org.springframework.context.ApplicationContext;

public class DependencyInjectionProps extends Props {
    /**
     * No-args constructor that sets all the default values.
     */
    public DependencyInjectionProps(ApplicationContext applicationContext, Class<?> actorClass) {
        super(new SpringUntypedActorFactory(actorClass, applicationContext));
    }

    /**
     * Java API.
     */
    public DependencyInjectionProps(ApplicationContext applicationContext, UntypedActorFactory factory) {
        super(new SpringUntypedActorFactory(factory, applicationContext));
    }
}

The interesting part here is our SpringUntypedActorFactory which is implemented as follows:

package org.honeysoft.akka.di;

import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import java.lang.reflect.Field;

import static org.fest.reflect.util.Accessibles.setAccessible;
import static org.fest.reflect.util.Accessibles.setAccessibleIgnoringExceptions;

public class SpringUntypedActorFactory implements UntypedActorFactory {

    private final DependencyInjectionFactory dependencyInjectionFactory;

    private final ApplicationContext applicationContext;

    public SpringUntypedActorFactory(Class<?> actorClass, ApplicationContext applicationContext) {
        this.dependencyInjectionFactory = new DefaultUntypedActorFactory(actorClass);
        this.applicationContext = applicationContext;
    }

    public SpringUntypedActorFactory(UntypedActorFactory customFactory, ApplicationContext applicationContext) {
        this.dependencyInjectionFactory = new SpecificUntypedActorFactory(customFactory);
        this.applicationContext = applicationContext;
    }

    private interface DependencyInjectionFactory {
        UntypedActor createAndInject();
    }


    private abstract class AbstractUntypedActorFactory implements DependencyInjectionFactory {

        @Override
        public final UntypedActor createAndInject() {
            try {
                UntypedActor untypedActor = create();

                Class<?> aClass = getActorClass();
                for (Field field : aClass.getDeclaredFields()) {

                    if (field.getAnnotation(Autowired.class) != null) {
                        boolean accessible = field.isAccessible();
                        try {
                            setAccessible(field, true);
                            field.set(untypedActor, applicationContext.getBean(field.getType()));
                        } catch (IllegalAccessException e) {
                            throw new IllegalStateException("Unable to create actor instance", e);
                        } finally {
                            setAccessibleIgnoringExceptions(field, accessible);
                        }
                    }
                }
                return untypedActor;

            } catch (InstantiationException e) {
                throw new IllegalStateException("Unable to create actor instance", e);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("Unable to create actor instance", e);
            }

        }

        protected abstract Class<?> getActorClass();

        protected abstract UntypedActor create() throws InstantiationException, IllegalAccessException;

    }

    private final class SpecificUntypedActorFactory extends AbstractUntypedActorFactory {

        private final UntypedActorFactory specificFactory;
        private volatile Class<?> actorClass;

        private SpecificUntypedActorFactory(UntypedActorFactory specificFactory) {
            this.specificFactory = specificFactory;
        }

        @Override
        protected Class<?> getActorClass() {
            return actorClass;
        }

        @Override
        protected UntypedActor create() throws InstantiationException, IllegalAccessException {
            UntypedActor untypedActor = (UntypedActor) specificFactory.create();
            actorClass = untypedActor.getClass();
            return untypedActor;
        }
    }

    private final class DefaultUntypedActorFactory extends AbstractUntypedActorFactory {
        private final Class<?> actorClass;

        public DefaultUntypedActorFactory(Class<?> actorClass) {
            this.actorClass = actorClass;
        }

        @Override
        protected Class<?> getActorClass() {
            return actorClass;
        }

        @Override
        protected UntypedActor create() throws InstantiationException, IllegalAccessException {
            return (UntypedActor) actorClass.newInstance();
        }
    }

    /**
     * This method must return a different instance upon every call.
     */
    @Override
    public UntypedActor create() {
        return dependencyInjectionFactory.createAndInject();
    }
}

Inside our custom SpringUntypedActorFactory is a Strategy pattern which allows us to inject Spring context available beans in an actor fields annotated with @Autowired.

Well, that’s almost all. Now we need a bootstrap component and we are going to provide one using XML-less Spring configuration:

package org.honeysoft.akka;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import org.honeysoft.akka.actor.BusinessActor;
import org.honeysoft.akka.di.DependencyInjectionProps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
@ComponentScan({"org.honeysoft.akka.service"})
public class Bootstrap {

    public static final String BUSINESS_ACTOR = "honeysoft-business-actor";
    public static final String ACTOR_SYSTEM = "honeysoft-actor-actorSystem";
    private ActorSystem actorSystem;

    @Autowired
    private ApplicationContext applicationContext;

    @Bean(name = ACTOR_SYSTEM, destroyMethod = "shutdown")
    public ActorSystem actorSystem() {
        actorSystem = ActorSystem.create(ACTOR_SYSTEM);
        return actorSystem;
    }

    @Bean(name = BUSINESS_ACTOR)
    @DependsOn({ACTOR_SYSTEM})
    public ActorRef businessActor() {
        return actorSystem.actorOf(//
                new DependencyInjectionProps(applicationContext, BusinessActor.class), BUSINESS_ACTOR);
    }
}

Oh, you can also inject our BusinessActor in another Spring enabled service (or component in general) like this:


import akka.actor.ActorRef;
import org.honeysoft.akka.Bootstrap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class MyCoolService {

    @Autowired
    @Qualifier(Bootstrap.BUSINESS_ACTOR)
    private ActorRef businessActor;
    
    public void doSomething() {
       businessActor.tell("message"); 
       // more logic goes here ...
    }
}

That was all folks. Now it’s up to you to leave a comment or contribute on GitHub.

 
8 Comments

Posted by on August 5, 2012 in AKKA, FEST-Reflect, Java, Maven, Spring

 

Tags: , ,

Testing AKKA actors with Mockito and FEST-Reflect

Abstract : One of the few frameworks implementing the actor model is AKKA. In fact AKKA is a lot more than just an implementation of the actor model, but within this post we are going to concentrate on combining Mockito, JUnit and FEST-Reflect in order to facilitate actor testing and thus we won’t need all the fancy features of AKKA.
Goal : Mocking an instance field within an AKKA actor.
Acknowledgement: My gratitude goes to the open source community and to the following people:
Munish K Gupta – Using AKKA testkit with Java

In order to reach our goal will need the following maven configuration. Note that you need to add the AKKA repository:

<!-- other maven configuration -->
    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor</artifactId>
            <version>2.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-reflect</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
        </dependency>

        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-testkit</artifactId>
            <version>2.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.0</version>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>akka.repository</id>
            <name>Akka Maven Repository</name>
            <url>http://repo.akka.io/releases/</url>
        </repository>
        <!-- other repositories ... -->
    </repositories>

The actor which we are going to test looks like this:

import akka.actor.UntypedActor;
import com.honeysoft.business.service.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;

public class BusinessActor extends UntypedActor {

    @Autowired
    private IBusinessService businessService;

    @Override
    public void onReceive(Object message) {
        businessService.doBusiness(message);
    }
}

As you can see, I’m using Spring framework for dependency injection within the actor, but you are free to choose whatever approach you want to instantiate and assign the business service.

Our goal is quite simple, we have to mock the businessService within our BusinessActor. The difficulty comes from the fact that in a test case we are going to have an ActorRef reference variable to our actor and not a plain Actor reference. This means that our actor is actually nested within an ActorRef reference. As you might already guessed this brings further complications for mocking our businessService reference within the actor instance itself. Or in other words, our businessService is deeply nested and the exact path is actorRef.actorCell.actor.businessService. Luckily for us, since version 1.4 of FEST-Reflect we can play with (deeply) nested fields with a single line of code (not counting the static import). Here is how:

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import com.honeysoft.business.service.IBusinessService;
import com.typesafe.config.ConfigFactory;
import org.fest.reflect.core.Reflection;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;

import static org.fest.reflect.core.Reflection.*;
import static org.mockito.Matchers.eq;

@RunWith(MockitoJUnitRunner.class)
public class TestBusinessActor {

    static ActorSystem akkaSystem = ActorSystem.create("honeysoft-test-system", ConfigFactory.load().getConfig("honeysoft-test-system"));

    @Mock
    private IBusinessService businessServiceMock;

    private ActorRef businessActor;

    @Before
    public void setup() {
        businessActor = akkaSystem.actorOf(new Props(BusinessActor.class));
    }

    @After
    public void clean() {
        akkaSystem.stop(businessActor);
    }

    @Test
    public void shouldExecuteBusinessMethod() {
        //GIVEN
        String businessMessage = "Some business message";

        field("actorCell.actor.businessService").ofType(IBusinessService.class)//
            .in(businessActor).set(businessServiceMock);

        //WHEN
        businessActor.tell(businessMessage);

        //THEN
        Mockito.verify(businessServiceMock, Mockito.times(1))//
            .doBusiness(eq(businessMessage));
    }
}

As you can see from the highlighted line 43 setting a deeply nested variable is as simple as specifying the path to it. Note that the exact path is businessActor.actorCell.actor.businessService, but the businessActor is already passed to the .in() method and thus as an argument to field() we have only “actorCell.actor.businessService”.

To run the test you are also going to need a configuration file named application.conf which I have placed in my src/test/resources directory. The content of application.conf is:

honeysoft-test-system {
	akka {
	    mode = test
	  	event-handlers = ["akka.testkit.TestEventListener"]
		loglevel = DEBUG
		actor {
			debug {
			 receive = on
			 autoreceive = on
			 lifecycle = on
			}
		}
  	}
}

Well that was all for this post. Don’t hesitate to leave a comment!

 
2 Comments

Posted by on July 1, 2012 in AKKA, FEST-Reflect, Java, JUnit, Maven, Mockito

 

Tags: , , , ,