From c96465fcc630835838d890a7e634bd7af6aa4b07 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 1 Feb 2017 18:56:43 +0100 Subject: [PATCH] [New] Added transient perf test --- .../config/PrivilegeConfig.xml | 33 +++++++++ .../config/PrivilegeRoles.xml | 17 +++++ .../config/PrivilegeUsers.xml | 21 ++++++ .../config/StrolchConfiguration.xml | 48 +++++++++++++ .../performance/PerformanceTransientTest.java | 72 +++++++++++++++++++ 5 files changed, 191 insertions(+) create mode 100644 li.strolch.performancetest/src/runtime_transient/config/PrivilegeConfig.xml create mode 100644 li.strolch.performancetest/src/runtime_transient/config/PrivilegeRoles.xml create mode 100644 li.strolch.performancetest/src/runtime_transient/config/PrivilegeUsers.xml create mode 100644 li.strolch.performancetest/src/runtime_transient/config/StrolchConfiguration.xml create mode 100644 li.strolch.performancetest/src/test/java/li/strolch/performance/PerformanceTransientTest.java diff --git a/li.strolch.performancetest/src/runtime_transient/config/PrivilegeConfig.xml b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeConfig.xml new file mode 100644 index 000000000..9793f19b8 --- /dev/null +++ b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeConfig.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.performancetest/src/runtime_transient/config/PrivilegeRoles.xml b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeRoles.xml new file mode 100644 index 000000000..78a1d851e --- /dev/null +++ b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeRoles.xml @@ -0,0 +1,17 @@ + + + + + li.strolch.runtime.privilege.StrolchSystemAction + li.strolch.runtime.privilege.StrolchSystemActionWithResult + + + + + true + + + true + + + diff --git a/li.strolch.performancetest/src/runtime_transient/config/PrivilegeUsers.xml b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeUsers.xml new file mode 100644 index 000000000..61cb01b8f --- /dev/null +++ b/li.strolch.performancetest/src/runtime_transient/config/PrivilegeUsers.xml @@ -0,0 +1,21 @@ + + + + SYSTEM + + agent + + + + Application + Administrator + ENABLED + en_GB + + AppUser + + + + + + diff --git a/li.strolch.performancetest/src/runtime_transient/config/StrolchConfiguration.xml b/li.strolch.performancetest/src/runtime_transient/config/StrolchConfiguration.xml new file mode 100644 index 000000000..743569d45 --- /dev/null +++ b/li.strolch.performancetest/src/runtime_transient/config/StrolchConfiguration.xml @@ -0,0 +1,48 @@ + + + + + minimal + + en + true + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PrivilegeHandler + + + transient + + EMPTY + + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + false + + + + diff --git a/li.strolch.performancetest/src/test/java/li/strolch/performance/PerformanceTransientTest.java b/li.strolch.performancetest/src/test/java/li/strolch/performance/PerformanceTransientTest.java new file mode 100644 index 000000000..9dc24eea1 --- /dev/null +++ b/li.strolch.performancetest/src/test/java/li/strolch/performance/PerformanceTransientTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2015 Robert von Burg + * + * Licensed 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 li.strolch.performance; + +import java.io.File; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.postgresql.Driver; + +import li.strolch.privilege.model.Certificate; +import li.strolch.service.api.ServiceHandler; +import li.strolch.testbase.runtime.RuntimeMock; +import li.strolch.utils.helper.FileHelper; + +/** + * @author Robert von Burg + */ +public class PerformanceTransientTest { + + public static final String RUNTIME_PATH = "target/runtime_transient_test/"; //$NON-NLS-1$ + public static final String CONFIG_SRC = "src/runtime_transient"; //$NON-NLS-1$ + + protected static RuntimeMock runtimeMock; + + @BeforeClass + public static void beforeClass() throws Exception { + + File rootPath = new File(RUNTIME_PATH); + File configSrc = new File(CONFIG_SRC); + runtimeMock = new RuntimeMock(); + runtimeMock.mockRuntime(rootPath, configSrc); + runtimeMock.startContainer(); + } + + @Test + public void runPerformanceTest() { + + Certificate certificate = runtimeMock.getPrivilegeHandler().authenticate("transient", "test".getBytes()); + + ServiceHandler svcHandler = runtimeMock.getServiceHandler(); + svcHandler.doService(certificate, new PerformanceTestService(), new PerformanceTestArgument()); + } + + @AfterClass + public static void afterClass() throws Exception { + if (runtimeMock != null) + runtimeMock.destroyRuntime(); + + File rootPath = new File(RUNTIME_PATH); + if (rootPath.exists()) { + FileHelper.deleteFile(rootPath, false); + } + + if (Driver.isRegistered()) + Driver.deregister(); + } +}