diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/ObserverUpdateTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/ObserverUpdateTest.java index 9c145f6ec..b2542bf34 100644 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/ObserverUpdateTest.java +++ b/src/test/java/li/strolch/persistence/postgresql/dao/test/ObserverUpdateTest.java @@ -19,6 +19,7 @@ import static li.strolch.model.ModelGenerator.createOrder; import static li.strolch.model.ModelGenerator.createResource; import static org.junit.Assert.assertEquals; +import java.io.File; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -33,14 +34,42 @@ import li.strolch.persistence.api.ModificationResult; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.runtime.observer.Observer; import li.strolch.runtime.observer.ObserverHandler; +import li.strolch.testbase.runtime.RuntimeMock; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; /** * @author Robert von Burg - * */ -public class ObserverUpdateTest extends AbstractDaoImplTest { +public class ObserverUpdateTest { + + public static final String RUNTIME_PATH = "target/strolchRuntime/"; //$NON-NLS-1$ + public static final String DB_STORE_PATH_DIR = "dbStore"; //$NON-NLS-1$ + public static final String CONFIG_SRC = "src/test/resources/runtime/config"; //$NON-NLS-1$ + + protected static RuntimeMock runtimeMock; + + protected RuntimeMock getRuntimeMock() { + return runtimeMock; + } + + @BeforeClass + public static void beforeClass() { + + File rootPath = new File(RUNTIME_PATH); + File configSrc = new File(CONFIG_SRC); + runtimeMock = new RuntimeMock(); + runtimeMock.mockRuntime(rootPath, configSrc); + new File(rootPath, DB_STORE_PATH_DIR).mkdir(); + runtimeMock.startContainer(rootPath); + } + + @AfterClass + public static void afterClass() { + runtimeMock.destroyRuntime(); + } public final class ElementAddedObserver implements Observer { diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlOrderDaoTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlOrderDaoTest.java deleted file mode 100644 index 89bda1f39..000000000 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlOrderDaoTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013 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.persistence.postgresql.dao.test; - -import li.strolch.testbase.runtime.OrderModelTestRunner; - -import org.junit.Test; - -public class PostgreSqlOrderDaoTest extends AbstractDaoImplTest { - - @Test - public void shouldCreateOrder() { - - OrderModelTestRunner testRunner = new OrderModelTestRunner(runtimeMock); - testRunner.runCreateOrderTest(); - } - - @Test - public void shouldCrud() { - - OrderModelTestRunner testRunner = new OrderModelTestRunner(runtimeMock); - testRunner.runCrudTests(); - } - - @Test - public void shouldPerformBulkOperations() { - - OrderModelTestRunner testRunner = new OrderModelTestRunner(runtimeMock); - testRunner.runBulkOperationTests(); - } -} diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlResourceDaoTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlResourceDaoTest.java deleted file mode 100644 index 695220574..000000000 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgreSqlResourceDaoTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013 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.persistence.postgresql.dao.test; - -import li.strolch.testbase.runtime.ResourceModelTestRunner; - -import org.junit.Test; - -public class PostgreSqlResourceDaoTest extends AbstractDaoImplTest { - - @Test - public void shouldCreateOrder() { - - ResourceModelTestRunner testRunner = new ResourceModelTestRunner(runtimeMock); - testRunner.runCreateResourceTest(); - } - - @Test - public void shouldCrud() { - - ResourceModelTestRunner testRunner = new ResourceModelTestRunner(runtimeMock); - testRunner.runCrudTests(); - } - - @Test - public void shouldPerformBulkOperations() { - - ResourceModelTestRunner testRunner = new ResourceModelTestRunner(runtimeMock); - testRunner.runBulkOperationTests(); - } -} diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgresqlContainerTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgresqlContainerTest.java deleted file mode 100644 index 6b5b99d58..000000000 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/PostgresqlContainerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2013 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.persistence.postgresql.dao.test; - -import java.io.File; -import java.sql.SQLException; - -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.testbase.runtime.RuntimeMock; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * @author Robert von Burg - */ -public class PostgresqlContainerTest { - - private static RuntimeMock runtimeMock; - - @BeforeClass - public static void beforeClass() throws SQLException { - - File rootPath = new File(AbstractDaoImplTest.RUNTIME_PATH); - File configSrc = new File(AbstractDaoImplTest.CONFIG_SRC); - runtimeMock = new RuntimeMock(); - runtimeMock.mockRuntime(rootPath, configSrc); - new File(rootPath, AbstractDaoImplTest.DB_STORE_PATH_DIR).mkdir(); - runtimeMock.startContainer(rootPath); - } - - @Test - public void shouldStartContainer() { - try (StrolchTransaction tx = runtimeMock.getPersistenceHandler().openTx()) { - tx.getOrderDao().queryKeySet(); - } - } - - @AfterClass - public static void afterClass() { - runtimeMock.destroyRuntime(); - } -} diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/XmlCachedDaoTest.java similarity index 92% rename from src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java rename to src/test/java/li/strolch/persistence/postgresql/dao/test/XmlCachedDaoTest.java index 897c65d64..70389ca86 100644 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java +++ b/src/test/java/li/strolch/persistence/postgresql/dao/test/XmlCachedDaoTest.java @@ -21,15 +21,13 @@ import java.sql.DriverManager; import java.sql.SQLException; import li.strolch.persistence.postgresql.DbSchemaVersionCheck; +import li.strolch.testbase.runtime.AbstractModelTest; import li.strolch.testbase.runtime.RuntimeMock; import org.junit.AfterClass; import org.junit.BeforeClass; -/** - * @author Robert von Burg - */ -public abstract class AbstractDaoImplTest { +public class XmlCachedDaoTest extends AbstractModelTest { public static final String RUNTIME_PATH = "target/strolchRuntime/"; //$NON-NLS-1$ public static final String DB_STORE_PATH_DIR = "dbStore"; //$NON-NLS-1$ @@ -40,6 +38,11 @@ public abstract class AbstractDaoImplTest { private static final String DB_PASSWORD = "test"; //$NON-NLS-1$ protected static RuntimeMock runtimeMock; + + @Override + protected RuntimeMock getRuntimeMock() { + return runtimeMock; + } @BeforeClass public static void beforeClass() throws SQLException {