You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.1 KiB
Java
80 lines
3.1 KiB
Java
package org.gcube.application.geoportal.service.engine.materialization;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.gcube.application.cms.tests.TokenSetter;
|
|
import org.gcube.application.cms.tests.model.TestModel;
|
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
|
import org.gcube.application.geoportal.common.model.legacy.GeoServerContent;
|
|
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
|
import org.gcube.application.geoportal.common.model.legacy.PersistedContent;
|
|
import org.gcube.application.geoportal.common.utils.Files;
|
|
import org.gcube.application.geoportal.service.engine.materialization.SDIManager;
|
|
import org.gcube.application.geoportal.service.engine.postgis.PostgisIndex;
|
|
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
|
import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException;
|
|
import org.gcube.application.geoportal.service.utils.Serialization;
|
|
import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.charset.Charset;
|
|
import java.sql.SQLException;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.regex.Matcher;
|
|
|
|
@Slf4j
|
|
public class SDITests {
|
|
|
|
|
|
@Before
|
|
public void init(){
|
|
TokenSetter.set("/gcube/devsec/devVRE");
|
|
}
|
|
|
|
@Test
|
|
public void registerCentroidsLayer() throws SDIInteractionException, SQLException, ConfigurationException {
|
|
PostgisIndex index=new PostgisIndex();
|
|
}
|
|
|
|
@Test
|
|
public void testRegexp(){
|
|
Matcher hostMatcher=SDIManager.HOSTNAME_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
Assert.assertTrue(hostMatcher.find());
|
|
System.out.println("HOST :\t"+hostMatcher.group());
|
|
|
|
Matcher portMatcher=SDIManager.PORT_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
Assert.assertTrue(portMatcher.find());
|
|
System.out.println("PORT :\t"+portMatcher.group());
|
|
|
|
Matcher dbMatcher=SDIManager.DB_NAME_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
Assert.assertTrue(dbMatcher.find());
|
|
System.out.println("DB :\t"+dbMatcher.group());
|
|
}
|
|
|
|
|
|
// @Test
|
|
//Disabled because dependant on state
|
|
public void registerLayer() throws IOException, SDIInteractionException {
|
|
Concessione toTest= Serialization.read(Files.readFileAsString(
|
|
new File(TestModel.getBaseFolder(),"transferTest.json").getAbsolutePath(), Charset.defaultCharset()), Concessione.class);
|
|
|
|
|
|
SDIManager manager = new SDIManager();
|
|
List<LayerConcessione> toPush=new ArrayList<>();
|
|
toPush.add(toTest.getPosizionamentoScavo());
|
|
toPush.addAll(toTest.getPianteFineScavo());
|
|
|
|
for (LayerConcessione l :toPush){
|
|
GeoServerContent content=manager.pushShapeLayerFileSet(l,toTest.getFolderId(),toTest.getMongo_id()+"_"+System.currentTimeMillis());
|
|
System.out.println("Published "+content);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|