Using a dedicated class to set token and scope for tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@140071 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-12-19 10:18:24 +00:00
parent 67913ea482
commit cf92502c5f
2 changed files with 23 additions and 9 deletions

View File

@ -153,7 +153,7 @@ public class MultiContextTest {
logger.debug("Changing token to test add to scope");
ScopedTest.setContext(ScopedTest.SECOND_TOKEN);
ScopedTest.setContext(ScopedTest.GCUBE_DEVNEXT_NEXTNEXT);
UUID uuid = createdHN.getHeader().getUUID();
boolean addedToContext = resourceRegistryPublisher.addResourceToContext(uuid);

View File

@ -25,14 +25,22 @@ public class ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
protected static final String PROPERTIES_FILENAME = "config.properties";
protected static final String PROPERTIES_FILENAME = "token.properties";
private static final String TOKEN_VARNAME = "TOKEN";
public static final String TOKEN;
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
public static final String GCUBE_DEVNEXT;
private static final String SECOND_TOKEN_VARNAME = "SECOND_TOKEN";
public static final String SECOND_TOKEN;
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
public static final String GCUBE_DEVNEXT_NEXTNEXT;
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
public static final String GCUBE_DEVSEC;
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
public static final String GCUBE_DEVSEC_DEVVRE;
public static final String DEFAULT_TEST_SCOPE;
public static final String ALTERNATIVE_TEST_SCOPE;
static {
Properties properties = new Properties();
@ -45,8 +53,14 @@ public class ScopedTest {
throw new RuntimeException(e);
}
TOKEN = properties.getProperty(TOKEN_VARNAME);
SECOND_TOKEN = properties.getProperty(SECOND_TOKEN_VARNAME);
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
}
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
@ -64,7 +78,7 @@ public class ScopedTest {
@BeforeClass
public static void beforeClass() throws Exception{
setContext(TOKEN);
setContext(DEFAULT_TEST_SCOPE);
}
@AfterClass