Removed force URL in factory
This commit is contained in:
parent
7a0eb867fe
commit
31c19f3c49
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.schema;
|
package org.gcube.informationsystem.resourceregistry.schema;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -28,21 +26,8 @@ public class ResourceRegistrySchemaClientFactory {
|
||||||
return authorizationEntry.getContext();
|
return authorizationEntry.getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String FORCED_URL = null;
|
|
||||||
|
|
||||||
protected static void forceToURL(String url){
|
|
||||||
FORCED_URL = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResourceRegistrySchemaClient create() {
|
public static ResourceRegistrySchemaClient create() {
|
||||||
String address = null;
|
String address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
|
||||||
|
|
||||||
if(FORCED_URL!=null){
|
|
||||||
address = FORCED_URL;
|
|
||||||
}else {
|
|
||||||
address = String.format("%s/%s", ServiceInstance.getServiceURL(),Constants.SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address);
|
logger.trace("The {} will be contacted at {}", Constants.SERVICE_NAME, address);
|
||||||
return new ResourceRegistrySchemaClientImpl(address);
|
return new ResourceRegistrySchemaClientImpl(address);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,6 @@ public class ContextTest {
|
||||||
|
|
||||||
RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY);
|
RESOURCE_REGISTRY_URL = registryProperties.getProperty(RESOURCE_REGISTRY_URL_PROPERTY);
|
||||||
|
|
||||||
if(RESOURCE_REGISTRY_URL!=null){
|
|
||||||
ResourceRegistrySchemaClientFactory.forceToURL(RESOURCE_REGISTRY_URL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||||
|
|
|
@ -15,6 +15,17 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ResourceRegistrySchemaClientTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ResourceRegistrySchemaClientTest.class);
|
||||||
|
|
||||||
|
protected ResourceRegistrySchemaClient resourceRegistrySchemaClient;
|
||||||
|
|
||||||
|
public ResourceRegistrySchemaClientTest() {
|
||||||
|
if(ContextTest.RESOURCE_REGISTRY_URL !=null && !ContextTest.RESOURCE_REGISTRY_URL.isEmpty()) {
|
||||||
|
resourceRegistrySchemaClient = new ResourceRegistrySchemaClientImpl(ContextTest.RESOURCE_REGISTRY_URL);
|
||||||
|
}else {
|
||||||
|
resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Abstract
|
@Abstract
|
||||||
interface AuxFacet extends Facet {
|
interface AuxFacet extends Facet {
|
||||||
public static final String NAME = "aux"; //AuxFacet.class.getSimpleName();
|
public static final String NAME = "aux"; //AuxFacet.class.getSimpleName();
|
||||||
|
@ -24,14 +35,12 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
|
||||||
Type td = resourceRegistrySchemaClient.create(AuxFacet.class);
|
Type td = resourceRegistrySchemaClient.create(AuxFacet.class);
|
||||||
logger.debug("{}", td);
|
logger.debug("{}", td);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRead() throws Exception {
|
public void testRead() throws Exception {
|
||||||
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
|
||||||
List<Type> types = resourceRegistrySchemaClient.read(Facet.class, true);
|
List<Type> types = resourceRegistrySchemaClient.read(Facet.class, true);
|
||||||
Assert.assertTrue(types.size()>1);
|
Assert.assertTrue(types.size()>1);
|
||||||
for(Type td : types) {
|
for(Type td : types) {
|
||||||
|
@ -49,5 +58,4 @@ public class ResourceRegistrySchemaClientTest extends ContextTest {
|
||||||
//Assert.assertTrue(gotFacetDefinition.getDescription().compareTo(facetDefinition.getDescription())==0);
|
//Assert.assertTrue(gotFacetDefinition.getDescription().compareTo(facetDefinition.getDescription())==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue