From 060653a811c00b7828f58f13d2542bbc1267f7a4 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Thu, 11 Dec 2014 15:02:38 +0000 Subject: [PATCH] SSDM-1286 : QGF: Setup of automatic testing of dropboxes - control database kind SVN: 33034 --- .../systemtests/GenericSystemTest.java | 13 +++++++- .../cisd/dsu/dss/systemtests/DSUContants.java | 27 +++++++++++++++ .../dss/systemtests/DSUDropboxSystemTest.java | 33 +++++++++++++++++++ .../dsu/dss/systemtests/DSUSystemTest.java | 33 +++++++++++++++++++ .../dsu/dss/systemtests/DemoDropboxTest.java | 20 ++--------- .../generic/server/util/TestInitializer.java | 18 ++++++++-- 6 files changed, 122 insertions(+), 22 deletions(-) create mode 100644 deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUContants.java create mode 100644 deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUDropboxSystemTest.java create mode 100644 deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUSystemTest.java diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/GenericSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/GenericSystemTest.java index a8e36a631a5..5ecf38a9773 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/GenericSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/GenericSystemTest.java @@ -28,11 +28,22 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService public class GenericSystemTest extends SystemTestCase { + protected String getDBScriptFolder() + { + return "sourceTest"; + } + + protected String getDBKind() + { + return "test"; + } + @Override @BeforeSuite public void beforeSuite() throws Exception { - System.setProperty(TestInitializer.getScriptFolderTestDBPropertyName(), "sourceTest"); + System.setProperty(TestInitializer.getScriptFolderTestDBPropertyName(), getDBScriptFolder()); + System.setProperty(TestInitializer.getDBKindPropertyName(), getDBKind()); super.beforeSuite(); } diff --git a/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUContants.java b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUContants.java new file mode 100644 index 00000000000..d5eaf3925cc --- /dev/null +++ b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUContants.java @@ -0,0 +1,27 @@ +/* + * Copyright 2014 ETH Zuerich, CISD + * + * 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 ch.ethz.bsse.cisd.dsu.dss.systemtests; + +/** + * @author pkupczyk + */ +public class DSUContants +{ + + public static final String DB_KIND = "test_deep_sequencing_unit"; + +} diff --git a/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUDropboxSystemTest.java b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUDropboxSystemTest.java new file mode 100644 index 00000000000..4d02d819ff7 --- /dev/null +++ b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUDropboxSystemTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2014 ETH Zuerich, CISD + * + * 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 ch.ethz.bsse.cisd.dsu.dss.systemtests; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.GenericDropboxSystemTest; + +/** + * @author pkupczyk + */ +public abstract class DSUDropboxSystemTest extends GenericDropboxSystemTest +{ + + @Override + protected String getDBKind() + { + return DSUContants.DB_KIND; + } + +} diff --git a/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUSystemTest.java b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUSystemTest.java new file mode 100644 index 00000000000..446c89e3f9b --- /dev/null +++ b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DSUSystemTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2014 ETH Zuerich, CISD + * + * 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 ch.ethz.bsse.cisd.dsu.dss.systemtests; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.GenericSystemTest; + +/** + * @author pkupczyk + */ +public class DSUSystemTest extends GenericSystemTest +{ + + @Override + protected String getDBKind() + { + return DSUContants.DB_KIND; + } + +} diff --git a/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DemoDropboxTest.java b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DemoDropboxTest.java index 8db8078c34a..a0506f6df0c 100644 --- a/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DemoDropboxTest.java +++ b/deep_sequencing_unit/sourceTest/java/ch/ethz/bsse/cisd/dsu/dss/systemtests/DemoDropboxTest.java @@ -21,7 +21,6 @@ import java.util.List; import org.testng.Assert; import org.testng.annotations.Test; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.GenericDropboxSystemTest; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; @@ -31,7 +30,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; /** * @author pkupczyk */ -public class DemoDropboxTest extends GenericDropboxSystemTest +public class DemoDropboxTest extends DSUDropboxSystemTest { @Override @@ -47,7 +46,7 @@ public class DemoDropboxTest extends GenericDropboxSystemTest } @Test - public void testDropbox1() throws Exception + public void testDropbox() throws Exception { importData("demo-data"); waitUntilDataImported(); @@ -62,19 +61,4 @@ public class DemoDropboxTest extends GenericDropboxSystemTest Assert.assertEquals(experiments.size(), 2); } - @Test(enabled = false) - public void testDropbox2() throws Exception - { - // WARNING: this test fails and shows that transaction is not rolled back after testDropbox1 is executed - // (the newly created experiments still exist) - - String sessionToken = getGeneralInformationService().tryToAuthenticateForAllServices("test", "password"); - - SearchCriteria criteria = new SearchCriteria(); - criteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, "DEMO-EXPERIMENT*")); - - List<Experiment> experiments = getGeneralInformationService().searchForExperiments(sessionToken, criteria); - Assert.assertEquals(experiments.size(), 0); - } - } \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/util/TestInitializer.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/util/TestInitializer.java index a275df78840..e3bb4b93c43 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/util/TestInitializer.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/util/TestInitializer.java @@ -51,10 +51,14 @@ public class TestInitializer private static final String LUCENE_INDEX_PATH = "targets/lucene/indices"; + private static final String DB_KIND_PROPERTY_NAME = "dbKind"; + private static final String SCRIPT_FOLDER_TEST_DB_PROPERTY_NAME = "scriptFolderTestDB"; private static final String SCRIPT_FOLDER_EMPTY_DB_PROPERTY_NAME = "scriptFolderEmptyDB"; + private static final String DEFAULT_DB_KIND = "test"; + private static final String DEFAULT_SCRIPT_FOLDER_TEST_DB = "../openbis/sourceTest"; private static final String DEFAULT_SCRIPT_FOLDER_EMPTY_DB = "../openbis/source"; @@ -141,10 +145,8 @@ public class TestInitializer // and in the right place when we run tests restoreSearchIndex(); - String projectName = System.getProperty("ant.project.name", ""); - System.setProperty("database.create-from-scratch", "true"); - System.setProperty("database.kind", projectName.isEmpty() ? "test" : "test_" + projectName); + System.setProperty("database.kind", getDBKind()); System.setProperty("script-folder", scriptFolder); System.setProperty("hibernate.search.index-mode", hibernateIndexMode.name()); System.setProperty("hibernate.search.index-base", LUCENE_INDEX_PATH); @@ -177,6 +179,11 @@ public class TestInitializer } } + public static String getDBKindPropertyName() + { + return TestInitializer.class.getName() + "." + DB_KIND_PROPERTY_NAME; + } + public static String getScriptFolderTestDBPropertyName() { return TestInitializer.class.getName() + "." + SCRIPT_FOLDER_TEST_DB_PROPERTY_NAME; @@ -187,6 +194,11 @@ public class TestInitializer return TestInitializer.class.getName() + "." + SCRIPT_FOLDER_EMPTY_DB_PROPERTY_NAME; } + private static String getDBKind() + { + return getSystemProperty(getDBKindPropertyName(), DEFAULT_DB_KIND); + } + private static String getScriptFolderTestDB() { return getSystemProperty(getScriptFolderTestDBPropertyName(), DEFAULT_SCRIPT_FOLDER_TEST_DB); -- GitLab