Search in sources :

Example 6 with ObjectFactory

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

the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration.

@Test
public void shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(DirtiesContextBellyMetaStepDefs.class);
    // Scenario 1
    factory.start();
    final BellyBean o1 = factory.getInstance(DirtiesContextBellyMetaStepDefs.class).getBellyBean();
    factory.stop();
    // Scenario 2
    factory.start();
    final BellyBean o2 = factory.getInstance(DirtiesContextBellyMetaStepDefs.class).getBellyBean();
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertNotSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) DirtiesContextBellyMetaStepDefs(cucumber.runtime.java.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefs) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) Test(org.junit.Test)

Example 7 with ObjectFactory

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

the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefs.

@Test
public void shouldRespectDirtiesContextAnnotationsInStepDefs() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(DirtiesContextBellyStepDefs.class);
    // Scenario 1
    factory.start();
    final BellyBean o1 = factory.getInstance(DirtiesContextBellyStepDefs.class).getBellyBean();
    factory.stop();
    // Scenario 2
    factory.start();
    final BellyBean o2 = factory.getInstance(DirtiesContextBellyStepDefs.class).getBellyBean();
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertNotSame(o1, o2);
}
Also used : DirtiesContextBellyStepDefs(cucumber.runtime.java.spring.dirtiescontextconfig.DirtiesContextBellyStepDefs) ObjectFactory(cucumber.api.java.ObjectFactory) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) Test(org.junit.Test)

Example 8 with ObjectFactory

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

the class SpringFactoryTest method shouldGiveUsNewInstancesOfGlueScopeClassesForEachScenario.

@Test
public void shouldGiveUsNewInstancesOfGlueScopeClassesForEachScenario() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(BellyStepdefs.class);
    factory.addClass(AutowiresPlatformTransactionManager.class);
    // Scenario 1
    factory.start();
    final PlatformTransactionManager o1 = factory.getInstance(AutowiresPlatformTransactionManager.class).getTransactionManager();
    factory.stop();
    // Scenario 2
    factory.start();
    final PlatformTransactionManager o2 = factory.getInstance(AutowiresPlatformTransactionManager.class).getTransactionManager();
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertNotSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) AutowiresPlatformTransactionManager(cucumber.runtime.java.spring.commonglue.AutowiresPlatformTransactionManager) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) AutowiresPlatformTransactionManager(cucumber.runtime.java.spring.commonglue.AutowiresPlatformTransactionManager) Test(org.junit.Test)

Example 9 with ObjectFactory

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

the class SpringFactoryTest method shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration.

@Test
public void shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration() {
    // Feature 1
    final ObjectFactory factory1 = new SpringFactory();
    factory1.addClass(BellyMetaStepdefs.class);
    factory1.start();
    final BellyBean o1 = factory1.getInstance(BellyMetaStepdefs.class).getBellyBean();
    factory1.stop();
    // Feature 2
    final ObjectFactory factory2 = new SpringFactory();
    factory2.addClass(BellyMetaStepdefs.class);
    factory2.start();
    final BellyBean o2 = factory2.getInstance(BellyMetaStepdefs.class).getBellyBean();
    factory2.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) BellyMetaStepdefs(cucumber.runtime.java.spring.metaconfig.general.BellyMetaStepdefs) Test(org.junit.Test)

Example 10 with ObjectFactory

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

the class SpringFactoryTest method shouldRespectContextHierarchyInStepDefs.

@Test
public void shouldRespectContextHierarchyInStepDefs() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(WithContextHierarchyAnnotation.class);
    factory.start();
    WithContextHierarchyAnnotation stepdef = factory.getInstance(WithContextHierarchyAnnotation.class);
    factory.stop();
    assertNotNull(stepdef);
    assertTrue(stepdef.isAutowired());
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) WithContextHierarchyAnnotation(cucumber.runtime.java.spring.contexthierarchyconfig.WithContextHierarchyAnnotation) 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