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:
Luca Frosini 2016-11-04 15:52:41 +00:00
parent 41b3f39989
commit 0935bfc1f7
3 changed files with 53 additions and 6 deletions

View File

@ -202,7 +202,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestProperty("Content-type", "text/plain"); connection.setRequestProperty("Content-type", "application/json");
connection.setRequestProperty("User-Agent", ResourceRegistryClient.class.getSimpleName()); connection.setRequestProperty("User-Agent", ResourceRegistryClient.class.getSimpleName());
connection.setRequestMethod(method.toString()); connection.setRequestMethod(method.toString());

View File

@ -3,10 +3,9 @@
*/ */
package org.gcube.informationsystem.resourceregistry.client.proxy; 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.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.junit.Before; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -22,9 +21,12 @@ public class ResourceRegistryClientTest {
protected ResourceRegistryClient resourceRegistryClient; protected ResourceRegistryClient resourceRegistryClient;
@Before @BeforeClass
public void before(){ public static void beforeClass() throws Exception {
ScopeProvider.instance.set("/gcube/devNext/NextNext"); ScopedTest.beforeClass();
}
public ResourceRegistryClientTest(){
resourceRegistryClient = ResourceRegistryClientFactory.create(); resourceRegistryClient = ResourceRegistryClientFactory.create();
} }

View File

@ -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();
}
}