Changing the tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@133913 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
41b3f39989
commit
0935bfc1f7
|
@ -202,7 +202,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
|||
}
|
||||
connection.setDoOutput(true);
|
||||
|
||||
connection.setRequestProperty("Content-type", "text/plain");
|
||||
connection.setRequestProperty("Content-type", "application/json");
|
||||
connection.setRequestProperty("User-Agent", ResourceRegistryClient.class.getSimpleName());
|
||||
|
||||
connection.setRequestMethod(method.toString());
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.client.proxy;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -22,9 +21,12 @@ public class ResourceRegistryClientTest {
|
|||
|
||||
protected ResourceRegistryClient resourceRegistryClient;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ScopedTest.beforeClass();
|
||||
}
|
||||
|
||||
public ResourceRegistryClientTest(){
|
||||
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.client.proxy;
|
||||
|
||||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class ScopedTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
|
||||
|
||||
private static final String TOKEN = "";
|
||||
|
||||
private static String getCurrentScope() throws ObjectNotFound, Exception{
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(TOKEN);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", TOKEN, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception{
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
ScopeProvider.instance.set(getCurrentScope());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception{
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue