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
This commit is contained in:
parent
8880bdddde
commit
de32c0135c
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue