Search in sources :

Example 16 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldRespectCommonAnnotationsInStepDefs.

@Test
public void shouldRespectCommonAnnotationsInStepDefs() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(WithSpringAnnotations.class);
    factory.start();
    WithSpringAnnotations stepdef = factory.getInstance(WithSpringAnnotations.class);
    factory.stop();
    assertNotNull(stepdef);
    assertTrue(stepdef.isAutowired());
}
Also used : WithSpringAnnotations(cucumber.runtime.java.spring.contextconfig.WithSpringAnnotations) ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 17 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldFindStepDefsCreatedImplicitlyForAutowiring.

@Test
public void shouldFindStepDefsCreatedImplicitlyForAutowiring() {
    final ObjectFactory factory1 = new SpringFactory();
    factory1.addClass(WithSpringAnnotations.class);
    factory1.addClass(OneStepDef.class);
    factory1.addClass(ThirdStepDef.class);
    factory1.addClass(AutowiresThirdStepDef.class);
    factory1.start();
    final OneStepDef o1 = factory1.getInstance(OneStepDef.class);
    final ThirdStepDef o2 = factory1.getInstance(ThirdStepDef.class);
    factory1.stop();
    assertNotNull(o1.getThirdStepDef());
    assertNotNull(o2);
    assertSame(o1.getThirdStepDef(), o2);
}
Also used : OneStepDef(cucumber.runtime.java.spring.commonglue.OneStepDef) ObjectFactory(cucumber.api.java.ObjectFactory) ThirdStepDef(cucumber.runtime.java.spring.commonglue.ThirdStepDef) AutowiresThirdStepDef(cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef) Test(org.junit.Test)

Example 18 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldAllowClassesWithSameSpringAnnotations.

@Test
public void shouldAllowClassesWithSameSpringAnnotations() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(WithSpringAnnotations.class);
    factory.addClass(BellyStepdefs.class);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 19 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldRespectCustomPropertyPlaceholderConfigurer.

@Test
public void shouldRespectCustomPropertyPlaceholderConfigurer() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(WithSpringAnnotations.class);
    factory.start();
    WithSpringAnnotations stepdef = factory.getInstance(WithSpringAnnotations.class);
    factory.stop();
    assertEquals("property value", stepdef.getProperty());
}
Also used : WithSpringAnnotations(cucumber.runtime.java.spring.contextconfig.WithSpringAnnotations) ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 20 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class PicoFactoryTest method shouldDisposeOnStop.

@Test
public void shouldDisposeOnStop() {
    // Given
    ObjectFactory factory = new PicoFactory();
    factory.addClass(StepDefs.class);
    // When
    factory.start();
    StepDefs steps = factory.getInstance(StepDefs.class);
    // Then
    assertFalse(steps.getBelly().isDisposed());
    // When
    factory.stop();
    // Then
    assertTrue(steps.getBelly().isDisposed());
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Aggregations

ObjectFactory (cucumber.api.java.ObjectFactory)26 Test (org.junit.Test)24 BellyBean (cucumber.runtime.java.spring.beans.BellyBean)4 Backend (cucumber.runtime.Backend)2 CucumberException (cucumber.runtime.CucumberException)2 ResourceLoader (cucumber.runtime.io.ResourceLoader)2 JavaBackend (cucumber.runtime.java.JavaBackend)2 AutowiresPlatformTransactionManager (cucumber.runtime.java.spring.commonglue.AutowiresPlatformTransactionManager)2 AutowiresThirdStepDef (cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef)2 OneStepDef (cucumber.runtime.java.spring.commonglue.OneStepDef)2 BellyStepdefs (cucumber.runtime.java.spring.contextconfig.BellyStepdefs)2 WithSpringAnnotations (cucumber.runtime.java.spring.contextconfig.WithSpringAnnotations)2 OsgiClassFinder (cucumber.java.runtime.osgi.OsgiClassFinder)1 PaxExamObjectFactory (cucumber.java.runtime.osgi.PaxExamObjectFactory)1 ClassFinder (cucumber.runtime.ClassFinder)1 Glue (cucumber.runtime.Glue)1 NoInstancesException (cucumber.runtime.NoInstancesException)1 Reflections (cucumber.runtime.Reflections)1 Runtime (cucumber.runtime.Runtime)1 RuntimeOptions (cucumber.runtime.RuntimeOptions)1