Fix load from record url

This commit is contained in:
Fabio Sinibaldi 2022-03-23 18:48:49 +01:00
parent ca660cf8b6
commit 5d6aa5a4d1
2 changed files with 11 additions and 4 deletions

View File

@ -126,8 +126,9 @@ public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
try {
log.debug("Loading UCD From {} ", record);
String json = new Scanner(
new URL("http://www.google.com").openStream(),
"UTF-8").next();
new URL(record.getUcdUrl()).openStream(),
"UTF-8").useDelimiter("\\A").next();
log.trace("JSON IS {} ",json);
UseCaseDescriptor ucd = Serialization.read(json, UseCaseDescriptor.class);
toReturn.put(ucd.getId(), ucd);
}catch (Throwable t){

View File

@ -2,6 +2,7 @@ package org.gcube.application.geoportal.service.engine.providers.ucd;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.junit.BeforeClass;
import org.junit.Test;
@ -11,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assume.assumeTrue;
public class UCDLoadingTest {
@ -33,9 +35,13 @@ public class UCDLoadingTest {
}
@Test
public void testLoading(){
public void testLoading() throws ConfigurationException {
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
TokenSetter.set(GCubeTest.getContext());
// SingleISResourceUCDProvider provider =
SingleISResourceUCDProvider provider = new SingleISResourceUCDProvider();
ProfileMap map = provider.getObject();
System.out.println("loaded "+map.size()+" ucds");
assertTrue(map.size()>0);
}
}