From de32c0135c32cef54b7458d6c1e6ce97ed0a3829 Mon Sep 17 00:00:00 2001 From: "manuele.simi" Date: Wed, 24 Jan 2018 04:10:52 +0000 Subject: [PATCH] Load the default token from a property file for Queries test. Skip the tests if the token is null. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162503 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../manager/webapp/context/QueriesTest.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/QueriesTest.java b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/QueriesTest.java index 49695e6..a476f37 100644 --- a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/QueriesTest.java +++ b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/QueriesTest.java @@ -5,6 +5,9 @@ package org.gcube.resourcemanagement.manager.webapp.context; import static org.junit.Assert.*; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; import java.util.UUID; import org.gcube.common.authorization.client.Constants; @@ -35,12 +38,26 @@ public class QueriesTest { private final static String RR = "http://manuele-registry.dev.d4science.org/resource-registry"; - public static final String DEFAULT_TEST_SCOPE =""; + public static String DEFAULT_TEST_SCOPE =""; - public static final UUID uuid = UUID.fromString("5f86dc81-2f59-486b-8aa9-3ab5486313c4"); + public static final UUID context1UUID = UUID.fromString("5f86dc81-2f59-486b-8aa9-3ab5486313c4"); 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 { setContext(DEFAULT_TEST_SCOPE); @@ -87,9 +104,9 @@ public class QueriesTest { return; ResourceRegistryContextClient client = new ResourceRegistryContextClientImpl(RR); Queries queries = new Queries(); - Context context = queries.fetchContext(uuid,client); + Context context = queries.fetchContext(context1UUID,client); assertNotNull("Context does not exist.", context); - assertEquals("Unexpected uuid for context", uuid, context.getHeader().getUUID()); + assertEquals("Unexpected uuid for context", context1UUID, context.getHeader().getUUID()); } }