You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/07/08 20:28:01 UTC
[isis] branch v2 updated: ISIS-2123 drop deprecated classes from
/extensions/specsupport
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new c651fcf ISIS-2123 drop deprecated classes from /extensions/specsupport
c651fcf is described below
commit c651fcff50d22146b57fcd935846dfbd09381eea
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Jul 8 22:27:53 2019 +0200
ISIS-2123 drop deprecated classes from /extensions/specsupport
- bumping cucumber version from 1.2.4 -> 4.2.6 (not the latest yet)
- handle cucumber version in /extensions/specsupport/pom.xml (no longer
in core)
- add cucumber-spring artifact
however, documentation seems sparse and I've not figured out yet hoe to
properly integrate cucumber with spring boot
---
core/pom.xml | 14 -
...nAppAppManifest.java => SimpleAppManifest.java} | 2 +-
.../bdd/specglue/CatalogOfFixturesGlue.java | 4 +-
.../application/bdd/specs/RunIntegBddSpecs.java | 3 +-
...estAbstract.java => SpringIntegrationTest.java} | 11 +-
.../integtests/mml/MetaModelService_IntegTest.java | 33 +-
.../integtests/smoke/Smoke_IntegTest.java | 143 +++---
.../src/test/resources/cucumber.properties | 2 +-
.../modules/simple/specglue/SimpleObjectsGlue.java | 32 +-
.../main/java/domainapp/application/SimpleApp.java | 4 +-
extensions/specsupport/pom.xml | 39 +-
.../HeadlessWithBootstrappingAbstract.java | 133 ------
.../apache/isis/runtime/headless/IsisSystem.java | 201 --------
.../runtime/headless/IsisSystemBootstrapper.java | 193 --------
.../auth/AuthenticationRequestNameOnly.java | 29 --
.../runtime/headless/logging/LeveledLogger.java | 58 ---
.../isis/runtime/headless/logging/LogConfig.java | 80 ----
.../isis/runtime/headless/logging/LogStream.java | 74 ---
.../specsupport/ObjectFactoryForIntegration.java | 79 ++++
.../scenarios/DomainServiceProvider.java | 44 --
.../scenarios/DomainServiceProviderMockery.java | 143 ------
.../isis/specsupport/scenarios/InMemoryDB.java | 230 ---------
.../specsupport/scenarios/ScenarioExecution.java | 526 ---------------------
.../scenarios/ScenarioExecutionForUnit.java | 78 ---
.../scenarios/ScenarioExecutionScope.java | 66 ---
.../isis/specsupport/specs/CukeGlueAbstract.java | 319 +------------
.../isis/specsupport/specs/CukeGlueAbstract2.java | 32 --
.../specs/CukeGlueBootstrappingAbstract.java | 58 ---
.../isis/specsupport/specs/CukeSpecsAbstract.java | 42 --
.../java/org/apache/isis/specsupport/specs/V.java | 12 +-
30 files changed, 244 insertions(+), 2440 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index d5dab77..9cb4daf 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -175,7 +175,6 @@
<jmock.version>2.11.0</jmock.version>
<easymock.version>2.5.2</easymock.version>
- <cucumber.version>1.2.4</cucumber.version>
<validation-api.version>1.1.0.Final</validation-api.version>
<transaction-api.version>1.2</transaction-api.version>
@@ -2038,19 +2037,6 @@
<version>${assertj.version}</version>
</dependency>
-
- <!-- BDD testing -->
- <dependency>
- <groupId>info.cukes</groupId>
- <artifactId>cucumber-java</artifactId>
- <version>${cucumber.version}</version>
- </dependency>
- <dependency>
- <groupId>info.cukes</groupId>
- <artifactId>cucumber-junit</artifactId>
- <version>${cucumber.version}</version>
- </dependency>
-
<!-- Testing libraries (scope=test) -->
<dependency>
<groupId>org.easymock</groupId>
diff --git a/examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/DomainAppAppManifest.java b/examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/SimpleAppManifest.java
similarity index 98%
rename from examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/DomainAppAppManifest.java
rename to examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/SimpleAppManifest.java
index 5159aab..3c2f64a 100644
--- a/examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/DomainAppAppManifest.java
+++ b/examples/apps/simpleapp/application/src/main/java/domainapp/application/manifest/SimpleAppManifest.java
@@ -58,7 +58,7 @@ import domainapp.modules.simple.SimpleModule;
includeFilters= {
@Filter(type = FilterType.CUSTOM, classes= {IsisBeanScanInterceptorForSpring.class})
})
-public class DomainAppAppManifest {
+public class SimpleAppManifest {
@Bean @Singleton
public WebAppConfigBean webAppConfigBean() {
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/CatalogOfFixturesGlue.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/CatalogOfFixturesGlue.java
index 6eb8f35..a1e3c79 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/CatalogOfFixturesGlue.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specglue/CatalogOfFixturesGlue.java
@@ -16,12 +16,12 @@
*/
package domainapp.application.bdd.specglue;
-import org.apache.isis.specsupport.specs.CukeGlueAbstract2;
+import org.apache.isis.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.Before;
import domainapp.application.fixture.scenarios.DomainAppDemo;
-public class CatalogOfFixturesGlue extends CukeGlueAbstract2 {
+public class CatalogOfFixturesGlue extends CukeGlueAbstract {
@Before(value={"@DomainAppDemo"}, order=20000)
public void runDomainAppDemo() {
fixtureScripts.runFixtureScript(new DomainAppDemo(), null);
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
index 77e5a5e..2999b71 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/bdd/specs/RunIntegBddSpecs.java
@@ -27,7 +27,8 @@ import cucumber.api.junit.Cucumber;
*/
@RunWith(Cucumber.class)
@CucumberOptions(
- format = {
+
+ plugin = {
"html:target/cucumber-html-report"
,"json:target/cucumber.json"
},
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/DomainAppIntegTestAbstract.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/SpringIntegrationTest.java
similarity index 75%
rename from examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/DomainAppIntegTestAbstract.java
rename to examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/SpringIntegrationTest.java
index 2de6a5c..b55ec6c 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/DomainAppIntegTestAbstract.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/SpringIntegrationTest.java
@@ -18,13 +18,12 @@
*/
package domainapp.application.integtests;
-//import org.apache.isis.integtestsupport.IntegrationTestAbstract3;
+import org.springframework.boot.test.context.SpringBootTest;
-public abstract class DomainAppIntegTestAbstract /*extends IntegrationTestAbstract3*/ {
+import domainapp.application.manifest.SimpleAppManifest;
+
+@SpringBootTest(classes = SimpleAppManifest.class)
+public class SpringIntegrationTest {
- //FIXME[2112] needs migration
-// public DomainAppIntegTestAbstract() {
-// super(new DomainAppApplicationModule());
-// }
}
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
index c29c603..ff780d6 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
@@ -18,37 +18,36 @@
*/
package domainapp.application.integtests.mml;
+import static org.approvaltests.Approvals.getReporter;
+import static org.approvaltests.Approvals.verify;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assume.assumeThat;
+
import java.io.File;
import java.util.List;
import javax.inject.Inject;
+import org.apache.isis.applib.services.jaxb.JaxbService;
+import org.apache.isis.applib.services.metamodel.MetaModelService;
+import org.apache.isis.schema.metamodel.v1.DomainClassDto;
+import org.apache.isis.schema.metamodel.v1.MetamodelDto;
import org.approvaltests.namer.StackTraceNamer;
import org.approvaltests.reporters.DiffReporter;
import org.approvaltests.reporters.QuietReporter;
import org.approvaltests.reporters.UseReporter;
import org.approvaltests.writers.ApprovalTextWriter;
import org.junit.Test;
+import org.springframework.boot.test.context.SpringBootTest;
-import org.apache.isis.applib.services.jaxb.JaxbService;
-import org.apache.isis.applib.services.metamodel.MetaModelService;
-import org.apache.isis.schema.metamodel.v1.DomainClassDto;
-import org.apache.isis.schema.metamodel.v1.MetamodelDto;
-
-import domainapp.application.integtests.DomainAppIntegTestAbstract;
-import static org.approvaltests.Approvals.getReporter;
-import static org.approvaltests.Approvals.verify;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assume.assumeThat;
-
-public class MetaModelService_IntegTest extends DomainAppIntegTestAbstract {
+import domainapp.application.manifest.SimpleAppManifest;
- @Inject
- MetaModelService metaModelService;
- @Inject
- JaxbService jaxbService;
+@SpringBootTest(classes = SimpleAppManifest.class)
+public class MetaModelService_IntegTest {
+ @Inject MetaModelService metaModelService;
+ @Inject JaxbService jaxbService;
//
// learn...
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/smoke/Smoke_IntegTest.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/smoke/Smoke_IntegTest.java
index a27ed53..5ffe6ff 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/smoke/Smoke_IntegTest.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/smoke/Smoke_IntegTest.java
@@ -18,81 +18,90 @@
*/
package domainapp.application.integtests.smoke;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.List;
import javax.inject.Inject;
-import org.junit.Test;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
+import org.apache.isis.applib.services.xactn.TransactionService;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
-import domainapp.application.integtests.DomainAppIntegTestAbstract;
+import domainapp.application.manifest.SimpleAppManifest;
import domainapp.modules.simple.dom.impl.SimpleObject;
import domainapp.modules.simple.dom.impl.SimpleObjects;
-import static org.assertj.core.api.Assertions.assertThat;
-public class Smoke_IntegTest extends DomainAppIntegTestAbstract {
-
- //FIXME[2112] needs migration
-// @Inject
-// SimpleObjects menu;
-//
-// @Test
-// public void create() {
-//
-// // when
-// List<SimpleObject> all = wrap(menu).listAll();
-//
-// // then
-// assertThat(all).isEmpty();
-//
-//
-//
-// // when
-// final SimpleObject fred = wrap(menu).create("Fred");
-// transactionService.flushTransaction();
-//
-// // then
-// all = wrap(menu).listAll();
-// assertThat(all).hasSize(1);
-// assertThat(all).contains(fred);
-//
-//
-//
-// // when
-// final SimpleObject bill = wrap(menu).create("Bill");
-// transactionService.flushTransaction();
-//
-// // then
-// all = wrap(menu).listAll();
-// assertThat(all).hasSize(2);
-// assertThat(all).contains(fred, bill);
-//
-//
-//
-// // when
-// wrap(fred).updateName("Freddy");
-// transactionService.flushTransaction();
-//
-// // then
-// assertThat(wrap(fred).getName()).isEqualTo("Freddy");
-//
-//
-// // when
-// wrap(fred).setNotes("These are some notes");
-// transactionService.flushTransaction();
-//
-// // then
-// assertThat(wrap(fred).getNotes()).isEqualTo("These are some notes");
-//
-//
-// // when
-// wrap(fred).delete();
-// transactionService.flushTransaction();
-//
-//
-// all = wrap(menu).listAll();
-// assertThat(all).hasSize(1);
-//
-// }
+@SpringBootTest(classes = SimpleAppManifest.class)
+class Smoke_IntegTest {
+
+ @Inject SimpleObjects menu;
+ @Inject TransactionService transactionService;
+ @Inject WrapperFactory wrapperFactory;
+
+ @Test
+ void create() {
+
+ // when
+ List<SimpleObject> all = wrap(menu).listAll();
+
+ // then
+ assertThat(all).isEmpty();
+
+
+
+ // when
+ final SimpleObject fred = wrap(menu).create("Fred");
+ transactionService.flushTransaction();
+
+ // then
+ all = wrap(menu).listAll();
+ assertThat(all).hasSize(1);
+ assertThat(all).contains(fred);
+
+
+
+ // when
+ final SimpleObject bill = wrap(menu).create("Bill");
+ transactionService.flushTransaction();
+
+ // then
+ all = wrap(menu).listAll();
+ assertThat(all).hasSize(2);
+ assertThat(all).contains(fred, bill);
+
+
+
+ // when
+ wrap(fred).updateName("Freddy");
+ transactionService.flushTransaction();
+
+ // then
+ assertThat(wrap(fred).getName()).isEqualTo("Freddy");
+
+
+ // when
+ wrap(fred).setNotes("These are some notes");
+ transactionService.flushTransaction();
+
+ // then
+ assertThat(wrap(fred).getNotes()).isEqualTo("These are some notes");
+
+
+ // when
+ wrap(fred).delete();
+ transactionService.flushTransaction();
+
+
+ all = wrap(menu).listAll();
+ assertThat(all).hasSize(1);
+
+ }
+
+ private <T> T wrap(T domainObject) {
+ return wrapperFactory.wrap(domainObject);
+ }
}
diff --git a/examples/apps/simpleapp/application/src/test/resources/cucumber.properties b/examples/apps/simpleapp/application/src/test/resources/cucumber.properties
index 683c38a..b579b01 100644
--- a/examples/apps/simpleapp/application/src/test/resources/cucumber.properties
+++ b/examples/apps/simpleapp/application/src/test/resources/cucumber.properties
@@ -1 +1 @@
-cucumber.api.java.ObjectFactory=org.apache.isis.core.integtestsupport.scenarios.ObjectFactoryForIntegration
\ No newline at end of file
+cucumber.api.java.ObjectFactory=org.apache.isis.specsupport.ObjectFactoryForIntegration
\ No newline at end of file
diff --git a/examples/apps/simpleapp/module-simple/src/test/java/domainapp/modules/simple/specglue/SimpleObjectsGlue.java b/examples/apps/simpleapp/module-simple/src/test/java/domainapp/modules/simple/specglue/SimpleObjectsGlue.java
index dfc4e0a..3b374e4 100644
--- a/examples/apps/simpleapp/module-simple/src/test/java/domainapp/modules/simple/specglue/SimpleObjectsGlue.java
+++ b/examples/apps/simpleapp/module-simple/src/test/java/domainapp/modules/simple/specglue/SimpleObjectsGlue.java
@@ -1,18 +1,20 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package domainapp.modules.simple.specglue;
@@ -21,7 +23,7 @@ import java.util.UUID;
import javax.inject.Inject;
-import org.apache.isis.specsupport.specs.CukeGlueAbstract2;
+import org.apache.isis.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
@@ -30,7 +32,7 @@ import domainapp.modules.simple.dom.impl.SimpleObjects;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public class SimpleObjectsGlue extends CukeGlueAbstract2 {
+public class SimpleObjectsGlue extends CukeGlueAbstract {
@Given("^there are.* (\\d+) simple objects$")
public void there_are_N_simple_objects(int n) throws Throwable {
diff --git a/examples/apps/simpleapp/webapp/src/main/java/domainapp/application/SimpleApp.java b/examples/apps/simpleapp/webapp/src/main/java/domainapp/application/SimpleApp.java
index 5e4eecf..6cfdbc0 100644
--- a/examples/apps/simpleapp/webapp/src/main/java/domainapp/application/SimpleApp.java
+++ b/examples/apps/simpleapp/webapp/src/main/java/domainapp/application/SimpleApp.java
@@ -27,14 +27,14 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
-import domainapp.application.manifest.DomainAppAppManifest;
+import domainapp.application.manifest.SimpleAppManifest;
/**
* Bootstrap the application.
*/
@SpringBootApplication
@Import({
- DomainAppAppManifest.class,
+ SimpleAppManifest.class,
IsisBootWebWicket.class,
IsisBootSecurityShiro.class
})
diff --git a/extensions/specsupport/pom.xml b/extensions/specsupport/pom.xml
index c7f504b..807369f 100644
--- a/extensions/specsupport/pom.xml
+++ b/extensions/specsupport/pom.xml
@@ -28,6 +28,8 @@
<properties>
<jar-plugin.automaticModuleName>org.apache.isis.extensions.specsupport</jar-plugin.automaticModuleName>
<git-plugin.propertiesDir>org/apache/isis/extensions/specsupport</git-plugin.propertiesDir>
+
+ <cucumber.version>4.2.6</cucumber.version>
</properties>
<dependencies>
@@ -78,20 +80,29 @@
<artifactId>jmock</artifactId>
</dependency>
- <dependency>
- <groupId>info.cukes</groupId>
- <artifactId>cucumber-java</artifactId>
- </dependency>
- <dependency>
- <groupId>info.cukes</groupId>
- <artifactId>cucumber-junit</artifactId>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <!-- CUCUMBER -->
+
+ <dependency>
+ <groupId>io.cucumber</groupId>
+ <artifactId>cucumber-java</artifactId>
+ <version>${cucumber.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.cucumber</groupId>
+ <artifactId>cucumber-spring</artifactId>
+ <version>${cucumber.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.cucumber</groupId>
+ <artifactId>cucumber-junit</artifactId>
+ <version>${cucumber.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/HeadlessWithBootstrappingAbstract.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/HeadlessWithBootstrappingAbstract.java
deleted file mode 100644
index 34fac21..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/HeadlessWithBootstrappingAbstract.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.runtime.headless;
-
-import java.io.PrintStream;
-
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.services.xactn.TransactionService;
-import org.apache.isis.commons.internal.plugins.environment.IsisSystemEnvironment;
-import org.apache.isis.config.IsisConfiguration;
-import org.apache.isis.logging.IsisLoggingConfigurer;
-import org.apache.isis.runtime.headless.logging.LeveledLogger;
-import org.apache.isis.runtime.headless.logging.LogConfig;
-import org.apache.isis.runtime.headless.logging.LogStream;
-import org.apache.logging.log4j.Level;
-
-import lombok.val;
-import lombok.extern.log4j.Log4j2;
-
-/**
- * Provides headless access to the system, first bootstrapping the system if required.
- *
- * <p>
- * This acts as a common superclass from which framework-provided adapter classes for integration tests
- * (<tt>IntegrationTestAbstract3</tt>) and for BDD spec glue (<tt>CukeGlueIntegrationScopeAbstract</tt> inherit,
- * to bootstrap the system with a given module for headless access.
- * </p>
- */
-@Log4j2
-public abstract class HeadlessWithBootstrappingAbstract extends HeadlessAbstract {
-
- private final LogConfig logConfig;
- protected static PrintStream logPrintStream(Level level) {
- return LogStream.logPrintStream(log, level);
- }
-
- private final LeveledLogger logger;
-
- private final static ThreadLocal<Boolean> setupLogging = new ThreadLocal<Boolean>() {{
- set(false);
- }};
-
-
- private final IsisSystemBootstrapper isisSystemBootstrapper;
-
- protected HeadlessWithBootstrappingAbstract(final LogConfig logConfig, IsisConfiguration config) {
-
- IsisSystemEnvironment.setUnitTesting(true);
-
- this.logConfig = logConfig;
- this.logger = new LeveledLogger(log, logConfig.getTestLoggingLevel());
-
- final boolean firstTime = !setupLogging.get();
- if(firstTime) {
- val loggingConfigurer = new IsisLoggingConfigurer(Level.INFO);
- loggingConfigurer.configureLoggingWithFile(logConfig.getLoggingPropertyFile(), new String[0]);
- setupLogging.set(true);
- }
-
- final String integTestModuleFqcn = System.getProperty("isis.integTest.module");
- log.info("isis.integTest.module = {}", integTestModuleFqcn);
- String moduleFqcn = integTestModuleFqcn;
-
- if(moduleFqcn == null) {
- final String headlessModuleFqcn = System.getProperty("isis.headless.module");
- log.info("isis.headless.module = {}", headlessModuleFqcn);
- moduleFqcn = headlessModuleFqcn;
- }
-
- this.isisSystemBootstrapper =
- IsisSystemBootstrapper.of(logConfig, config);
- }
-
-
- private org.joda.time.LocalDate timeBeforeTest;
-
- protected void bootstrapAndSetupIfRequired() {
-
- System.setProperty("isis.headless", "true");
- System.setProperty("isis.integTest", "true");
- System.setProperty("isis.bddSpec", "true");
-
- isisSystemBootstrapper.bootstrapIfRequired();
- isisSystemBootstrapper.injectServicesInto(this);
- fixtureScripts.setFixtureTracing(logConfig.getFixtureTracing());
-
- beginTransaction();
-
- isisSystemBootstrapper.setupModuleRefData();
-
- timeBeforeTest = Clock.getTimeAsLocalDate();
- }
-
- private void beginTransaction() {
- IsisSystem.get().getService(HeadlessTransactionSupport.class).beginTransaction();
- }
-
- protected void tearDownAllModules() {
-
- final boolean testHealthy = transactionService != null;
- if(!testHealthy) {
- // avoid throwing an NPE here if something unexpected has occurred...
- return;
- }
-
- transactionService.nextTransaction(TransactionService.Policy.ALWAYS);
-
- isisSystemBootstrapper.tearDownAllModules();
-
- // reinstate clock
- setFixtureClockDate(timeBeforeTest);
- }
-
- protected void log(final String message) {
- logger.log(message);
- }
-}
\ No newline at end of file
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystem.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystem.java
deleted file mode 100644
index 866dc9f..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystem.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.runtime.headless;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.apache.isis.commons.internal.base._NullSafe;
-import org.apache.isis.config.IsisConfiguration;
-import org.apache.isis.config.internal._Config;
-import org.apache.isis.extensions.fixtures.legacy.FixtureClock;
-import org.apache.isis.runtime.headless.auth.AuthenticationRequestNameOnly;
-import org.apache.isis.runtime.system.context.IsisContext;
-import org.apache.isis.runtime.system.session.IsisSessionFactory;
-import org.apache.isis.security.authentication.AuthenticationRequest;
-import org.apache.isis.security.authentication.AuthenticationSession;
-import org.apache.isis.security.authentication.manager.AuthenticationManager;
-
-import lombok.val;
-
-
-/**
- * Wraps a plain {@link IsisSessionFactoryBuilder}.
- *
- * <p>
- * This is a simplification of <tt>IsisSystemForTest</tt>, removing dependencies on junit and specsupport.
- * </p>
- */
-public final class IsisSystem {
-
- // -- getElseNull, get, set
-
- protected static ThreadLocal<IsisSystem> ISFT = new ThreadLocal<>();
-
- public static IsisSystem getElseNull() {
- return ISFT.get();
- }
-
- public static IsisSystem get() {
- final IsisSystem isft = ISFT.get();
- if(isft == null) {
- throw new IllegalStateException("No IsisSystem available on thread; call #set(IsisSystem) first");
- }
-
- return isft;
- }
-
- public static void set(IsisSystem isft) {
- ISFT.set(isft);
- }
-
-
- public static IsisSystem ofConfiguration(IsisConfiguration isisConfiguration) {
-
- AuthenticationRequest authenticationRequest = new AuthenticationRequestNameOnly("tester");
-
- return new IsisSystem(authenticationRequest);
- }
-
- // -- constructor, fields
-
- protected final AuthenticationRequest authenticationRequestIfAny;
- protected AuthenticationSession authenticationSession;
-
-
- private IsisSystem(final AuthenticationRequest authenticationRequestIfAny) {
- this.authenticationRequestIfAny = authenticationRequestIfAny;
- }
-
- // -- setup (also componentProvider)
-
- IsisSystem setUpSystem() throws RuntimeException {
- try {
- initIfRequiredThenOpenSession();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return this;
- }
-
- protected void initIfRequiredThenOpenSession() throws Exception {
-
- // exit as quickly as possible for this case...
- {
- val metaModelDeficiencies = IsisContext.getMetaModelDeficienciesIfAny();
-
- if(metaModelDeficiencies != null) {
- final Set<String> validationErrors = metaModelDeficiencies.getValidationErrors();
- final String validationMsg = _NullSafe.stream(validationErrors)
- .collect(Collectors.joining("\n"));
- throw new AssertionError(validationMsg);
- }
- }
-
- boolean firstTime = isisSessionFactory == null;
- if(firstTime) {
-
- // ensures that a FixtureClock is installed as the singleton underpinning the ClockService
- FixtureClock.initialize();
-
- // finalize the config (build and regard immutable)
- // as a side-effect bootstrap CDI, if the environment we are running on does not already have its own
- _Config.getConfiguration();
-
- isisSessionFactory = IsisContext.getSessionFactory();
-
- isisSessionFactory.initServices();
- //FIXME also run fixtures
-
- // REVIEW: does no harm, but is this required?
- closeSession();
-
- // if the IsisSystem does not initialize properly, then - as a side effect - the resulting
- // MetaModelInvalidException will be pushed onto the IsisContext (as a static field).
- val metaModelDeficiencies = IsisContext.getMetaModelDeficienciesIfAny();
-
- if (metaModelDeficiencies != null) {
-
- // for subsequent tests; the attempt to bootstrap the framework will leave
- // the IsisContext singleton as set.
- IsisContext.clear();
-
- final Set<String> validationErrors = metaModelDeficiencies.getValidationErrors();
- final StringBuilder buf = new StringBuilder();
- for (String validationError : validationErrors) {
- buf.append(validationError).append("\n");
- }
- throw new AssertionError("Metamodel is invalid: \n" + buf.toString());
- }
- }
-
- final AuthenticationManager authenticationManager = isisSessionFactory.getAuthenticationManager();
- authenticationSession = authenticationManager.authenticate(authenticationRequestIfAny);
-
- openSession();
- }
-
- // -- isisSystem (populated during setup)
- protected IsisSessionFactory isisSessionFactory;
-
- /**
- * The {@link IsisSessionFactory} created during {@link #setUpSystem()}.
- */
- public IsisSessionFactory getIsisSessionFactory() {
- return isisSessionFactory;
- }
-
- /**
- * The {@link AuthenticationSession} created during {@link #setUpSystem()}.
- */
- public AuthenticationSession getAuthenticationSession() {
- return authenticationSession;
- }
-
- // -- openSession, closeSession, nextSession
-
-
- public void nextSession() throws Exception {
- closeSession();
- openSession();
- }
-
- public void openSession() throws Exception {
- openSession(authenticationSession);
- }
-
- public void openSession(AuthenticationSession authenticationSession) throws Exception {
- isisSessionFactory.openSession(authenticationSession);
- }
-
- public void closeSession() throws Exception {
- if(isisSessionFactory!=null && isisSessionFactory.isInSession()) {
- isisSessionFactory.closeSession();
- }
- }
-
- // -- getService
-
- public <C> C getService(Class<C> serviceClass) {
- return IsisContext.getServiceRegistry().lookupServiceElseFail(serviceClass);
- }
-
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystemBootstrapper.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystemBootstrapper.java
deleted file mode 100644
index 1bb6421..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/IsisSystemBootstrapper.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.runtime.headless;
-
-import org.apache.isis.applib.services.inject.ServiceInjector;
-import org.apache.isis.applib.services.metamodel.MetaModelService;
-import org.apache.isis.commons.internal.assertions._Ensure;
-import org.apache.isis.commons.internal.exceptions._Exceptions;
-import org.apache.isis.config.IsisConfiguration;
-import org.apache.isis.extensions.fixtures.legacy.fixturescripts.FixtureScript;
-import org.apache.isis.extensions.fixtures.legacy.fixturescripts.FixtureScripts;
-import org.apache.isis.runtime.headless.logging.LeveledLogger;
-import org.apache.isis.runtime.headless.logging.LogConfig;
-import org.apache.isis.runtime.system.context.IsisContext;
-
-import lombok.extern.log4j.Log4j2;
-
-@Log4j2
-public class IsisSystemBootstrapper {
-
- private final IsisConfiguration isisConfiguration;
- private final LeveledLogger logger;
-
- public static IsisSystemBootstrapper of(LogConfig logConfig, IsisConfiguration isisConfiguration) {
- return new IsisSystemBootstrapper(logConfig, isisConfiguration);
- }
-
- private IsisSystemBootstrapper(
- final LogConfig logConfig,
- final IsisConfiguration isisConfiguration) {
-
- _Ensure.ensure("Should have an IsisConfiguration!", isisConfiguration!=null);
-
- this.isisConfiguration = isisConfiguration;
- this.logger = new LeveledLogger(log, logConfig.getTestLoggingLevel());
- }
-
- public IsisSystem bootstrapIfRequired() {
- //FIXME[2112]
- _Exceptions.throwNotImplemented();
- //bootstrapUsingConfig();
- return IsisSystem.get();
- }
-
- /**
- * Expects a transaction to have been started
- */
- public void setupModuleRefData() {
- MetaModelService metaModelService = lookupService(MetaModelService.class);
- //FIXME[2112]
- _Exceptions.throwNotImplemented();
- //FixtureScript refDataSetupFixture = metaModelService.getAppManifest2().getRefDataSetupFixture();
- //runFixtureScript(refDataSetupFixture);
- }
-
-
-// private void bootstrapUsingConfig() {
-//
-// final SystemState systemState = null;//FIXME[2112] determineSystemState(isisConfiguration.getAppManifest());
-// switch (systemState) {
-//
-// case BOOTSTRAPPED_SAME_MODULES:
-// // nothing to do
-// break;
-// case BOOTSTRAPPED_DIFFERENT_MODULES:
-// // TODO: this doesn't work correctly yet; not tearing down HSQLDB correctly.
-// if(false) {
-// teardownSystem();
-// } else {
-// throw new RuntimeException("Bootstrapping different modules is not yet supported");
-// }
-// // fall through
-// case NOT_BOOTSTRAPPED:
-//
-// long t0 = System.currentTimeMillis();
-// setupSystem(isisConfiguration);
-// long t1 = System.currentTimeMillis();
-//
-// log("##########################################################################");
-// log("# Bootstrapped in " + (t1- t0) + " millis");
-// log("##########################################################################");
-//
-// TickingFixtureClock.replaceExisting();
-//
-// break;
-// }
-// }
-//
-// private static SystemState determineSystemState(final AppManifest appManifest) {
-// IsisSystem isft = IsisSystem.getElseNull();
-// if (isft == null)
-// return SystemState.NOT_BOOTSTRAPPED;
-//
-// final AppManifest appManifestFromPreviously = isftAppManifest.get();
-// return haveSameModules(appManifest, appManifestFromPreviously)
-// ? SystemState.BOOTSTRAPPED_SAME_MODULES
-// : SystemState.BOOTSTRAPPED_DIFFERENT_MODULES;
-// }
-//
-// static boolean haveSameModules(
-// final AppManifest m1,
-// final AppManifest m2) {
-// final List<Class<?>> m1Modules = m1.getModules();
-// final List<Class<?>> m2Modules = m2.getModules();
-// return m1Modules.containsAll(m2Modules) && m2Modules.containsAll(m1Modules);
-// }
-//
-// private static IsisSystem setupSystem(IsisConfiguration isisConfiguration) {
-//
-// final IsisSystem isft =
-// IsisSystem.ofConfiguration(isisConfiguration);
-//
-// isft.setUpSystem();
-//
-// // save both the system and the manifest
-// // used to bootstrap the system onto thread-local
-// IsisSystem.set(isft);
-// isftAppManifest.set(isisConfiguration.getAppManifest());
-//
-// return isft;
-// }
-
- public void injectServicesInto(final Object object) {
- lookupService(ServiceInjector.class).injectServicesInto(object);
- }
-
- enum SystemState {
- NOT_BOOTSTRAPPED,
- BOOTSTRAPPED_SAME_MODULES,
- BOOTSTRAPPED_DIFFERENT_MODULES
- }
-
- private static void teardownSystem() {
-
- //FIXME[2133]
- _Exceptions.throwNotImplemented();
-
-// final IsisSessionFactory isisSessionFactory = lookupService(IsisSessionFactory.class);
-//
-// final IsisJdoSupport isisJdoSupport = lookupService(IsisJdoSupport.class);
-// final PersistenceManagerFactory pmf =
-// isisJdoSupport.getJdoPersistenceManager().getPersistenceManagerFactory();
-// isisSessionFactory.destroyServicesAndShutdown();
-// pmf.close();
-
- IsisContext.clear();
- }
-
- public void tearDownAllModules() {
- final MetaModelService metaModelService4 = lookupService(MetaModelService.class);
-
- //FIXME[2112]
- _Exceptions.throwNotImplemented();
-// FixtureScript fixtureScript = metaModelService4.getAppManifest2().getTeardownFixture();
-// runFixtureScript(fixtureScript);
- }
-
-
- private void runFixtureScript(final FixtureScript... fixtureScriptList) {
- final FixtureScripts fixtureScripts = lookupService(FixtureScripts.class);
- fixtureScripts.runFixtureScript(fixtureScriptList);
- }
-
-
- private static IsisSystem getIsisSystem() {
- return IsisSystem.get();
- }
-
- private static <T> T lookupService(Class<T> serviceClass) {
- return getIsisSystem().getService(serviceClass);
- }
-
- private void log(final String message) {
- logger.log(message);
- }
-
-}
\ No newline at end of file
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/auth/AuthenticationRequestNameOnly.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/auth/AuthenticationRequestNameOnly.java
deleted file mode 100644
index 15e6bec..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/auth/AuthenticationRequestNameOnly.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.runtime.headless.auth;
-
-import org.apache.isis.security.authentication.AuthenticationRequestAbstract;
-
-public class AuthenticationRequestNameOnly extends AuthenticationRequestAbstract {
-
- public AuthenticationRequestNameOnly(String name) {
- super(name);
- }
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LeveledLogger.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LeveledLogger.java
deleted file mode 100644
index 8673673..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LeveledLogger.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.runtime.headless.logging;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-
-public class LeveledLogger {
-
- private final Logger logger;
- private Level level;
-
- public LeveledLogger(final Logger logger, final Level level) {
- this.logger = logger;
- this.level = level;
- }
-
- public void log(final String message) {
- logger.log(level, message);
-
-//[2112]
-// switch (level.) {
-// case ERROR:
-// logger.error(message);
-// break;
-// case WARN:
-// logger.warn(message);
-// break;
-// case INFO:
-// logger.info(message);
-// break;
-// case DEBUG:
-// logger.debug(message);
-// break;
-// case TRACE:
-// logger.trace(message);
-// break;
-// }
- }
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogConfig.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogConfig.java
deleted file mode 100644
index 6c24ed0..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogConfig.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.runtime.headless.logging;
-
-import java.io.PrintStream;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-
-
-public class LogConfig {
- private final String loggingPropertyFile;
- private final Level testLoggingLevel;
- private final PrintStream fixtureTracing;
-
- public LogConfig(
- final Level testLoggingLevel,
- final Level fixtureTracingLevel,
- final Logger fixtureTracingLogger) {
- this(testLoggingLevel, fixtureTracingLevel, fixtureTracingLogger, null);
- }
- public LogConfig(
- final Level testLoggingLevel,
- final Level fixtureTracingLevel,
- final Logger fixtureTracingLogger,
- final String loggingPropertyFile) {
- this(testLoggingLevel, LogStream.logPrintStream(fixtureTracingLogger, fixtureTracingLevel), loggingPropertyFile);
- }
- public LogConfig(
- final Level testLoggingLevel) {
- this(testLoggingLevel, (String)null);
- }
- public LogConfig(
- final Level testLoggingLevel,
- final String loggingPropertyFile) {
- this(testLoggingLevel, null, loggingPropertyFile);
- }
- public LogConfig(
- final Level testLoggingLevel,
- final PrintStream fixtureTracing) {
- this(testLoggingLevel, fixtureTracing, null);
- }
- public LogConfig(
- final Level testLoggingLevel,
- final PrintStream fixtureTracing,
- final String loggingPropertyFile) {
- this.testLoggingLevel = testLoggingLevel != null ? testLoggingLevel : Level.INFO;
- this.fixtureTracing = fixtureTracing != null ? fixtureTracing : System.out;
- this.loggingPropertyFile =
- loggingPropertyFile != null ? loggingPropertyFile : "logging-integtest.properties";
- }
-
- public Level getTestLoggingLevel() {
- return testLoggingLevel;
- }
-
- public PrintStream getFixtureTracing() {
- return fixtureTracing;
- }
-
- public String getLoggingPropertyFile() {
- return loggingPropertyFile;
- }
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogStream.java b/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogStream.java
deleted file mode 100644
index 871da58..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/runtime/headless/logging/LogStream.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.runtime.headless.logging;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-
-public class LogStream extends OutputStream {
-
- private final LeveledLogger logger;
-
- private final StringBuilder buf = new StringBuilder();
-
- public static PrintStream logPrintStream(final Logger logger, final Level level) {
- return new PrintStream(new LogStream(logger, level));
- }
-
- public LogStream(final Logger logger, final Level level) {
- this.logger = new LeveledLogger(logger, level);
- }
-
- @Override
- public void close() {}
-
- @Override
- public void flush() {
- logger.log(toString());
-
- // Clear the buffer
- buf.delete(0, buf.length());
- }
-
- @Override
- public void write(byte[] b) {
- String str = new String(b);
- this.buf.append(str);
- }
-
- @Override
- public void write(byte[] b, int off, int len) {
- String str = new String(b, off, len);
- this.buf.append(str);
- }
-
- @Override
- public void write(int codePoint) {
- char[] chars = Character.toChars(codePoint);
- this.buf.append(chars);
- }
-
- @Override
- public String toString() {
- return buf.toString();
- }
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/ObjectFactoryForIntegration.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/ObjectFactoryForIntegration.java
new file mode 100644
index 0000000..04ef6f9
--- /dev/null
+++ b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/ObjectFactoryForIntegration.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.specsupport;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+import org.apache.isis.commons.internal.collections._Maps;
+import org.apache.isis.runtime.system.context.IsisContext;
+
+import cucumber.api.java.ObjectFactory;
+import cucumber.runtime.CucumberException;
+import lombok.val;
+
+public class ObjectFactoryForIntegration implements ObjectFactory {
+ private final Map<Class<?>, Object> instances = _Maps.newHashMap();
+
+ @Override
+ public void start() { }
+
+ @Override
+ public void stop() {
+ this.instances.clear();
+ }
+
+ @Override
+ public boolean addClass(Class<?> clazz) {
+ return true;
+ }
+
+ @Override
+ public <T> T getInstance(Class<T> type) {
+ T instance = type.cast(this.instances.get(type));
+ if (instance == null) {
+ instance = this.newInstance(type);
+
+ val injector = IsisContext.getServiceInjector();
+ if(injector != null) {
+ instance = this.cacheInstance(type, instance);
+ injector.injectServicesInto(instance);
+ } else {
+ // don't cache
+ }
+ }
+ return instance;
+ }
+
+ private <T> T cacheInstance(Class<T> type, T instance) {
+ this.instances.put(type, instance);
+ return instance;
+ }
+
+ private <T> T newInstance(Class<T> type) {
+ try {
+ Constructor<T> constructor = type.getConstructor();
+ return constructor.newInstance();
+ } catch (NoSuchMethodException var4) {
+ throw new CucumberException(String.format("%s doesn't have an empty constructor.", type), var4);
+ } catch (Exception var5) {
+ throw new CucumberException(String.format("Failed to instantiate %s", type), var5);
+ }
+ }
+}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProvider.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProvider.java
deleted file mode 100644
index 4c0ed78..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-/**
- * Provides access to the any domain services
- * that may have been configured.
- *
- * <p>
- * For {@link ScenarioExecution scenario}s with integration-scope, these will be
- * configured services for an end-to-end running system. For scenarios with
- * unit-scope, these will typically be mocks.
- *
- * @deprecated - with no replacement
- */
-@Deprecated
-public interface DomainServiceProvider {
-
- <T> T getService(Class<T> serviceClass);
-
- /**
- * Replaces the service implementation with some other.
- *
- * <p>
- * Allows services to be mocked out. It is the responsibility of the test to reinstate the "original"
- * service implementation afterwards.
- * </p>
- */
- <T> void replaceService(T original, T replacement);
-}
\ No newline at end of file
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProviderMockery.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProviderMockery.java
deleted file mode 100644
index 74f866d..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/DomainServiceProviderMockery.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.hamcrest.Description;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.api.Action;
-import org.jmock.api.Invocation;
-
-import org.apache.isis.applib.services.factory.FactoryService;
-import org.apache.isis.applib.services.repository.RepositoryService;
-import org.apache.isis.commons.internal.collections._Maps;
-import org.apache.isis.unittestsupport.jmocking.Imposterisers;
-
-/**
- * @deprecated - with no replacement
- */
-@Deprecated
-class DomainServiceProviderMockery implements DomainServiceProvider {
-
- private RepositoryService mockRepositoryService = null;
- private FactoryService mockFactoryService = null;
- private final Map<Class<?>, Object> mocks = _Maps.newHashMap();
-
- private Mockery context;
-
- private ScenarioExecution scenarioExecution;
-
- DomainServiceProviderMockery() {
- init();
- }
-
- private void init() {
- context = new Mockery() {{
- setImposteriser(Imposterisers.getDefault());
- }};
- mocks.clear();
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> serviceClass) {
- Object mock = doGetService(serviceClass);
-
- if(FactoryService.class.isAssignableFrom(serviceClass)) {
- mockFactoryService = (FactoryService) mock;
-
- context.checking(new Expectations() {
- {
- allowing(mockFactoryService).instantiate(with(Expectations.<Class<?>>anything()));
- will(new Action() {
-
- @Override
- @SuppressWarnings("rawtypes")
- public Object invoke(Invocation invocation) throws Throwable {
- Class cls = (Class) invocation.getParameter(0);
- return scenarioExecution.injectServices(cls.newInstance());
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("newTransientInstance");
- }
- });
- }
- });
- }
- if(RepositoryService.class.isAssignableFrom(serviceClass)) {
- mockRepositoryService = (RepositoryService) mock;
- context.checking(new Expectations() {
- {
- allowing(mockRepositoryService).persist(with(Expectations.<T>anything()));
- }
- });
- }
- return (T) mock;
- }
-
- protected <T> Object doGetService(final Class<T> serviceClass) {
- Object mock = mocks.get(serviceClass);
- if(mock == null) {
- mock = context.mock(serviceClass);
- }
- mocks.put(serviceClass, mock);
- return mock;
- }
-
- @Override
- public <T> void replaceService(final T original, final T replacement) {
- final Class<?> originalKey = keyFor(original);
- if(originalKey == null) {
- throw new IllegalArgumentException("Service to replace not found");
- }
- mocks.put(originalKey, replacement);
- }
-
- private Class<?> keyFor(Object original) {
- final Set<Map.Entry<Class<?>, Object>> entries = mocks.entrySet();
- for (Map.Entry<Class<?>, Object> entry : entries) {
- if(entry.getValue() == original) {
- return entry.getKey();
- }
- }
- return null;
- }
-
- public Mockery mockery() {
- return context;
- }
-
- DomainServiceProviderMockery init(ScenarioExecution scenarioExecution) {
- this.scenarioExecution = scenarioExecution;
- return this;
- }
-
- /**
- * not API
- */
- void assertIsSatisfied() {
- mockery().assertIsSatisfied();
- // discard all existing mocks and mockery, to start again.
- init();
- }
-}
\ No newline at end of file
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/InMemoryDB.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/InMemoryDB.java
deleted file mode 100644
index 4181977..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/InMemoryDB.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-
-import org.apache.isis.schema.utils.InteractionDtoUtils.Strategy;
-import org.hamcrest.Description;
-import org.jmock.api.Action;
-import org.jmock.api.Invocation;
-
-import org.apache.isis.commons.internal.collections._Lists;
-import org.apache.isis.commons.internal.collections._Maps;
-import org.apache.isis.commons.internal.functions._Predicates;
-
-/**
- * Utility class to support the writing of unit-scope specs.
- *
- * <p>
- * The {@link #finds(Class, Strategy)} provides an implementation of a JMock
- * {@link Action} that can simulate searching for an object from a database, and
- * optionally automatically creating a new one if {@link Strategy specified}.
- *
- * <p>
- * If objects are created, then (mock) services are automatically injected. This is performed by
- * searching for <tt>injectXxx()</tt> methods.
- *
- * <p>
- * Finally, note that the {@link #init(Object, String) init} hook method allows subclasses to
- * customize the state of any objects created.
- *
- * @deprecated - with no replacement
- */
-@Deprecated
-public class InMemoryDB {
-
- private final ScenarioExecution scenarioExecution;
-
- public InMemoryDB(ScenarioExecution scenarioExecution) {
- this.scenarioExecution = scenarioExecution;
- }
-
- public static class EntityId {
- private final Class<?> type;
- private final String id;
- public EntityId(Class<?> type, String id) {
- this.type = type;
- this.id = id;
- }
- Class<?> getType() {
- return type;
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- InMemoryDB.EntityId other = (InMemoryDB.EntityId) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- return true;
- }
- @Override
- public String toString() {
- return "EntityId [type=" + type + ", id=" + id + "]";
- }
- }
-
- private Map<InMemoryDB.EntityId, Object> objectsById = _Maps.newHashMap();
-
- /**
- * Returns the object if exists, but will NOT instantiate a new one if not present.
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public <T> T getNoCreate(final Class<T> cls, final String id) {
- Class type = cls;
- while(type != null) {
- // search for this class and all superclasses
- final InMemoryDB.EntityId entityId = new EntityId(cls, id);
- final Object object = objectsById.get(entityId);
- if(object != null) {
- return (T) object;
- }
- type = type.getSuperclass();
- }
- return null;
- }
-
- /**
- * Returns the object if exists, else will instantiate and save a new one if not present.
- *
- * <p>
- * The new object will have services injected into it (through the {@link ScenarioExecution#injectServices(Object)})
- * and will be initialized through the {@link #init(Object, String) init hook} method.
- */
- @SuppressWarnings({ "unchecked" })
- public <T> T getElseCreate(final Class<T> cls, final String id) {
- final Object object = getNoCreate(cls, id);
- if(object != null) {
- return (T) object;
- }
- Object obj = instantiateAndInject(cls);
- init(obj, id);
-
- return put(cls, id, obj);
- }
-
- /**
- * Put an object into the database.
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public <T> T put(final Class<T> cls, final String id, Object obj) {
- Class type = cls;
- // put for this class and all superclasses
- while(type != null) {
- final InMemoryDB.EntityId entityId = new EntityId(cls, id);
- objectsById.put(entityId, obj);
- type = type.getSuperclass();
- }
- return (T) obj;
- }
-
- private Object instantiateAndInject(Class<?> cls) {
- try {
- return scenarioExecution.injectServices(cls.newInstance());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Returns a JMock {@link Action} to return an instance of the provided class.
- *
- * <p>
- * If the object is not yet held in memory, it will be automatically created,
- * as per {@link #getElseCreate(Class, String)}.
- *
- * <p>
- * This {@link Action} can only be set for expectations to invoke a method
- * accepting a single string argument. This string argument is taken to be an
- * identifier for the object (and is used in the caching of that object in memory).
- */
- public Action finds(final Class<?> cls) {
- return new Action() {
-
- @Override
- public Object invoke(Invocation invocation) throws Throwable {
- if(invocation.getParameterCount() != 1) {
- throw new IllegalArgumentException("intended for action of findByXxx");
- }
- final Object argObj = invocation.getParameter(0);
- if(!(argObj instanceof String)) {
- throw new IllegalArgumentException("Argument must be a string");
- }
- String arg = (String) argObj;
- return getElseCreate(cls, arg);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("finds an instance of " + cls.getName());
- }
- };
- }
-
- public <T> List<T> findAll(Class<T> cls) {
- return find(cls, _Predicates.<T>alwaysTrue());
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> find(Class<T> cls, Predicate<T> predicate) {
- final List<T> list = _Lists.newArrayList();
- for (EntityId entityId : objectsById.keySet()) {
- if(cls.isAssignableFrom(entityId.getType())) {
- final T object = (T) objectsById.get(entityId);
- if(predicate.test(object)) {
- list.add(object);
- }
- }
- }
- return list;
- }
-
- /**
- * Hook to initialize if possible.
- *
- * <p>
- * The provided string is usually taken to be some sort of unique identifier for the object
- * (unique in the context of any given scenario, that is).
- */
- protected void init(Object obj, String str) {
- }
-
-
-}
\ No newline at end of file
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecution.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecution.java
deleted file mode 100644
index 8173b05..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecution.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-
-import javax.inject.Inject;
-
-import org.jmock.Mockery;
-import org.jmock.Sequence;
-import org.jmock.States;
-import org.jmock.internal.ExpectationBuilder;
-import org.apache.isis.applib.services.wrapper.WrapperFactory;
-import org.apache.isis.commons.internal.collections._Lists;
-import org.apache.isis.commons.internal.collections._Maps;
-import org.apache.isis.extensions.fixtures.legacy.InstallableFixture;
-import org.apache.isis.metamodel.exceptions.MetaModelException;
-import org.apache.isis.security.authentication.AuthenticationSession;
-
-/**
- * Represents the currently executing scenario, allowing information to be shared
- * between Cucumber step definitions (for unit- or integration- scoped), and also for
- * integration tests.
- *
- * <p>
- * Two types of information are available:
- * <ul>
- * <li>First, there are the domain services, provided using the {@link #service(Class) method}.
- * If running at unit-scope, then these will most likely be mocked services (and not all services
- * will necessarily be available). If running at integration-scope, then these will most likely
- * be real instances, eg wired to the backend database.</li>
- * <li>Second, there is a map of identified objects. This is predominantly for Cucumber
- * step definitions (either unit- or integration-scoped), such that information can be passed
- * between steps in a decoupled fashion.
- * </ul>
- *
- * <p>
- * When instantiated, this object binds itself to the current thread (using a {@link ThreadLocal}).
- *
- * <p>
- * Subclasses may tailor the world for specific types of tests; for example the
- * <tt>IntegrationScenarioExecution</tt> provides additional support for fixtures and
- * transaction management, used both by integration-scoped specs and by integration tests.
- *
- * @deprecated - to be removed in 2.0, will support BDD for integration tests only
- */
-@Deprecated
-public abstract class ScenarioExecution {
-
- private static ThreadLocal<ScenarioExecution> current = new ThreadLocal<ScenarioExecution>();
-
- public static ScenarioExecution peek() {
- return current.get();
- }
-
- public static ScenarioExecution current() {
- final ScenarioExecution execution = current.get();
- if(execution == null) {
- fail();
- }
- return execution;
- }
-
-
- // //////////////////////////////////////
-
- protected final DomainServiceProvider dsp;
- private final ScenarioExecutionScope scope;
-
- protected ScenarioExecution(final DomainServiceProvider dsp, ScenarioExecutionScope scope) {
- this.dsp = dsp;
- this.scope = scope;
- current.set(this);
- }
-
- public boolean ofScope(ScenarioExecutionScope scope) {
- return this.scope == scope;
- }
-
-
- // //////////////////////////////////////
-
- /**
- * Returns a domain service of the specified type, ensuring that
- * it is available.
- *
- * @throws IllegalStateException if not available
- */
- public <T> T service(Class<T> cls) {
- final T service = dsp.getService(cls);
- if(service == null) {
- throw new IllegalStateException(
- "No service of type "
- + cls.getSimpleName()
- + " available");
- }
- return service;
- }
-
- /**
- * Replaces the service implementation with some other.
- *
- * <p>
- * Allows services to be mocked out. It is the responsibility of the test to reinstate the "original"
- * service implementation afterwards.
- *
- * <p>
- * Mock services may requiring expectations to ignore any initialization that the framework would normally perform
- * on them. For example, if mocking out the {@link org.apache.isis.applib.services.eventbus.EventBusService}, the
- * mock should be set up to ignore any calls to
- * {@link org.apache.isis.applib.services.eventbus.EventBusService#register(Object) register} and
- * {@link org.apache.isis.applib.services.eventbus.EventBusService#unregister(Object)}.
- *
- * <p>
- * Because integration tests cache services in the session, this method should typically be followed by
- * calls to {@link #closeSession() close} the current session and then to re-{@link #openSession() open} a new one.
- *
- * <p>
- * TODO: I'm not convinced this works reliably...
- * </p>
- */
- public <T> void replaceService(T original, T replacement) {
- dsp.replaceService(original, replacement);
- }
-
- // /**
- // * Convenience method, returning the {@link DomainObjectContainer},
- // * first ensuring that it is available.
- // *
- // * @throws IllegalStateException if not available
- // */
- // public DomainObjectContainer container() {
- // return service(DomainObjectContainer.class);
- // }
-
-
- /**
- * Returns the {@link WrapperFactory} if one {@link #service(Class) is available},
- * otherwise returns a {@link WrapperFactory#NOOP no-op} implementation.
- */
- public WrapperFactory wrapperFactory() {
- return WrapperFactory.NOOP;
- }
-
-
- // //////////////////////////////////////
-
- /**
- * Key for objects stored by steps in the scenario.
- *
- * <p>
- * Objects can be identified in a variety of manners:
- * <ul>
- * <li>a fully qualified object provides both its type and a (unique) id; for example 'lease OXF-TOPMODEL-001'</li>
- * <li>a named object provides only its id; for example 'OXF-TOPMODEL-001'</li>
- * <li>a typed object provides only its type; for example 'the lease'.</li>
- * </ul>
- *
- * <p>
- * Because of the second rule, the id should be unique in and of itself.
- *
- * <p>
- * The expectation is that scenarios will use the first form (fully qualified) the first time that an
- * object is introduced within a scenario. Thereafter either of the other forms may be used.
- * In the case of a typed object (eg "the lease"), the most recently "touched" object of that type
- * is returned.
- */
- public static class VariableId {
- private final String type;
- private final String id;
- public VariableId(String type, String id) {
- this.type = type;
- this.id = id;
- }
-
- /**
- * eg 'lease'
- */
- public String getType() {
- return type;
- }
- /**
- * eg 'OXF-TOPMODEL-001'
- */
- public String getId() {
- return id;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- VariableId other = (VariableId) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "VariableId [type=" + type + ", id=" + id + "]";
- }
- }
-
- private final Map<VariableId, Object> objectByVariableId = _Maps.newLinkedHashMap();
- private final Map<String, Object> objectsById = _Maps.newLinkedHashMap();
-
- private final Map<String, Object> mostRecent = _Maps.newHashMap();
-
- public void putVar(String type, String id, Object value) {
- if(type == null || id == null) {
- throw new IllegalArgumentException("type and id must both be provided to save a scenario variable");
- }
- if(value == null) {
- throw new IllegalArgumentException("value cannot be null; use remove() to clear an scenario variable");
- }
- final VariableId key = new VariableId(type, id);
- objectByVariableId.put(key, value);
- objectsById.put(id, value);
- mostRecent.put(type, value);
- }
-
- public void removeVar(String type, String id) {
- if(type != null && id != null) {
- final VariableId key = new VariableId(type, id);
- objectByVariableId.remove(key);
- }
- if(id != null) {
- objectsById.remove(id);
- }
- if(type != null) {
- mostRecent.remove(type);
- }
- }
-
- /**
- * Retrieve an variable previously used in the scenario.
- *
- * <p>
- * Must specify type and/or id.
- *
- * @see VariableId - for rules on what constitutes an identifier.
- */
- public Object getVar(String type, String id) {
- if(type != null && id != null) {
- final VariableId variableId = new VariableId(type,id);
- final Object value = objectByVariableId.get(variableId);
- if(value != null) {
- mostRecent.put(type, value);
- return value;
- }
- throw new IllegalStateException("No such " + variableId);
- }
- if(type != null && id == null) {
- return mostRecent.get(type);
- }
- if(type == null && id != null) {
- final Object value = objectsById.get(id);
- if(value != null) {
- mostRecent.put(type, value);
- }
- return value;
- }
- throw new IllegalArgumentException("Must specify type and/or id");
- }
-
- /**
- * As {@link #getVar(String, String)}, but downcasting to the provided class.
- */
- @SuppressWarnings("unchecked")
- public <X> X getVar(String type, String id, Class<X> cls) {
- return (X) getVar(type, id);
- }
-
- // //////////////////////////////////////
-
- /**
- * Whether this implementation supports mocks.
- *
- * <p>
- * This default implementation returns <tt>false</tt>, meaning that the methods to
- * support mocking ({@link #checking(ExpectationBuilder)}, {@link #assertIsSatisfied()},
- * {@link #sequence(String)} and {@link #states(String)}) may not be called. However,
- * the {@link ScenarioExecutionForUnit} overrides this and does support mocking.
- */
- public boolean supportsMocks() {
- return false;
- }
-
- /**
- * Install expectations on mock domain services (if appropriate).
- *
- * <p>
- * By default, mocks are not supported. However, {@link ScenarioExecutionForUnit} overrides this
- * method and does support mocking (delegating to an underlying JMock {@link Mockery}).
- *
- * <p>
- * Subclasses of this class tailored to supporting integration specs/tests should do nothing
- */
- public void checking(ExpectationBuilder expectations) {
- throw new IllegalStateException("Mocks are not supported");
- }
-
- /**
- * Install expectations on mock domain services (if appropriate).
- *
- * <p>
- * By default, mocks are not supported. To reduce clutter in tests, this method is a no-op
- * and will silently do nothing if called when mocks are not supported.
- *
- * <p>
- * The {@link ScenarioExecutionForUnit} overrides this method and does support mocking, delegating
- * to an underlying JMock {@link Mockery}). Not only will it assert all existing interactions
- * have been satisfied, it also resets mocks/expectations for the next interaction.
- */
- public void assertIsSatisfied() {
- }
-
- /**
- * Define {@link Sequence} in a (JMock) interaction (if appropriaate).
- *
- * <p>
- * By default, mocks are not supported. However, {@link ScenarioExecutionForUnit} overrides this
- * method and does support mocking (delegating to an underlying JMock {@link Mockery}).
- *
- * <p>
- * Subclasses of this class tailored to supporting integration specs/tests should do nothing
- */
- public Sequence sequence(String name) {
- throw new IllegalStateException("Mocks are not supported");
- }
-
- /**
- * Define {@link States} in a (JMock) interaction (if appropriaate).
- *
- * <p>
- * By default, mocks are not supported. However, {@link ScenarioExecutionForUnit} overrides this
- * method and does support mocking (delegating to an underlying JMock {@link Mockery}).
- *
- * <p>
- * Subclasses of this class tailored to supporting integration specs/tests should do nothing
- */
- public States states(String name) {
- throw new IllegalStateException("Mocks are not supported");
- }
-
- // //////////////////////////////////////
-
- /**
- * Install arbitrary fixtures, eg before an integration tests or as part of a
- * Cucumber step definitions or hook.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs/tests are expected to override.
- */
- public void install(InstallableFixture... fixtures) {
- // do nothing
- }
-
- // //////////////////////////////////////
-
- /**
- * For Cucumber hooks to call.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs are expected to override.
- */
- public void openSession() {
- // do nothing
- }
-
- /**
- * For Cucumber hooks to call.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs are expected to override.
- */
- public void openSession(AuthenticationSession authenticationSession) {
- // do nothing
- }
-
- /**
- * For Cucumber hooks to call.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs are expected to override.
- */
- public void closeSession() {
- // do nothing
- }
-
- // //////////////////////////////////////
-
- /**
- * For Cucumber hooks to call, performing transaction management around each step.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs are expected to override. (Integration tests can use
- * the <tt>IsisTransactionRule</tt> to do transaction management transparently).
- */
- public void beginTran() {
- // do nothing
- }
-
- /**
- * For Cucumber hooks to call, performing transaction management around each step.
- *
- * <p>
- * This implementation is a no-op, but subclasses of this class tailored to
- * supporting integration specs are expected to override. (Integration tests can use
- * the <tt>IsisTransactionRule</tt> to do transaction management transparently).
- */
- public void endTran(boolean ok) {
- // do nothing
- }
-
- // //////////////////////////////////////
-
- public Object injectServices(final Object obj) {
- try {
- final Method[] methods = obj.getClass().getMethods();
- for (Method method : methods) {
- final Class<?>[] parameterTypes = method.getParameterTypes();
- if(parameterTypes.length != 1) {
- continue;
- }
- final Class<?> serviceClass = parameterTypes[0];
- if(method.getName().startsWith("inject")) {
- final Object service = service(serviceClass);
- method.invoke(obj, service);
- }
- // if(method.getName().startsWith("set") && serviceClass == DomainObjectContainer.class) {
- // final Object container = container();
- // method.invoke(obj, container);
- // }
- }
- autowireViaFields(obj, obj.getClass());
-
- return obj;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private void autowireViaFields(final Object object, final Class<?> cls) {
- final List<Field> fields = Arrays.asList(cls.getDeclaredFields());
- final List<Field> injectFields = _Lists.filter(fields, new Predicate<Field>() {
- @Override
- public boolean test(Field input) {
- final Inject annotation = input.getAnnotation(javax.inject.Inject.class);
- return annotation != null;
- }
- });
-
- for (final Field field : injectFields) {
- final Object service = service(field.getType());
- final Class<?> serviceClass = service.getClass();
- field.setAccessible(true);
- invokeInjectorField(field, object, service);
- }
-
- // recurse up the hierarchy
- final Class<?> superclass = cls.getSuperclass();
- if(superclass != null) {
- autowireViaFields(object, superclass);
- }
- }
-
- private static void invokeInjectorField(final Field field, final Object target, final Object parameter) {
- try {
- field.set(target, parameter);
- } catch (IllegalArgumentException e) {
- throw new MetaModelException(e);
- } catch (IllegalAccessException e) {
- throw new MetaModelException(String.format("Cannot access the %s field in %s", field.getName(), target.getClass().getName()));
- }
- }
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionForUnit.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionForUnit.java
deleted file mode 100644
index 870db30..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionForUnit.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-import org.jmock.Mockery;
-import org.jmock.Sequence;
-import org.jmock.States;
-import org.jmock.internal.ExpectationBuilder;
-
-/**
- * An implementation of {@link ScenarioExecution} with which uses JMock to provide
- * all services.
- *
- * <p>
- * Expectations can be {@link Mockery#checking(org.jmock.internal.ExpectationBuilder) set}
- * and interactions {@link Mockery#assertIsSatisfied() verified} by accessing
- * the underlying {@link Mockery}.
- *
- * @deprecated - to be removed in 2.0, will support BDD for integration tests only
- */
-@Deprecated
-public class ScenarioExecutionForUnit extends ScenarioExecution {
-
- private final DomainServiceProviderMockery dspm;
-
- public ScenarioExecutionForUnit() {
- this(new DomainServiceProviderMockery());
- }
- private ScenarioExecutionForUnit(DomainServiceProviderMockery dspm) {
- super(dspm, ScenarioExecutionScope.UNIT);
- this.dspm = dspm.init(this);
- }
-
-
- // //////////////////////////////////////
-
- @Override
- public boolean supportsMocks() {
- return true;
- }
- /**
- * Sets up an expectation against the underlying JMock {@link Mockery}
- * (as wrapped by {@link DomainServiceProviderMockery}).
- */
- @Override
- public void checking(ExpectationBuilder expectations) {
- dspm.mockery().checking(expectations);
- }
-
- @Override
- public void assertIsSatisfied() {
- dspm.assertIsSatisfied();
- }
-
- @Override
- public Sequence sequence(String name) {
- return dspm.mockery().sequence(name);
- }
- @Override
- public States states(String name) {
- return dspm.mockery().states(name);
- }
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionScope.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionScope.java
deleted file mode 100644
index a070d19..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/scenarios/ScenarioExecutionScope.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.scenarios;
-
-import org.apache.isis.commons.internal.context._Context;
-
-/**
- * The scope at which the specification will run; acts as a factory to create
- * an instance of the appropriate subclass of {@link ScenarioExecution}.
- *
- * @deprecated - with no replacement
- */
-@Deprecated
-public class ScenarioExecutionScope {
-
- public final static ScenarioExecutionScope UNIT = new ScenarioExecutionScope(ScenarioExecutionForUnit.class);
- public final static ScenarioExecutionScope INTEGRATION = new ScenarioExecutionScope("org.apache.isis.integtestsupport.scenarios.ScenarioExecutionForIntegration");
-
- private final Class<? extends ScenarioExecution> scenarioExecutionClass;
-
- public ScenarioExecutionScope(Class<? extends ScenarioExecution> scenarioExecutionClass) {
- this.scenarioExecutionClass = scenarioExecutionClass;
- }
-
- @SuppressWarnings("unchecked")
- public ScenarioExecutionScope(String scenarioExecutionClassName) {
- try {
- this.scenarioExecutionClass = (Class<? extends ScenarioExecution>)
- _Context.loadClass(scenarioExecutionClassName);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- public ScenarioExecution instantiate() {
- try {
- return scenarioExecutionClass.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return scenarioExecutionClass.getName();
- }
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract.java
index 61981d6..d709908 100644
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract.java
+++ b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract.java
@@ -1,5 +1,5 @@
/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
+O * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
@@ -16,320 +16,17 @@
*/
package org.apache.isis.specsupport.specs;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.isis.applib.services.wrapper.WrapperFactory;
-import org.apache.isis.commons.internal.base._Strings;
-import org.jmock.Sequence;
-import org.jmock.States;
-import org.jmock.internal.ExpectationBuilder;
-
-import java.util.Objects;
-import org.apache.isis.commons.internal.collections._Lists;
-import org.apache.isis.specsupport.scenarios.ScenarioExecution;
-import org.apache.isis.specsupport.scenarios.ScenarioExecutionForUnit;
-import org.apache.isis.specsupport.scenarios.ScenarioExecutionScope;
-
-import cucumber.api.java.Before;
+import org.apache.isis.runtime.headless.HeadlessAbstract;
/**
- * Base class for Cucumber-JVM step definitions.
+ * Base class for BDD spec glue.
*
* <p>
- * Simply declares that an instance of {@link ScenarioExecution} (or a subclass)
- * must be instantiated by the Cucumber-JVM runtime and injected into the step definitions.
- *
- * @deprecated - use {@link CukeGlueAbstract2} instead.
+ * Note that there also needs to be at least one spec glue that performs the bootstrapping.
+ * This should inline the boilerplate that can be found in {@link CukeGlueBootstrappingAbstract} (it's not possible
+ * to inherit from that class, unfortunately).
+ * </p>
*/
-@Deprecated
-public abstract class CukeGlueAbstract {
-
- /**
- * Access the {@link ScenarioExecution} as setup through a previous call to {@link #before(ScenarioExecutionScope)}.
- *
- * <p>
- * This corresponds, broadly, to the (Ruby) Cucumber's "World" object.
- */
- protected ScenarioExecution scenarioExecution() {
- if(ScenarioExecution.current() == null) {
- fail();
- return null;
- }
- return ScenarioExecution.current();
- }
-
- // //////////////////////////////////////
-
- /**
- * Intended to be called at the beginning of any 'when' (after all the 'given's)
- * or at the beginning of any 'then' (after all the 'when's)
- *
- * <p>
- * Simply {@link ScenarioExecution#endTran(boolean) ends any existing transaction} and
- * then {@link ScenarioExecution#beginTran() starts a new one}.
- */
- protected void nextTransaction() {
- final ScenarioExecution scenarioExecution = scenarioExecution();
- if(scenarioExecution != null) {
- scenarioExecution.endTran(true);
- scenarioExecution.beginTran();
- }
- }
-
-
- // //////////////////////////////////////
-
- /**
- * Convenience method
- */
- public Object getVar(String type, String id) {
- return scenarioExecution().getVar(type, id);
- }
-
- /**
- * Convenience method
- */
- public <X> X getVar(String type, String id, Class<X> cls) {
- return scenarioExecution().getVar(type, id ,cls);
- }
-
- /**
- * Convenience method
- */
- public void putVar(String type, String id, Object value) {
- scenarioExecution().putVar(type, id, value);
- }
-
- /**
- * Convenience method
- */
- public void removeVar(String type, String id) {
- scenarioExecution().removeVar(type, id);
- }
-
- /**
- * Convenience method
- */
- protected <T> T service(Class<T> cls) {
- return scenarioExecution().service(cls);
- }
-
- // /**
- // * Convenience method
- // */
- // protected DomainObjectContainer container() {
- // return scenarioExecution().container();
- // }
-
- /**
- * Convenience method
- */
- protected WrapperFactory wrapperFactory() {
- return scenarioExecution().wrapperFactory();
- }
-
- /**
- * Convenience method
- */
- protected <T> T wrap(T obj) {
- return wrapperFactory().wrap(obj);
- }
-
- /**
- * Convenience method
- */
- protected <T> T unwrap(T obj) {
- return wrapperFactory().unwrap(obj);
- }
-
- /**
- * Convenience method
- * @return
- */
- public boolean supportsMocks() {
- return scenarioExecution().supportsMocks();
- }
-
- /**
- * Convenience method
- */
- public void checking(ExpectationBuilder expectations) {
- scenarioExecution().checking(expectations);
- }
-
- /**
- * Convenience method
- */
- public void assertMocksSatisfied() {
- scenarioExecution().assertIsSatisfied();
- }
-
- /**
- * Convenience method
- */
- public Sequence sequence(String name) {
- return scenarioExecution().sequence(name);
- }
-
- /**
- * Convenience method
- */
- public States states(String name) {
- return scenarioExecution().states(name);
- }
-
- // //////////////////////////////////////
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public static void assertTableEquals(final List listOfExpecteds, final Iterable iterableOfActuals) {
- final List<Object> listOfActuals = _Lists.newArrayList(iterableOfActuals);
- assertThat(listOfActuals.size(), is(listOfExpecteds.size()));
-
- final StringBuilder buf = new StringBuilder();
- for (int i=0; i<listOfActuals.size(); i++) {
-
- final Object actual = listOfActuals.get(i);
- final Object expected = listOfExpecteds.get(i);
-
- final Field[] expectedFields = expected.getClass().getDeclaredFields();
- for (Field field : expectedFields) {
- final String propertyName = field.getName();
- final Object actualProp = getProperty(actual, propertyName );
- final Object expectedProp = getProperty(expected, propertyName);
-
- if(!Objects.equals(actualProp, expectedProp)) {
- buf.append("#" + i + ": " + propertyName + ": " + expectedProp + " vs " + actualProp).append("\n");
- }
- }
- }
- if(buf.length() != 0) {
- fail("\n" + buf.toString());
- }
- }
-
-
- private static Object getProperty(Object obj, String propertyName) {
- if(obj == null) {
- return null;
- }
- final Class<? extends Object> cls = obj.getClass();
- try {
- final String methodName = "get" + _Strings.capitalize(propertyName);
- final Method method = cls.getMethod(methodName, new Class[]{});
- if(method != null) {
- return method.invoke(obj);
- }
- } catch (Exception e) {
- // continue
- }
-
- try {
- final String methodName = "is" + _Strings.capitalize(propertyName);
- final Method method = cls.getMethod(methodName, new Class[]{});
- if(method != null) {
- return method.invoke(obj);
- }
- } catch (Exception e) {
- // continue
- }
-
- try {
- final Field field = cls.getDeclaredField(propertyName);
- if(field != null) {
- if(!field.isAccessible()) {
- field.setAccessible(true);
- }
- return field.get(obj);
- }
- } catch (Exception e) {
- // continue
- }
-
- return null;
- }
-
- // //////////////////////////////////////
-
- /**
- * Indicate that a scenario is starting, and specify the {@link ScenarioExecutionScope scope}
- * at which to run the scenario.
- *
- * <p>
- * This method should be called from a "before" hook (a method annotated with
- * Cucumber's {@link Before} annotation, in a step definition subclass. The tag
- * should be appropriate for the scope specified. Typically this method should be delegated to
- * twice, in two mutually exclusive before hooks.
- *
- * <p>
- * Calling this method makes the {@link ScenarioExecution} available (via {@link #scenarioExecution()}).
- * It also delegates to the scenario to {@link ScenarioExecution#beginTran() begin the transaction}.
- * (Whether this actually does anything depends in implementation of the {@link ScenarioExecution}).
- *
- * <p>
- * The boilerplate (to copy-n-paste as required) is:
- * <pre>
- * @cucumber.api.java.Before("@unit")
- * public void beforeScenarioUnitScope() {
- * before(ScenarioExecutionScope.UNIT);
- * }
- * @cucumber.api.java.Before("@integration")
- * public void beforeScenarioIntegrationScope() {
- * before(ScenarioExecutionScope.INTEGRATION);
- * }
- * </pre>
- * The built-in {@link ScenarioExecutionScope#UNIT unit}-level scope will instantiate a
- * {@link ScenarioExecutionForUnit}, while the built-in
- * {@link ScenarioExecutionScope#INTEGRATION integration}-level scope instantiates
- * <tt>ScenarioExecutionForIntegration</tt> (from the <tt>isis-core-integtestsupport</tt> module).
- * The former provides access to domain services as mocks, whereas the latter wraps a running
- * <tt>IsisSystemForTest</tt>.
- *
- * <p>
- * If need be, it is also possible to define custom scopes, with a different implementation of
- * {@link ScenarioExecution}. This might be done when unit testing where a large number of specs
- * have similar expectations needing to be set on the mock domain services.
- *
- * <p>
- * Not every class holding step definitions should have these hooks, only those that correspond to the logical
- * beginning and end of scenario. As such, this method may only be called once per scenario execution
- * (and fails fast if called more than once).
- */
- protected void before(ScenarioExecutionScope scope) {
- final ScenarioExecution scenarioExecution = scope.instantiate();
- scenarioExecution.beginTran();
- }
-
- /**
- * Indicate that a scenario is ending; the {@link ScenarioExecution} is discarded and no
- * longer {@link #scenarioExecution() available}.
- *
- * <p>
- * Before being discarded, the {@link ScenarioExecution} is delegated to
- * in order to {@link ScenarioExecution#endTran(boolean) end the transaction}.
- * (Whether this actually does anything depends in implementation of the {@link ScenarioExecution}).
- *
- * <p>
- * The boilerplate (to copy-n-paste as required) is:
- * <pre>
- * @cucumber.api.java.After
- * public void afterScenario(cucumber.api.Scenario sc) {
- * after(sc);
- * }
- * </pre>
- *
- * <p>
- * Not every class holding step definitions should have this hook, only those that correspond to the logical
- * beginning and end of scenario. As such, this method may only be called once per scenario execution
- * (and fails fast if called more than once).
- */
- public void after(cucumber.api.Scenario sc) {
- ScenarioExecution.current().endTran(!sc.isFailed());
- }
+public abstract class CukeGlueAbstract extends HeadlessAbstract {
}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract2.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract2.java
deleted file mode 100644
index d1d5292..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueAbstract2.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-O * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.specs;
-
-import org.apache.isis.runtime.headless.HeadlessAbstract;
-
-/**
- * Base class for BDD spec glue.
- *
- * <p>
- * Note that there also needs to be at least one spec glue that performs the bootstrapping.
- * This should inline the boilerplate that can be found in {@link CukeGlueBootstrappingAbstract} (it's not possible
- * to inherit from that class, unfortunately).
- * </p>
- */
-public abstract class CukeGlueAbstract2 extends HeadlessAbstract {
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueBootstrappingAbstract.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueBootstrappingAbstract.java
deleted file mode 100644
index 0c5ef3e..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeGlueBootstrappingAbstract.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
-O * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.specs;
-
-import com.fasterxml.jackson.databind.Module;
-
-import org.apache.isis.config.IsisConfiguration;
-import org.apache.isis.runtime.headless.HeadlessWithBootstrappingAbstract;
-import org.apache.isis.runtime.headless.logging.LogConfig;
-
-import cucumber.api.java.After;
-import cucumber.api.java.Before;
-
-/**
- * For BDD spec using headless access, there needs to be (at least) one BDD spec glue that inherits from this adapter
- * class, specifying the {@link Module} to use to bootstrap the system.
- *
- * <p>
- * <b>This class is deprecated</b>. It's not possible to subclass from this class, it'll result in an exception:
- * <code>cucumber.runtime.CucumberException: You're not allowed to extend classes that define Step Definitions or
- * hooks</code>.
- * Instead, just inline the contents of this class.
- * </p>
- *
- * @deprecated - it's not possible to subclass from this class. Instead, just inline the contents of this class.
- */
-@Deprecated
-public abstract class CukeGlueBootstrappingAbstract extends HeadlessWithBootstrappingAbstract {
-
- protected CukeGlueBootstrappingAbstract(LogConfig logConfig, IsisConfiguration isisConfiguration) {
- super(logConfig, isisConfiguration);
- }
-
- @Before(order=100)
- public void beforeScenario() {
- super.bootstrapAndSetupIfRequired();
- }
-
- @After
- public void afterScenario(cucumber.api.Scenario sc) {
- super.tearDownAllModules();
- }
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeSpecsAbstract.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeSpecsAbstract.java
deleted file mode 100644
index 6737546..0000000
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/CukeSpecsAbstract.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.specsupport.specs;
-
-import org.junit.runner.RunWith;
-
-import cucumber.api.CucumberOptions;
-import cucumber.api.junit.Cucumber;
-
-/**
- * Base class for all Cucumber specs run at unit-scope; runs the spec as a JUnit test.
- *
- * @deprecated - with no replacement
- */
-@Deprecated
-@RunWith(Cucumber.class)
-@CucumberOptions(
- format = {
- "html:target/cucumber-html-report"
- // addHook causes an exception to be thrown if this reporter is registered...
- // ,"json-pretty:target/cucumber-json-report.json"
- },
- strict = true,
- tags = { "~@backlog" })
-public abstract class CukeSpecsAbstract {
-
-
-}
diff --git a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/V.java b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/V.java
index 3743012..e5e31fe 100644
--- a/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/V.java
+++ b/extensions/specsupport/src/main/java/org/apache/isis/specsupport/specs/V.java
@@ -16,8 +16,6 @@
*/
package org.apache.isis.specsupport.specs;
-import cucumber.api.Transformer;
-
import org.joda.time.format.DateTimeFormat;
/**
@@ -27,6 +25,16 @@ public class V {
private V() {
}
+
+ /**
+ * @deprecated this is just a dummy, it seems the former cucumber.api.Transformer was removed;
+ * what's the replacement?
+ *
+ * @param <T>
+ */
+ public static abstract class Transformer<T> {
+ public abstract T transform(java.lang.String value);
+ }
/**
* Converts {@link java.lang.String}s to {@link java.lang.Byte}, but also recognizing the