Package com.foreach.across.core

Examples of com.foreach.across.core.AcrossContext


    AcrossApplicationContextHolder acrossApplicationContextHolder = mock( AcrossApplicationContextHolder.class );
    when( acrossApplicationContextHolder.getApplicationContext() ).thenReturn( applicationContext );
    when( acrossApplicationContextHolder.getBeanFactory() ).thenReturn( beanFactory );

    AcrossContext acrossContext = mock( AcrossContext.class );
    when( acrossContext.hasApplicationContext() ).thenReturn( true );
    when( acrossContext.getAcrossApplicationContextHolder() ).thenReturn( acrossApplicationContextHolder );

    module = mock( AcrossModule.class );
    contextConfig = mock( AcrossBootstrapConfig.class );

    moduleConfig = mock( ModuleBootstrapConfig.class );
View Full Code Here


*/
public class TestAcrossContextShutdown
{
  @Test
  public void withoutParentSingleModuleApplicationContextDestroyed() {
    AcrossContext context = boot();
    AcrossContextBeanRegistry registry = AcrossContextUtils.getBeanRegistry( context );

    assertEquals( "one", fetch( registry, "one" ) );
    assertEquals( "two", fetch( registry, "two" ) );

View Full Code Here

  @Test
  public void withParentSingleModuleApplicationContextDestroyed() {
    AcrossApplicationContext parent = new AcrossApplicationContext();
    parent.refresh();

    AcrossContext context = boot( parent );

    assertEquals( "one", fetch( parent, "one" ) );
    assertEquals( "two", fetch( parent, "two" ) );

    destroy( context, "two" );
View Full Code Here

    assertNull( fetch( parent, "one" ) );
  }

  @Test
  public void withoutParentRootApplicationContextDestroyed() {
    AcrossContext context = boot();
    AcrossContextBeanRegistry registry = AcrossContextUtils.getBeanRegistry( context );

    assertEquals( "one", fetch( registry, "one" ) );
    assertEquals( "two", fetch( registry, "two" ) );

    context.shutdown();

    assertNull( fetch( registry, "two" ) );
    assertNull( fetch( registry, "one" ) );
  }
View Full Code Here

  @Test
  public void withParentRootApplicationContextDestroyed() {
    AcrossApplicationContext parent = new AcrossApplicationContext();
    parent.refresh();

    AcrossContext context = boot( parent );

    assertEquals( "one", fetch( parent, "one" ) );
    assertEquals( "two", fetch( parent, "two" ) );

    context.shutdown();

    assertNull( fetch( parent, "two" ) );
    assertNull( fetch( parent, "one" ) );
  }
View Full Code Here

  private AcrossContext boot() {
    return boot( null );
  }

  private AcrossContext boot( ApplicationContext parent ) {
    AcrossContext context = new AcrossContext();

    if ( parent != null ) {
      context.setParentApplicationContext( parent );
    }

    context.addModule( new TestModule( "one" ) );
    context.addModule( new TestModule( "two" ) );

    context.bootstrap();

    return context;
  }
View Full Code Here

      assertEquals( Integer.valueOf( resultsPerLock ), entry.getValue() );
    }
  }

  private AcrossContext createContext() {
    AcrossContext context = new AcrossContext();
    context.setDataSource( uniqueDataSource() );

    context.bootstrap();

    return context;
  }
View Full Code Here

    public Integer call() throws Exception {
      if ( startDelay > 0 ) {
        Thread.sleep( startDelay );
      }

      AcrossContext context = createContext();
      DistributedLockRepository distributedLockRepository = AcrossContextUtils.getBeanRegistry( context )
                                                                              .getBeanOfType(
                                                                                  DistributedLockRepository.class );

      ExecutorService fixedThreadPool = Executors.newFixedThreadPool( 50 );

      List<Executor> executors = new ArrayList<>( LOCKS_PER_BATCH * EXECUTORS_PER_LOCK );

      for ( int i = 0; i < LOCKS_PER_BATCH; i++ ) {
        DistributedLock lock = distributedLockRepository.getLock( "batch-lock-" + i );

        for ( int j = 0; j < EXECUTORS_PER_LOCK; j++ ) {
          executors.add( new Executor( lock, 10 ) );
        }
      }

      for ( Executor executor : executors ) {
        fixedThreadPool.submit( executor );
      }

      fixedThreadPool.shutdown();
      fixedThreadPool.awaitTermination( 3, TimeUnit.MINUTES );

      int totalSucceeded = 0;

      for ( Executor executor : executors ) {
        if ( executor.isFinished() ) {
          totalSucceeded++;
        }
      }

      context.destroy();

      return totalSucceeded;
    }
View Full Code Here

    databaseReset();

    Map<String, AcrossContextConfigurer> configurerMap =
        applicationContext.getBeansOfType( AcrossContextConfigurer.class );

    AcrossContext context = new AcrossContext( applicationContext );
    context.setInstallerAction( InstallerAction.EXECUTE );
    context.setDataSource( dataSource() );

    for ( AcrossContextConfigurer configurer : configurerMap.values() ) {
      configurer.configure( context );
    }
View Full Code Here

    @Autowired
    public AcrossContext acrossContext( ConfigurableApplicationContext applicationContext ) throws Exception {
      ScannedBeanModule1.CONSTRUCTION_COUNTER.set( 0 );
      ScannedBeanModule2.CONSTRUCTION_COUNTER.set( 0 );

      AcrossContext context = new AcrossContext( applicationContext );
      context.setDataSource( acrossDataSource() );
      context.setInstallerAction( InstallerAction.EXECUTE );
      context.addApplicationContextConfigurer( new AnnotatedClassConfigurer( CustomPropertyConfig.class ),
                                               ConfigurerScope.CONTEXT_AND_MODULES );

      context.addModule( testModule1() );
      context.addModule( testModule2() );

      return context;
    }
View Full Code Here

TOP

Related Classes of com.foreach.across.core.AcrossContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.