From fbf3e8b0eb40537983cae0e18109ca55550184d6 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Thu, 17 Dec 2015 13:14:16 +0000 Subject: [PATCH] SSDM-2718: system tests for the new type of service SVN: 35365 --- .../core-plugins/core-plugins.properties | 1 + .../services/simple-service/plugin.properties | 2 + .../1/as/services/simple-service/script.py | 9 ++++ .../systemtest/api/v3/ExecuteServiceTest.java | 47 +++++++++++++++++++ .../systemtest/api/v3/SearchServiceTest.java | 46 ++++++++++++++++++ .../openbis/systemtest/SystemTestCase.java | 4 ++ 6 files changed, 109 insertions(+) create mode 100644 openbis/sourceTest/core-plugins/core-plugins.properties create mode 100644 openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/plugin.properties create mode 100644 openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/script.py create mode 100644 openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/ExecuteServiceTest.java create mode 100644 openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/SearchServiceTest.java diff --git a/openbis/sourceTest/core-plugins/core-plugins.properties b/openbis/sourceTest/core-plugins/core-plugins.properties new file mode 100644 index 00000000000..e8b0439d692 --- /dev/null +++ b/openbis/sourceTest/core-plugins/core-plugins.properties @@ -0,0 +1 @@ +enabled-modules = test-.* diff --git a/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/plugin.properties b/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/plugin.properties new file mode 100644 index 00000000000..34ac1313436 --- /dev/null +++ b/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/plugin.properties @@ -0,0 +1,2 @@ +class = ch.ethz.sis.openbis.generic.server.api.v3.helper.service.JythonBasedServiceExecutor +script-path = script.py diff --git a/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/script.py b/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/script.py new file mode 100644 index 00000000000..d63a0074fb9 --- /dev/null +++ b/openbis/sourceTest/core-plugins/test-v3api-services/1/as/services/simple-service/script.py @@ -0,0 +1,9 @@ +from ch.ethz.sis.openbis.generic.as.api.v3.dto.space.fetchoptions import SpaceFetchOptions +from ch.ethz.sis.openbis.generic.as.api.v3.dto.space.search import SpaceSearchCriteria + +def process(parameters): + name = parameters.get("name"); + searchCriteria = SpaceSearchCriteria(); + searchCriteria.withCode().thatEquals("CISD"); + result = applicationService.searchSpaces(sessionToken, searchCriteria, SpaceFetchOptions()); + return "hello %s. Services: %s" % (name, result.objects) diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/ExecuteServiceTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/ExecuteServiceTest.java new file mode 100644 index 00000000000..55f81e4cf05 --- /dev/null +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/ExecuteServiceTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2015 ETH Zuerich, SIS + * + * 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.sis.openbis.systemtest.api.v3; + +import static org.testng.Assert.assertEquals; + +import java.io.Serializable; + +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.ServiceCode; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class ExecuteServiceTest extends AbstractTest +{ + @Test + public void testSearchServices() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + ExecutionOptions options = new ExecutionOptions(); + options.withParameter("name", Math.PI); + + Serializable result = v3api.executeService(sessionToken, new ServiceCode("simple-service"), options); + + assertEquals(result, "hello 3.14159265359. Services: [Space CISD]"); + } + +} diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/SearchServiceTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/SearchServiceTest.java new file mode 100644 index 00000000000..8405a294477 --- /dev/null +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/SearchServiceTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015 ETH Zuerich, SIS + * + * 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.sis.openbis.systemtest.api.v3; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.as.api.v3.dto.common.search.SearchResult; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.fetchoptions.ServiceFetchOptions; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.search.ServiceSearchCriteria; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class SearchServiceTest extends AbstractTest +{ + + @Test + public void testSearchServices() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + SearchResult<Service> result = v3api.searchServices(sessionToken, new ServiceSearchCriteria(), new ServiceFetchOptions()); + + assertEquals(result.getTotalCount(), 1); + } + +} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/SystemTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/SystemTestCase.java index dacb345be4e..adb474afb0c 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/SystemTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/SystemTestCase.java @@ -64,6 +64,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy.RoleC import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.PropertyBuilder; +import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginsUtils; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientService; import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; @@ -79,6 +80,8 @@ import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; @TransactionConfiguration(transactionManager = "transaction-manager") public abstract class SystemTestCase extends AbstractTransactionalTestNGSpringContextTests { + private static final String SOURCE_TEST_CORE_PLUGINS = "sourceTest/core-plugins"; + protected static final String SESSION_KEY = "session-key"; protected ICommonServerForInternalUse commonServer; @@ -98,6 +101,7 @@ public abstract class SystemTestCase extends AbstractTransactionalTestNGSpringCo @BeforeSuite public void beforeSuite() { + System.setProperty(CorePluginsUtils.CORE_PLUGINS_FOLDER_KEY, SOURCE_TEST_CORE_PLUGINS); TestInitializer.init(); } -- GitLab