diff --git a/pom.xml b/pom.xml
index c9472cf..40313f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,6 @@
ch.qos.logback
logback-classic
${logback.version}
- runtime
diff --git a/src/main/java/li/strolch/bookshop/web/StartupListener.java b/src/main/java/li/strolch/bookshop/web/StartupListener.java
index ef1be76..fa3adce 100644
--- a/src/main/java/li/strolch/bookshop/web/StartupListener.java
+++ b/src/main/java/li/strolch/bookshop/web/StartupListener.java
@@ -5,11 +5,15 @@ import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.io.InputStream;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.util.ContextInitializer;
import li.strolch.agent.api.StrolchAgent;
import li.strolch.agent.api.StrolchBootstrapper;
+import li.strolch.rest.RestfulStrolchComponent;
import li.strolch.utils.helper.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.impl.StaticLoggerBinder;
@WebListener
public class StartupListener implements ServletContextListener {
@@ -25,12 +29,13 @@ public class StartupListener implements ServletContextListener {
logger.info("Starting " + APP_NAME + "...");
long start = System.currentTimeMillis();
try {
- String boostrapFileName = "/WEB-INF/" + StrolchBootstrapper.FILE_BOOTSTRAP;
- InputStream bootstrapFile = sce.getServletContext().getResourceAsStream(boostrapFileName);
+ String bootstrapFileName = "/" + StrolchBootstrapper.FILE_BOOTSTRAP;
+ InputStream bootstrapFile = getClass().getResourceAsStream(bootstrapFileName);
StrolchBootstrapper bootstrapper = new StrolchBootstrapper(StartupListener.class);
- this.agent = bootstrapper.setupByBoostrapFile(StartupListener.class, bootstrapFile);
+ this.agent = bootstrapper.setupByBootstrapFile(StartupListener.class, bootstrapFile);
this.agent.initialize();
this.agent.start();
+ RestfulStrolchComponent.getInstance().setWebPath(sce.getServletContext().getRealPath("/"));
} catch (Throwable e) {
logger.error("Failed to start " + APP_NAME + " due to: " + e.getMessage(), e);
throw e;
@@ -42,6 +47,13 @@ public class StartupListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sce) {
+ try {
+ new ContextInitializer((LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory()).autoConfig();
+ } catch (Exception e) {
+ System.err.println("Failed to reconfigure logging...");
+ e.printStackTrace(System.err);
+ }
+
if (this.agent != null) {
logger.info("Destroying " + APP_NAME + "...");
try {
diff --git a/src/test/java/li/strolch/bookshop/test/BookshopStartTest.java b/src/test/java/li/strolch/bookshop/test/BookshopStartTest.java
new file mode 100644
index 0000000..0de60df
--- /dev/null
+++ b/src/test/java/li/strolch/bookshop/test/BookshopStartTest.java
@@ -0,0 +1,38 @@
+package li.strolch.bookshop.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import li.strolch.privilege.model.Certificate;
+import li.strolch.testbase.runtime.RuntimeMock;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class BookshopStartTest {
+
+ private static final String TARGET_PATH = "target/" + BookshopStartTest.class.getSimpleName();
+ private static final String SOURCE_PATH = "src/test/resources/runtime";
+
+ private static RuntimeMock runtimeMock;
+ private static Certificate cert;
+
+ @BeforeClass
+ public static void beforeClass() {
+ runtimeMock = new RuntimeMock().mockRuntime(TARGET_PATH, SOURCE_PATH);
+ runtimeMock.startContainer();
+ cert = runtimeMock.getPrivilegeHandler().authenticate("test", "test".toCharArray());
+ }
+
+ @AfterClass
+ public static void afterClass(){
+ runtimeMock.destroyRuntime();
+ }
+
+ @Test
+ public void shouldStartApp() {
+
+ assertNotNull(cert);
+ assertEquals("test", cert.getUsername());
+ }
+}
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..fcc71f0
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ %d [%thread] %-5level %class{36}:%line %method - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/runtime/config/PrivilegeConfig.xml b/src/test/resources/runtime/config/PrivilegeConfig.xml
new file mode 100644
index 0000000..52154d4
--- /dev/null
+++ b/src/test/resources/runtime/config/PrivilegeConfig.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/runtime/config/PrivilegeRoles.xml b/src/test/resources/runtime/config/PrivilegeRoles.xml
new file mode 100644
index 0000000..d5d642e
--- /dev/null
+++ b/src/test/resources/runtime/config/PrivilegeRoles.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ li.strolch.runtime.privilege.StrolchSystemAction
+ li.strolch.runtime.privilege.StrolchSystemActionWithResult
+
+
+ Persist
+ PersistSessions
+ GetCertificates
+
+
+
+
+
+ true
+
+
+ true
+
+
+
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+
diff --git a/src/test/resources/runtime/config/PrivilegeUsers.xml b/src/test/resources/runtime/config/PrivilegeUsers.xml
new file mode 100644
index 0000000..661b3e5
--- /dev/null
+++ b/src/test/resources/runtime/config/PrivilegeUsers.xml
@@ -0,0 +1,21 @@
+
+
+
+ SYSTEM
+
+ agent
+ ModelAccessor
+
+
+
+
+ Application
+ Administrator
+ ENABLED
+ en-GB
+
+ AppUser
+ ModelAccessor
+
+
+
diff --git a/src/test/resources/runtime/config/StrolchConfiguration.xml b/src/test/resources/runtime/config/StrolchConfiguration.xml
new file mode 100644
index 0000000..172f23d
--- /dev/null
+++ b/src/test/resources/runtime/config/StrolchConfiguration.xml
@@ -0,0 +1,54 @@
+
+
+
+
+ Bookshop
+
+ en
+ true
+
+
+
+
+ PrivilegeHandler
+ li.strolch.runtime.privilege.PrivilegeHandler
+ li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler
+
+
+
+ RealmHandler
+ li.strolch.agent.api.RealmHandler
+ li.strolch.agent.impl.DefaultRealmHandler
+ PrivilegeHandler
+
+ TRANSIENT
+ defaultModel.xml
+ true
+
+
+
+
+ ServiceHandler
+ li.strolch.service.api.ServiceHandler
+ li.strolch.service.api.DefaultServiceHandler
+ RealmHandler
+ PrivilegeHandler
+
+ true
+
+
+
+
+ PolicyHandler
+ li.strolch.policy.PolicyHandler
+ li.strolch.policy.DefaultPolicyHandler
+
+
+
+ SessionHandler
+ li.strolch.rest.StrolchSessionHandler
+ li.strolch.rest.DefaultStrolchSessionHandler
+ PrivilegeHandler
+
+
+
diff --git a/src/test/resources/runtime/config/StrolchPolicies.xml b/src/test/resources/runtime/config/StrolchPolicies.xml
new file mode 100644
index 0000000..cba3b97
--- /dev/null
+++ b/src/test/resources/runtime/config/StrolchPolicies.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/runtime/data/defaultModel.xml b/src/test/resources/runtime/data/defaultModel.xml
new file mode 100644
index 0000000..46e859f
--- /dev/null
+++ b/src/test/resources/runtime/data/defaultModel.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/runtime/temp/.gitignore b/src/test/resources/runtime/temp/.gitignore
new file mode 100644
index 0000000..b44d1af
--- /dev/null
+++ b/src/test/resources/runtime/temp/.gitignore
@@ -0,0 +1,2 @@
+/sessions.dat
+users.csv
\ No newline at end of file