@@ -0,0 +1,2626 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.apache.usergrid.persistence.qakka;%0A%0Aimport com.google.inject.Injector;%0Aimport org.apache.usergrid.persistence.core.migration.schema.MigrationException;%0Aimport org.apache.usergrid.persistence.core.migration.schema.MigrationManager;%0Aimport org.junit.BeforeClass;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0A%0Apublic abstract class AbstractAkkaTest %7B%0A    private static final Logger logger = LoggerFactory.getLogger( AbstractAkkaTest.class );%0A%0A    static AtomicInteger nextPort = new AtomicInteger(3551);%0A%0A//    protected static Injector sharedInjector;%0A%0A    static AtomicBoolean migrated = new AtomicBoolean( false );%0A%0A    static %7B new KeyspaceDropper(); %7D%0A%0A%0A    public AbstractAkkaTest() %7B%0A        if ( !migrated.getAndSet( true ) ) %7B%0A            //setInjector( Guice.createInjector( new TestModule() ) );%0A            MigrationManager migrationManager = getInjector().getInstance( MigrationManager.class );%0A            try %7B%0A                migrationManager.migrate();%0A            %7D catch (MigrationException e) %7B%0A                logger.error(%22Error in migration%22, e);%0A            %7D%0A        %7D%0A    %7D%0A%0A    protected abstract Injector getInjector();%0A%0A%0A//    protected Injector getInjector() %7B%0A//        return sharedInjector;%0A//    %7D%0A//%0A//    protected static void setInjector(Injector injector) %7B%0A//        AbstractTest.sharedInjector = injector;%0A//    %7D%0A%0A%0A    protected static int getNextAkkaPort() %7B%0A        int ret = nextPort.getAndIncrement();%0A        logger.info(%22Returning port %7B%7D%22, ret);%0A        return ret;%0A    %7D%0A%0A%0A    @BeforeClass%0A    public static void startCassandra() throws Exception %7B%0A        //EmbeddedCassandraServerHelper.startEmbeddedCassandra(%22/cassandra.yaml%22);%0A    %7D%0A%0A%0A%0A%7D%0A

Use one injector in tests and, at most, one Akka cluster per test class.