Merges AASHTTPServer versions
Change-Id: Ide76c85e4e7d834ed7e27983b3dd59f03552304b
Signed-off-by: Daniel Espen <daniel.espen@iese.fraunhofer.de>
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProvider.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProvider.java
index 47cb986..cec4afc 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProvider.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProvider.java
@@ -4,8 +4,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -31,7 +31,7 @@
* Makes sure Tomcat Server is started with basyx.components regression test case
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderPropertyMetaData.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderPropertyMetaData.java
index f760c5d..8a87ce9 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderPropertyMetaData.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderPropertyMetaData.java
@@ -4,8 +4,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -31,7 +31,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderSubmodelMetaData.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderSubmodelMetaData.java
index a77cd3a..d6bbf43 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderSubmodelMetaData.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/cfgprovider/tests/TestCFGProviderSubmodelMetaData.java
@@ -4,8 +4,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -31,7 +31,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProvider.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProvider.java
index b315432..ca677a8 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProvider.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProvider.java
@@ -8,8 +8,8 @@
import java.net.URLEncoder;
import org.eclipse.basyx.aas.backend.connector.MetaprotocolHandler;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.tools.webserviceclient.WebServiceRawClient;
import org.junit.ClassRule;
import org.junit.Test;
@@ -29,7 +29,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
private MetaprotocolHandler handler = new MetaprotocolHandler();
/**
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProviderExceptions.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProviderExceptions.java
index a903852..5ce8391 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProviderExceptions.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/file/TestStaticDirectoryFileProviderExceptions.java
@@ -7,8 +7,8 @@
import javax.ws.rs.ServerErrorException;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.tools.webserviceclient.WebServiceJSONClient;
import org.junit.ClassRule;
import org.junit.Test;
@@ -27,7 +27,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Execute test case that tests not implemented calls
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/sql/TestDirectorySQLProvider.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/sql/TestDirectorySQLProvider.java
index af7369f..af0d8c4 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/sql/TestDirectorySQLProvider.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/directory/sql/TestDirectorySQLProvider.java
@@ -11,8 +11,8 @@
import org.eclipse.basyx.aas.backend.http.tools.GSONTools;
import org.eclipse.basyx.aas.backend.http.tools.factory.DefaultTypeFactory;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.identifier.IdentifierType;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.tools.aasdescriptor.AASDescriptor;
import org.eclipse.basyx.tools.webserviceclient.WebServiceRawClient;
import org.junit.Before;
@@ -31,7 +31,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
// Directory web service URL
public String wsURL;
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestDeviceAdministrationShell.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestDeviceAdministrationShell.java
index 40884b2..4446d1b 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestDeviceAdministrationShell.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestDeviceAdministrationShell.java
@@ -10,8 +10,9 @@
import org.eclipse.basyx.aas.backend.connected.ConnectedAssetAdministrationShellManager;
import org.eclipse.basyx.aas.backend.connected.aas.ConnectedAssetAdministrationShell;
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
-import org.eclipse.basyx.regression.support.processengine.SetupHTTResource;
-import org.eclipse.basyx.testsuite.support.vab.stub.DirectoryServiceStub;
+import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
+import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.junit.Before;
import org.junit.ClassRule;
@@ -25,24 +26,27 @@
*
*/
public class TestDeviceAdministrationShell {
- private ConnectedAssetAdministrationShellManager manager;
- ConnectedAssetAdministrationShell connectedAAS;
+ private ConnectedAssetAdministrationShell connectedAAS;
+
+ /**
+ * VAB connection manager backend
+ */
+ protected VABConnectionManager connManager = new VABConnectionManager(new ComponentsTestsuiteDirectory(),
+ new HTTPConnectorProvider());
+
+ protected ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(
+ connManager);
+
/**
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static SetupHTTResource res = new SetupHTTResource();
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
+
@Before
public void setupConnection() {
-
-
- //set-up the administration shell manager to create connected aas
- manager = new ConnectedAssetAdministrationShellManager(new VABConnectionManager(new DirectoryServiceStub()
- .addMapping("coilcar", "http://localhost:8080/basys.sdk/Testsuite/coilcar/")
- .addMapping("submodel1", "http://localhost:8080/basys.sdk/Testsuite/coilcar/"),
- new HTTPConnectorProvider()));
-
// create the connected AAS using the manager
+
try {
connectedAAS = (ConnectedAssetAdministrationShell) manager.retrieveAAS("coilcar");
} catch (Exception e) {
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestTransportProcess_ConfigureEngineProgramically.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestTransportProcess_ConfigureEngineProgramically.java
index d6aad24..d4f22f5 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestTransportProcess_ConfigureEngineProgramically.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/processengineconnector/tests/TestTransportProcess_ConfigureEngineProgramically.java
@@ -15,8 +15,9 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.components.processengine.connector.DeviceServiceDelegate;
import org.eclipse.basyx.regression.support.processengine.SetupAAS;
-import org.eclipse.basyx.regression.support.processengine.SetupHTTResource;
import org.eclipse.basyx.regression.support.processengine.executor.CoilcarServiceExecutor;
+import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.testsuite.support.vab.stub.DirectoryServiceStub;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.junit.Before;
@@ -47,7 +48,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static SetupHTTResource res = new SetupHTTResource();
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Creates the manager to be used in the test cases
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAAS.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAAS.java
index d4efa09..98d8fb8 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAAS.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAAS.java
@@ -5,8 +5,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.AssetAdministrationShell;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -32,7 +32,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAASNewModel.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAASNewModel.java
index d1d2e2e..148f01a 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAASNewModel.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderAASNewModel.java
@@ -5,8 +5,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.AssetAdministrationShell;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -32,7 +32,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderComplexType.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderComplexType.java
index 230999a..d08ac6e 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderComplexType.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderComplexType.java
@@ -7,8 +7,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -34,7 +34,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderSimpleValues.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderSimpleValues.java
index 16fe72d..bf2f23a 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderSimpleValues.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/rawcfgprovider/tests/TestRawCFGProviderSimpleValues.java
@@ -4,8 +4,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -29,7 +29,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLInvocationsTest.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLInvocationsTest.java
index 456eaaa..267d525 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLInvocationsTest.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLInvocationsTest.java
@@ -2,10 +2,11 @@
import java.util.Collection;
import java.util.LinkedList;
+
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -31,7 +32,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLQueriesTest.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLQueriesTest.java
index 08ee75f..56406f6 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLQueriesTest.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/sqlprovider/tests/SQLQueriesTest.java
@@ -5,8 +5,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -32,7 +32,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/directory/ComponentsTestsuiteDirectory.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/directory/ComponentsTestsuiteDirectory.java
index 303012f..8319dc8 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/directory/ComponentsTestsuiteDirectory.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/directory/ComponentsTestsuiteDirectory.java
@@ -34,5 +34,8 @@
addMapping("sampleRawCFG.RawCfgFileTestAAS", "http://localhost:8080/basys.components/Testsuite/components/BaSys/1.0/provider/rawcfgsm/");
// - XQuery provider mappings
addMapping("XMLXQueryFileTestAAS", "http://localhost:8080/basys.components/Testsuite/components/BaSys/1.0/provider/xmlxquery/");
+ // - Processengine mappings
+ addMapping("coilcar", "http://localhost:8080/basys.components/Testsuite/Processengine/coilcar/");
+ addMapping("submodel1", "http://localhost:8080/basys.components/Testsuite/Processengine/coilcar/");
}
}
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/processengine/SetupHTTResource.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/processengine/SetupHTTResource.java
deleted file mode 100644
index 1e32611..0000000
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/processengine/SetupHTTResource.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.eclipse.basyx.regression.support.processengine;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServlet;
-
-import org.eclipse.basyx.regression.support.processengine.servlet.CoilcarAASServlet;
-import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServer;
-import org.junit.rules.ExternalResource;
-
-
-public class SetupHTTResource extends ExternalResource {
- private static int refCount = 0;
-
- private static SetupHTTResource currentInstance;
-
- private AASHTTPServer server;
-
- public static SetupHTTResource getTestResource () {
- if (refCount == 0) {
- currentInstance = new SetupHTTResource();
- }
- return currentInstance;
- }
-
- protected void before() {
- try {
- if (refCount == 0) {
- System.out.println("Do actual TestResources init");
-
- Map<String, HttpServlet> servlets = new HashMap<String, HttpServlet>();
- servlets.put("/Testsuite/coilcar/*", new CoilcarAASServlet());
-
- server = new AASHTTPServer(servlets);
- server.start();
-
- }
- }
- finally {
- refCount++;
- }
- }
-
- protected void after() {
- System.out.println("TestResources after");
- refCount--;
- if (refCount == 0) {
- System.out.println("Do actual TestResources destroy");
-
- server.shutdown();
- }
- }
-}
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServer.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServer.java
deleted file mode 100644
index 5898bb3..0000000
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServer.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.eclipse.basyx.regression.support.server;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import javax.servlet.http.HttpServlet;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-
-
-
-/**
- * Starter Class for Apache Tomcat 9.0.14 HTTP server that adds the provided servlets and respective mappings on startup.
- *
- * @author pschorn
- *
- */
-public class AASHTTPServer extends Thread {
-
-
- /**
- * Apache Tomcat server reference
- */
- protected Tomcat tomcat;
-
-
-
- /**
- * Constructor
- *
- * Create new Tomcat instance and add the provided servlet mappings
- *
- * @param context Basyx context with of url mappings to HTTPServlet
- */
- public AASHTTPServer(BaSyxContext context) {
- // Instantiate and setup Tomcat server
- tomcat = new Tomcat();
- tomcat.setPort(context.port);
- tomcat.setHostname(context.hostname);
- tomcat.getHost().setAppBase(".");
-
- // Create servlet context
- // - Base path for resource files
- File docBase = new File(context.docBasePath); //System.getProperty("java.io.tmpdir"));
- // - Create context for servlets
- Context rootCtx = tomcat.addContext(context.contextPath, docBase.getAbsolutePath());
-
- // Iterate all servlets in context
- Iterator<Entry<String, HttpServlet>> it = context.entrySet().iterator();
- while (it.hasNext()) {
- // Servlet entry
- Entry<String, HttpServlet> entry = it.next();
-
- // Servlet mapping
- String mapping = entry.getKey();
- HttpServlet servlet = entry.getValue();
-
- // Add new Servlet and Mapping to tomcat environment
- Tomcat.addServlet(rootCtx, ""+servlet.hashCode(), servlet);
- rootCtx.addServletMapping(mapping, ""+servlet.hashCode());
- }
- }
-
-
- /**
- * Run Method. Use .start() to start the server in a new thread to avoid blocking the main thread
- */
- public void run() {
- System.out.println("Starting Tomcat.....");
-
- try {
- tomcat.stop();
- tomcat.start();
- System.out.println("Started BaSyx HTTP Server!");
- tomcat.getServer().await();
-
-
- } catch (LifecycleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-
- /**
- * This Method stops and destroys the tomcat instance. This is important since Tomcat would be already
- * bound to port 8080 when new tests are run that require a start of tomcat
- */
- public void shutdown() {
- System.out.println("Shutting down BaSyx HTTP Server...");
-
- try {
- tomcat.stop();
- tomcat.destroy();
- } catch (LifecycleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServerResource.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServerResource.java
deleted file mode 100644
index 265d400..0000000
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/AASHTTPServerResource.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.basyx.regression.support.server;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.rules.ExternalResource;
-
-
-
-/**
- * This class initializes Tomcat Server and required servlets for all HTTP test classes in this project.
- * The factory pattern makes sure Tomcat is only started once and teared down after only after all tests have run.
- *
- * @author pschorn
- *
- */
-public class AASHTTPServerResource extends ExternalResource {
-
-
- /**
- * Active server references
- */
- //private static int refCount = 0;
- private static Map<Integer, Integer> refCount = new HashMap<>();
-
-
- /**
- * Server resource instance
- */
- private static AASHTTPServerResource currentInstance;
-
-
- /**
- * Tomcat server instance
- */
- private AASHTTPServer server;
-
-
- /**
- * Servlet context
- */
- protected BaSyxContext context = null;
-
-
-
-
-
- /**
- * Check if the active server context contains the given context
- */
- protected static boolean containsContext(BaSyxContext requestedContext) {
- // Check presence of all keys
- if (currentInstance.context.keySet().containsAll(requestedContext.keySet())) return true;
-
- // Active server does not contain requested context
- return false;
- }
-
-
- /**
- * Get a test server with a requested context
- *
- * @param requestedContext
- * @return
- */
- public static AASHTTPServerResource getTestResource(BaSyxContext requestedContext) {
- // Check if map contains requested port number
- if (!refCount.containsKey(requestedContext.getPort())) refCount.put(requestedContext.getPort(), 0);
-
- // Create server resource if no resource is active at the moment
- if (refCount.get(requestedContext.getPort()) == 0) {
- currentInstance = new AASHTTPServerResource(requestedContext);
- }
-
- // Check if running server conforms to requested context
- // - Check if server contains requested context
- if (containsContext(requestedContext));
-
- // Return instance
- return currentInstance;
- }
-
-
-
-
- /**
- * Constructor
- */
- private AASHTTPServerResource(BaSyxContext requestedContext) {
- // Store context reference
- context = requestedContext;
- }
-
-
- /**
- * Execute before a test case starts
- */
- public void before() {
- // Try to instantiate a new Tomcat server if refCounter is 0
- try {
- if (refCount.get(context.getPort()) == 0) {
- // Instantiate and start HTTP server
- server = new AASHTTPServer(context);
- server.start();
- }
- }
-
- // Always execute this block
- finally {
- // Increment reference counter
- refCount.put(context.getPort(), refCount.get(context.getPort())+1);
- }
- }
-
-
- /**
- * Execute after test case ends
- */
- public void after() {
- // Decrement reference counter
- refCount.put(context.getPort(), refCount.get(context.getPort())-1);
-
- // Shutdown server if reference counter reaches zero
- if (refCount.get(context.getPort()) == 0) {
- server.shutdown();
- }
- }
-}
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxStandaloneServer.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxStandaloneServer.java
index bc95807..b98245e 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxStandaloneServer.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxStandaloneServer.java
@@ -4,6 +4,9 @@
import java.io.IOException;
import java.io.InputStreamReader;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServer;
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
+
@@ -24,8 +27,8 @@
public static void main(String args[]) throws IOException {
// Start server and allocate resource
- AASHTTPServerResource resource = AASHTTPServerResource.getTestResource(new BaSyxContext("", ""));
- resource.before();
+ AASHTTPServer server = new AASHTTPServer(new BaSyxContext("", ""));
+ server.start();
// Prompt for user input
InputStreamReader in = new InputStreamReader(System.in);
@@ -36,7 +39,7 @@
while (true) {
String command = keyboard.readLine();
if (command.equals("Please stop tomcat")) {
- resource.after();
+ server.shutdown();
break;
} else {
System.out.println("Command " + command + " not recognized!");
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/context/ComponentsRegressionContext.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/context/ComponentsRegressionContext.java
index 9098960..2886f4b 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/context/ComponentsRegressionContext.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/context/ComponentsRegressionContext.java
@@ -6,7 +6,8 @@
import org.eclipse.basyx.components.servlets.SQLSubModelProviderServlet;
import org.eclipse.basyx.components.servlets.StaticCFGDirectoryServlet;
import org.eclipse.basyx.components.servlets.XMLXQueryServlet;
-import org.eclipse.basyx.regression.support.server.BaSyxContext;
+import org.eclipse.basyx.regression.support.processengine.servlet.CoilcarAASServlet;
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
@@ -40,6 +41,7 @@
addServletMapping("/Testsuite/components/BaSys/1.0/provider/xmlxquery/*", new XMLXQueryServlet().withParameter("config", "/WebContent/WEB-INF/config/xmlqueryprovider/xmlqueryprovider.properties"));
addServletMapping("/Testsuite/Directory/CFGFile/*", new StaticCFGDirectoryServlet().withParameter("config", "/WebContent/WEB-INF/config/directory/cfgdirectory/directory.properties"));
addServletMapping("/Testsuite/Directory/SQL/*", new SQLDirectoryServlet().withParameter("config", "/WebContent/WEB-INF/config/directory/sqldirectory/directory.properties"));
+ addServletMapping("/Testsuite/Processengine/coilcar/*", new CoilcarAASServlet());
}
}
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/xqueryprovider/tests/XQueryProviderQueries.java b/components/basys.components/src/test/java/org/eclipse/basyx/regression/xqueryprovider/tests/XQueryProviderQueries.java
index 194e926..f9ad2ea 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/xqueryprovider/tests/XQueryProviderQueries.java
+++ b/components/basys.components/src/test/java/org/eclipse/basyx/regression/xqueryprovider/tests/XQueryProviderQueries.java
@@ -2,8 +2,8 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.regression.support.directory.ComponentsTestsuiteDirectory;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
import org.eclipse.basyx.regression.support.server.context.ComponentsRegressionContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.eclipse.basyx.vab.core.proxy.VABElementProxy;
import org.junit.ClassRule;
@@ -29,7 +29,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource(new ComponentsRegressionContext());
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new ComponentsRegressionContext());
/**
* Test basic queries
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/deployment/BaSyxDeployment.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/deployment/BaSyxDeployment.java
index 49ad7c6..7fe8c65 100644
--- a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/deployment/BaSyxDeployment.java
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/deployment/BaSyxDeployment.java
@@ -3,9 +3,9 @@
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.basyx.regression.support.server.AASHTTPServerResource;
-import org.eclipse.basyx.regression.support.server.BaSyxContext;
import org.eclipse.basyx.sdk.api.service.BaSyxService;
+import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServer;
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
import org.junit.rules.ExternalResource;
@@ -25,12 +25,15 @@
*/
protected Object[] contextComponents = null;
-
/**
* Map runnable names to runnables
*/
protected Map<String, BaSyxService> contectRunnablesByName = new HashMap<>();
+ /**
+ * Deployment on HTTP server
+ */
+ private AASHTTPServer server;
@@ -67,9 +70,9 @@
// Process BaSyx context objects that run in a tomcat server
if (contextComponent instanceof BaSyxContext) {
// Get HTTP server resource
- AASHTTPServerResource resource = AASHTTPServerResource.getTestResource((BaSyxContext) contextComponent);
- // - Invoke 'before' operation that starts the server
- resource.before();
+ server = new AASHTTPServer((BaSyxContext) contextComponent);
+ // - Start the server
+ server.start();
// - Continue loop
continue;
}
@@ -98,10 +101,8 @@
for (Object contextComponent: contextComponents) {
// Process BaSyx context objects that run in a tomcat server
if (contextComponent instanceof BaSyxContext) {
- // Get HTTP server resource
- AASHTTPServerResource resource = AASHTTPServerResource.getTestResource((BaSyxContext) contextComponent);
- // - Invoke 'before' operation that starts the server
- resource.after();
+ // - Shutdown the server
+ server.shutdown();
// - Continue loop
continue;
}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory.java
index 101d986..ba38d7c 100644
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory.java
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory.java
@@ -2,7 +2,7 @@
import org.eclipse.basyx.components.servlets.RawCFGSubModelProviderServlet;
import org.eclipse.basyx.components.servlets.SQLDirectoryServlet;
-import org.eclipse.basyx.regression.support.server.BaSyxContext;
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
/**
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_Empty.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_Empty.java
index dbc040f..390e858 100644
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_Empty.java
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/contexts/BaSyxExamplesContext_Empty.java
@@ -1,7 +1,6 @@
package org.eclipse.basyx.examples.contexts;
-import org.eclipse.basyx.regression.support.server.BaSyxContext;
-
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
/**
* BaSyx context that contains no infrastructure
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/backend/http/TestAASHTTP.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/backend/http/TestAASHTTP.java
index f0b4d69..1af0ead 100644
--- a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/backend/http/TestAASHTTP.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/backend/http/TestAASHTTP.java
@@ -14,6 +14,7 @@
import org.eclipse.basyx.aas.backend.connector.http.HTTPConnectorProvider;
import org.eclipse.basyx.testsuite.support.backend.http.tools.stubs.servlets.StubAASServlet;
import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
+import org.eclipse.basyx.testsuite.support.backend.servers.context.SdkRegressionContext;
import org.eclipse.basyx.testsuite.support.vab.stub.DirectoryServiceStub;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.junit.Before;
@@ -35,7 +36,7 @@
* Makes sure Tomcat Server is started
*/
@ClassRule
- public static AASHTTPServerResource res = AASHTTPServerResource.getTestResource();
+ public static AASHTTPServerResource res = new AASHTTPServerResource(new SdkRegressionContext());
/**
* Creates the manager to be used in the test cases
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/vab/connector/TestVABHTTP.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/vab/connector/TestVABHTTP.java
index b943858..857e7e1 100644
--- a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/vab/connector/TestVABHTTP.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/vab/connector/TestVABHTTP.java
@@ -4,6 +4,7 @@
import org.eclipse.basyx.testsuite.regression.vab.provider.TestProvider;
import org.eclipse.basyx.testsuite.support.backend.common.stubs.java.directory.TestsuiteDirectory;
import org.eclipse.basyx.testsuite.support.backend.servers.AASHTTPServerResource;
+import org.eclipse.basyx.testsuite.support.backend.servers.context.SdkRegressionContext;
import org.eclipse.basyx.vab.core.VABConnectionManager;
import org.junit.Rule;
@@ -18,10 +19,10 @@
new HTTPConnectorProvider());
/**
- * Makes sure Tomcat Server is started
+ * Makes sure Tomcat Server is started after before each test case
*/
@Rule
- public AASHTTPServerResource res = AASHTTPServerResource.getTestResource();
+ public AASHTTPServerResource res = new AASHTTPServerResource(new SdkRegressionContext());
@Override
protected VABConnectionManager getConnectionManager() {
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServer.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServer.java
index 63887ba..1bef749 100644
--- a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServer.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServer.java
@@ -2,7 +2,6 @@
import java.io.File;
import java.util.Iterator;
-import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServlet;
@@ -13,38 +12,48 @@
/**
* Starter Class for Apache Tomcat 9.0.14 HTTP server that adds the provided servlets and respective mappings on startup.
+ *
* @author pschorn
- *
+ *
*/
public class AASHTTPServer extends Thread {
-
- Tomcat tomcat;
+ private Tomcat tomcat;
/**
* Constructor
*
* Create new Tomcat instance and add the provided servlet mappings
*
- * @param mappings hashmap of url mapping to HTTPServlet
+ * @param context
+ * Basyx context with of url mappings to HTTPServlet
*/
- public AASHTTPServer(Map<String, HttpServlet> mappings) {
+ public AASHTTPServer(BaSyxContext context) {
+ // Instantiate and setup Tomcat server
tomcat = new Tomcat();
- tomcat.setPort(8080);
- tomcat.setHostname("localhost");
+ tomcat.setPort(context.port);
+ tomcat.setHostname(context.hostname);
tomcat.getHost().setAppBase(".");
- File docBase = new File(System.getProperty("java.io.tmpdir"));
- Context rootCtx = tomcat.addContext("/basys.sdk", docBase.getAbsolutePath());
-
- Iterator<Entry<String, HttpServlet>> it = mappings.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, HttpServlet> entry = it.next();
- String mapping = entry.getKey();
- HttpServlet servlet = entry.getValue();
-
- // Add new Servlet and Mapping
- Tomcat.addServlet(rootCtx, servlet.getClass().getSimpleName(), servlet.getClass().getName());
- rootCtx.addServletMapping(mapping, servlet.getClass().getSimpleName());
- }
+
+ // Create servlet context
+ // - Base path for resource files
+ File docBase = new File(context.docBasePath); // System.getProperty("java.io.tmpdir"));
+ // - Create context for servlets
+ Context rootCtx = tomcat.addContext(context.contextPath, docBase.getAbsolutePath());
+
+ // Iterate all servlets in context
+ Iterator<Entry<String, HttpServlet>> it = context.entrySet().iterator();
+ while (it.hasNext()) {
+ // Servlet entry
+ Entry<String, HttpServlet> entry = it.next();
+
+ // Servlet mapping
+ String mapping = entry.getKey();
+ HttpServlet servlet = entry.getValue();
+
+ // Add new Servlet and Mapping to tomcat environment
+ Tomcat.addServlet(rootCtx, Integer.toString(servlet.hashCode()), servlet);
+ rootCtx.addServletMapping(mapping, Integer.toString(servlet.hashCode()));
+ }
}
/**
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServerResource.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServerResource.java
index 7a501ce..c669114 100644
--- a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServerResource.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/AASHTTPServerResource.java
@@ -1,60 +1,36 @@
package org.eclipse.basyx.testsuite.support.backend.servers;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServlet;
-
-import org.eclipse.basyx.testsuite.support.backend.http.tools.stubs.servlets.StubAASServlet;
-import org.eclipse.basyx.testsuite.support.vab.stub.servlet.SimpleVABElementServlet;
import org.junit.rules.ExternalResource;
/**
- * This class initializes Tomcat Server and required servlets for all HTTP test classes in this project.
- * The factory pattern makes sure Tomcat is only started once and teared down after only after all tests have run.
- * @author pschorn
+ * This class initializes Tomcat server and required servlets for all HTTP test classes in this project.
+ *
+ * @author espen
*
*/
public class AASHTTPServerResource extends ExternalResource {
- private static int refCount = 0;
+ private AASHTTPServer server;
+ private BaSyxContext context;
- private static AASHTTPServerResource currentInstance;
-
- private AASHTTPServer server;
-
- public static AASHTTPServerResource getTestResource () {
- if (refCount == 0) {
- currentInstance = new AASHTTPServerResource();
- }
- return currentInstance;
+ /**
+ * Constructor taking the context of the requested server resource
+ */
+ public AASHTTPServerResource(BaSyxContext context) {
+ this.context = context;
}
+ /**
+ * Create a new AASHTTPServer before a test case runs
+ */
protected void before() {
- try {
- if (refCount == 0) {
- System.out.println("Do actual TestResources init");
-
- Map<String, HttpServlet> servlets = new HashMap<String, HttpServlet>();
- servlets.put("/Testsuite/SimpleVAB/*", new SimpleVABElementServlet());
- servlets.put("/Testsuite/StubAAS/*", new StubAASServlet());
-
- server = new AASHTTPServer(servlets);
- server.start();
-
- }
- }
- finally {
- refCount++;
- }
+ server = new AASHTTPServer(context);
+ server.start();
}
+ /**
+ * Shutdown the created server after a test case
+ */
protected void after() {
- System.out.println("TestResources after");
- refCount--;
- if (refCount == 0) {
- System.out.println("Do actual TestResources destroy");
-
- server.shutdown();
- }
+ server.shutdown();
}
}
\ No newline at end of file
diff --git a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxContext.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/BaSyxContext.java
similarity index 97%
rename from components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxContext.java
rename to sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/BaSyxContext.java
index 712af7d..5c63a31 100644
--- a/components/basys.components/src/test/java/org/eclipse/basyx/regression/support/server/BaSyxContext.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/BaSyxContext.java
@@ -1,4 +1,4 @@
-package org.eclipse.basyx.regression.support.server;
+package org.eclipse.basyx.testsuite.support.backend.servers;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/context/SdkRegressionContext.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/context/SdkRegressionContext.java
new file mode 100644
index 0000000..3f962c6
--- /dev/null
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/support/backend/servers/context/SdkRegressionContext.java
@@ -0,0 +1,23 @@
+package org.eclipse.basyx.testsuite.support.backend.servers.context;
+
+import org.eclipse.basyx.testsuite.support.backend.http.tools.stubs.servlets.StubAASServlet;
+import org.eclipse.basyx.testsuite.support.backend.servers.BaSyxContext;
+import org.eclipse.basyx.testsuite.support.vab.stub.servlet.SimpleVABElementServlet;
+
+/**
+ * BaSyx context that contains servlets with a simple VAB object and a simple AAS for regression testing of basys.sdk
+ * package
+ *
+ * @author espen
+ *
+ */
+public class SdkRegressionContext extends BaSyxContext {
+ private static final long serialVersionUID = 4670203024510994828L;
+
+ public SdkRegressionContext() {
+ super("/basys.sdk", System.getProperty("java.io.tmpdir"));
+
+ addServletMapping("/Testsuite/SimpleVAB/*", new SimpleVABElementServlet());
+ addServletMapping("/Testsuite/StubAAS/*", new StubAASServlet());
+ }
+}