Package org.springframework.context

Examples of org.springframework.context.ApplicationContext


  @Test
  public void shouldCreateOnlyOneContainerForMultipleBuildInvocations() {
    SpringAnnotationBuilder builderAnnotated = new SpringAnnotationBuilder(
        AnnotatedUsingStepsAndSpring.class);
    builderAnnotated.buildConfiguration();
    ApplicationContext applicationContext = builderAnnotated
        .applicationContext();
    builderAnnotated.buildConfiguration();
    assertThat(builderAnnotated.applicationContext(),
        sameInstance(applicationContext));
  }
View Full Code Here


public class SpringStepsFactoryBehaviour {

  @Test
  public void stepsCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext("org/jbehave/core/steps/spring/steps.xml");
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
View Full Code Here

  }

  @Test
  public void annotationStepsCanBeCreated() throws Exception {
    // Given
    ApplicationContext context = createApplicationContext(StepsAnnotationConfiguration.class
        .getName());
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
View Full Code Here

  }

  @Test
  public void stepsWithDependenciesCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext("org/jbehave/core/steps/spring/steps-with-dependency.xml");
    // When
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
View Full Code Here

  }

  @Test
  public void annotationStepsWithDependenciesCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext(StepsWithDependencyAnnotationConfiguration.class
        .getName());
    // When
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    List<CandidateSteps> steps = factory.createCandidateSteps();
View Full Code Here

  }

  @Test(expected = BeanDefinitionStoreException.class)
  public void stepsWithMissingDependenciesCannotBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext("org/jbehave/core/steps/spring/steps-with-missing-depedency.xml");
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    // When
    factory.createCandidateSteps();
    // Then ... expected exception is thrown
View Full Code Here

  }

  @Test
  public void beansWithUndefinedTypeOrCannotBeCreatedWillBeIgnored() {
    // Given
    ApplicationContext context = mock(ApplicationContext.class);
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    // When
    when(context.getBeanDefinitionNames()).thenReturn(
        new String[] { "fooSteps", "undefined", "blowUp" });
    doAnswer(new Answer<Class<FooSteps>>() {

      public Class<FooSteps> answer(InvocationOnMock invocation)
          throws Throwable {

        return FooSteps.class;
      }
    }).when(context).getType("fooSteps");
    when(context.getType("undefined")).thenReturn(null);
    doAnswer(new Answer<Class<BlowUp>>() {

      public Class<BlowUp> answer(InvocationOnMock invocation)
          throws Throwable {

        return BlowUp.class;
      }
    }).when(context).getType("blowUp");
    when(context.getBean("fooSteps")).thenReturn(new FooSteps());
    when(context.getBean("blowUp")).thenThrow(new RuntimeException("Bum!"));
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    // Then
    assertThat(candidateSteps.size(), equalTo(1));
    assertThat(firstStepsInstance(candidateSteps),
        instanceOf(FooSteps.class));
View Full Code Here

public class SpringStepsFactoryAOPBehaviour {

  @Test
  public void aopEnvelopedStepsCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext(StepsWithAOPAnnotationConfiguration.class
        .getName());
    SpringStepsFactory factory = new SpringStepsFactory(
        new MostUsefulConfiguration(), context);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
View Full Code Here

    }

    @Override
    public InjectableStepsFactory stepsFactory() {
        String path = "${package}".replaceAll("\\.", "/");
        ApplicationContext context = new SpringApplicationContextFactory(path+"/my_steps.xml").createApplicationContext();
        return new SpringStepsFactory(configuration(), context);
    }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/http-outbound-config.xml");
    RequestGateway requestGateway = context.getBean("requestGateway", RequestGateway.class);
    String reply = requestGateway.echo("Hello")
    logger.info("Replied with: " + reply);
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.ApplicationContext

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.