From 1767ed8178cbd1eb0a7576e98752248fd736f328 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk@ethz.ch> Date: Wed, 29 May 2024 15:08:35 +0200 Subject: [PATCH] BIS-736 : external data table for AFS : fix tests --- .../openbis/generic/server/AfsRegistrator.java | 18 +++++++++++++----- .../source/java/service.properties | 2 +- .../asapi/v3/SearchDataStoreTest.java | 2 +- .../openbis/systemtest/CommonServerTest.java | 6 ++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/AfsRegistrator.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/AfsRegistrator.java index a301c29f25b..fff034c4d26 100644 --- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/AfsRegistrator.java +++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/AfsRegistrator.java @@ -37,6 +37,8 @@ public class AfsRegistrator implements IAfsRegistrator, ApplicationListener<Appl @Autowired IAfsRegistrator self; + private boolean registered; + @Override public void onApplicationEvent(final ApplicationEvent event) { Object source = event.getSource(); @@ -45,11 +47,8 @@ public class AfsRegistrator implements IAfsRegistrator, ApplicationListener<Appl AbstractApplicationContext appContext = (AbstractApplicationContext) source; if ((event instanceof ContextStartedEvent) || (event instanceof ContextRefreshedEvent)) { - if (appContext.getParent() != null) - { - // call the bean with transaction support - self.registerAfs(); - } + // call the bean with transaction support + self.registerAfs(); } } } @@ -57,6 +56,15 @@ public class AfsRegistrator implements IAfsRegistrator, ApplicationListener<Appl @Transactional public void registerAfs() { + synchronized (this) + { + if (registered) + { + return; + } + registered = true; + } + IDataStoreDAO dataStoreDAO = daoFactory.getDataStoreDAO(); DataStorePE existingDataStore = dataStoreDAO.tryToFindDataStoreByCode(AFS_DATA_STORE_CODE); diff --git a/server-application-server/source/java/service.properties b/server-application-server/source/java/service.properties index 716c82e0747..2dd7a5a6b6a 100644 --- a/server-application-server/source/java/service.properties +++ b/server-application-server/source/java/service.properties @@ -75,7 +75,7 @@ crowd.application.password = # The database instance local unique identifier. Used when the new database is created. database-instance = CISD -dss-rpc.put.dss-code = DSS1 +dss-rpc.put.dss-code = STANDARD openbis.support.email=openbis-support@id.ethz.ch trusted-cross-origin-domains= * diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataStoreTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataStoreTest.java index 7fa622f69f6..f1fbe438658 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataStoreTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/SearchDataStoreTest.java @@ -35,7 +35,7 @@ public class SearchDataStoreTest extends AbstractTest @Test public void testSearchWithEmptyCriteria() { - testSearch(TEST_USER, new DataStoreSearchCriteria(), "STANDARD"); + testSearch(TEST_USER, new DataStoreSearchCriteria(), "AFS", "STANDARD"); } @Test diff --git a/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java b/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java index 9a71dfdb826..4b295e8652c 100644 --- a/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java +++ b/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java @@ -3549,8 +3549,10 @@ public class CommonServerTest extends SystemTestCase if (user.isInstanceUserOrSpaceUserOrEnabledProjectUser()) { List<DataStore> stores = commonServer.listDataStores(session.getSessionToken()); - assertEquals(stores.size(), 1); - assertEquals(stores.get(0).getCode(), "STANDARD"); + stores.sort(Comparator.comparing(DataStore::getCode)); + assertEquals(stores.size(), 2); + assertEquals(stores.get(0).getCode(), "AFS"); + assertEquals(stores.get(1).getCode(), "STANDARD"); } else { try -- GitLab