38 lines
1.0 KiB
Java
38 lines
1.0 KiB
Java
package org.gcube.data.publishing.gCatFeeder.tests;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Properties;
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.junit.BeforeClass;
|
|
|
|
public class InfrastructureTests {
|
|
|
|
private static String testContext=null;
|
|
|
|
static {
|
|
testContext=System.getProperty("testContext");
|
|
System.out.println("TEST CONTEXT = "+testContext);
|
|
}
|
|
|
|
protected static boolean isTestInfrastructureEnabled() {
|
|
return testContext!=null;
|
|
}
|
|
|
|
@BeforeClass
|
|
public static void setTestContext() {
|
|
|
|
if(isTestInfrastructureEnabled()) {
|
|
Properties props=new Properties();
|
|
try{
|
|
props.load(BaseCollectorTest.class.getResourceAsStream("/tokens.properties"));
|
|
}catch(IOException e) {throw new RuntimeException(e);}
|
|
if(!props.containsKey(testContext)) throw new RuntimeException("No token found for scope : "+testContext);
|
|
SecurityTokenProvider.instance.set(props.getProperty(testContext));
|
|
ScopeProvider.instance.set(testContext);
|
|
}
|
|
}
|
|
|
|
}
|