Examples of AnnotationConfigApplicationContext


Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

*/
public class DefaultYarnContainerTests {

  @Test
  public void testContainerVoidBean() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean1Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.COMPLETED));
    assertThat(stateWrapper.exit, instanceOf(Integer.class));
    assertThat((Integer)stateWrapper.exit, is(0));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    context.stop();
  }

  @Test
  public void testContainerBooleanBean() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean2Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.COMPLETED));
    assertThat(stateWrapper.exit, instanceOf(Boolean.class));
    assertThat((Boolean)stateWrapper.exit, is(true));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    context.stop();
  }

  @Test
  public void testContainerIntRetBean() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean3Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.COMPLETED));
    assertThat(stateWrapper.exit, instanceOf(Integer.class));
    assertThat((Integer)stateWrapper.exit, is(10));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    context.stop();
  }

  @Test
  public void testContainerBeanThrowsException() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean4Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.FAILED));
    assertThat(stateWrapper.exit, instanceOf(Exception.class));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    context.stop();
  }

  @Test
  public void testContainerBeanThrowsExceptionTwoAnnotations() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean5Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.FAILED));
    assertThat(stateWrapper.exit, instanceOf(Exception.class));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    context.stop();
  }

  @Test
  public void testContainerStringBean() {
    @SuppressWarnings("resource")
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, TestBean6Config.class);
    DefaultYarnContainer container = context.getBean(DefaultYarnContainer.class);
    final StateWrapper stateWrapper = new StateWrapper();

    container.addContainerStateListener(new ContainerStateListener() {
      @Override
      public void state(ContainerState state, Object exit) {
        stateWrapper.state = state;
        stateWrapper.exit = exit;
      }
    });

    container.run();
    assertThat(stateWrapper.state, is(ContainerState.COMPLETED));
    assertThat(stateWrapper.exit, instanceOf(String.class));
    assertThat((String)stateWrapper.exit, is("UNKNOWN"));

    context.stop();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class ActionTests extends AbstractStateMachineTests {

  @SuppressWarnings({ "unchecked" })
  @Test
  public void testTransitionActions() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    EnumStateMachine<TestStates,TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
    TestCountAction testAction1 = ctx.getBean("testAction1", TestCountAction.class);
    TestCountAction testAction2 = ctx.getBean("testAction2", TestCountAction.class);
    TestCountAction testAction3 = ctx.getBean("testAction3", TestCountAction.class);
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E2).build());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E3).build());
    assertThat(testAction1.count, is(1));
    assertThat(testAction2.count, is(1));
    assertThat(testAction3.count, is(1));
    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class StateMachineTests extends AbstractStateMachineTests {

  @Test
  public void test1() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    @SuppressWarnings("unchecked")
    EnumStateMachine<TestStates,TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
    assertThat(machine, notNullValue());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("foo", "jee1").build());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E2).setHeader("foo", "jee2").build());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E4).setHeader("foo", "jee2").build());
    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

  private static final String WS_URI = "ws://localhost:8080/spring-websocket-test/echo";


  public static void main(String[] args) throws IOException {
    try{
      AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(ClientConfig.class);
      System.out.println("\n\n\nWhen ready, press any key to exit\n\n\n");
      System.in.read();
      cxt.close();
    }
    catch (Throwable t) {
      t.printStackTrace();
    }
    finally {
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

  private static final String WS_URI = "ws://localhost:8080/spring-websocket-test/echo";


  public static void main(String[] args) throws IOException {
    try{
      AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(ClientConfig.class);
      System.out.println("\n\n\nWhen ready, press any key to exit\n\n\n");
      System.in.read();
      cxt.close();
    }
    catch (Throwable t) {
      t.printStackTrace();
    }
    finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.