From 34dcfec6e629e335b72ab3032e1fa7d919fe6c89 Mon Sep 17 00:00:00 2001 From: "manuele.simi" Date: Tue, 23 Jan 2018 03:48:33 +0000 Subject: [PATCH] Load the default token from a property file. Skip the tests if the token is null. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162451 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../manager/webapp/context/RMContextTest.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java index e1caba4..826d426 100644 --- a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java +++ b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java @@ -3,6 +3,9 @@ package org.gcube.resourcemanagement.manager.webapp.context; import static org.junit.Assert.*; import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import java.util.Properties; import java.util.UUID; import javax.ws.rs.client.Entity; @@ -19,6 +22,7 @@ import org.gcube.common.scope.api.ScopeProvider; import org.gcube.informationsystem.impl.entity.ContextImpl; import org.gcube.informationsystem.impl.utils.ISMapper; import org.gcube.informationsystem.model.entity.Context; +import org.gcube.informationsystem.resourceregistry.client.ScopedTest; import org.gcube.resourcemanagement.manager.io.codeexceptions.CodeFinder; import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode; @@ -59,10 +63,24 @@ public class RMContextTest extends JerseyTest { private final static String RR = "http://manuele-registry.dev.d4science.org/resource-registry"; - public static final String DEFAULT_TEST_SCOPE ="71b9ef86-76ba-4346-b16e-9a1af203f6db-98187548"; - + public static String DEFAULT_TEST_SCOPE =""; private static boolean skipTest = false; + + static { + Properties properties = new Properties(); + try (InputStream input = RMContextTest.class.getClassLoader().getResourceAsStream("token.properties")) { + // load the properties file + properties.load(input); + } catch (IOException e) { + skipTest = true; + //throw new RuntimeException(e); + } + + DEFAULT_TEST_SCOPE = properties.getProperty("DEFAULT_SCOPE_TOKEN"); + if (DEFAULT_TEST_SCOPE.isEmpty()) + skipTest = true; + } @BeforeClass public static void beforeClass() throws Exception {