186 lines
4.5 KiB
Java
186 lines
4.5 KiB
Java
package org.gcube.application.geoportal.service.legacy;
|
|
|
|
import java.io.IOException;
|
|
import java.io.UncheckedIOException;
|
|
import java.net.URL;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Properties;
|
|
|
|
import javax.persistence.EntityManagerFactory;
|
|
import javax.persistence.SharedCacheMode;
|
|
import javax.persistence.ValidationMode;
|
|
import javax.persistence.spi.ClassTransformer;
|
|
import javax.persistence.spi.PersistenceUnitInfo;
|
|
import javax.persistence.spi.PersistenceUnitTransactionType;
|
|
import javax.sql.DataSource;
|
|
import javax.ws.rs.client.WebTarget;
|
|
import javax.ws.rs.core.Application;
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
|
import org.gcube.application.geoportal.managers.AbstractRecordManager;
|
|
import org.gcube.application.geoportal.service.GeoportalService;
|
|
import org.glassfish.jersey.test.JerseyTest;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Slf4j
|
|
public class Concessioni extends JerseyTest {
|
|
|
|
|
|
@Override
|
|
protected Application configure() {
|
|
return new GeoportalService();
|
|
}
|
|
|
|
@BeforeClass
|
|
public static void init() {
|
|
AbstractRecordManager.setDefaultProvider(new DefaultEMFProvider() {
|
|
|
|
@Override
|
|
public EntityManagerFactory getFactory() {
|
|
System.err.println("***********************SETTING DEBUG CONTEXT******************");
|
|
TokenSetter.set("/gcube/devNext/NexNext");
|
|
return super.getF
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
public void list(){
|
|
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
|
System.err.println(target.getUri());
|
|
System.out.println(target.request(MediaType.APPLICATION_JSON).get(Collection.class));
|
|
}
|
|
|
|
|
|
@Test
|
|
public void createNew() {
|
|
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
|
// target.
|
|
}
|
|
|
|
|
|
|
|
|
|
private static PersistenceUnitInfo archiverPersistenceUnitInfo() {
|
|
|
|
final List<String> MANAGED_CLASSES=Arrays.asList(new String[] {
|
|
"org.gcube.application.geoportal.model.Record",
|
|
"org.gcube.application.geoportal.model.concessioni.Concessione",
|
|
"org.gcube.application.geoportal.model.concessioni.LayerConcessione",
|
|
"org.gcube.application.geoportal.model.concessioni.RelazioneScavo",
|
|
|
|
"org.gcube.application.geoportal.model.content.AssociatedContent",
|
|
"org.gcube.application.geoportal.model.content.GeoServerContent",
|
|
"org.gcube.application.geoportal.model.content.OtherContent",
|
|
"org.gcube.application.geoportal.model.content.PersistedContent",
|
|
"org.gcube.application.geoportal.model.content.UploadedImage",
|
|
"org.gcube.application.geoportal.model.content.WorkspaceContent",
|
|
|
|
"org.gcube.application.geoportal.model.gis.ShapeFileLayerDescriptor",
|
|
"org.gcube.application.geoportal.model.gis.SDILayerDescriptor"});
|
|
|
|
|
|
return new PersistenceUnitInfo() {
|
|
@Override
|
|
public String getPersistenceUnitName() {
|
|
return "ApplicationPersistenceUnit";
|
|
}
|
|
|
|
@Override
|
|
public String getPersistenceProviderClassName() {
|
|
return "org.hibernate.jpa.HibernatePersistenceProvider";
|
|
}
|
|
|
|
@Override
|
|
public PersistenceUnitTransactionType getTransactionType() {
|
|
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
|
|
}
|
|
|
|
@Override
|
|
public DataSource getJtaDataSource() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public DataSource getNonJtaDataSource() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public List<String> getMappingFileNames() {
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
@Override
|
|
public List<URL> getJarFileUrls() {
|
|
try {
|
|
return Collections.list(this.getClass()
|
|
.getClassLoader()
|
|
.getResources(""));
|
|
} catch (IOException e) {
|
|
throw new UncheckedIOException(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public URL getPersistenceUnitRootUrl() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public List<String> getManagedClassNames() {
|
|
return MANAGED_CLASSES;
|
|
}
|
|
|
|
@Override
|
|
public boolean excludeUnlistedClasses() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public SharedCacheMode getSharedCacheMode() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public ValidationMode getValidationMode() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public Properties getProperties() {
|
|
return new Properties();
|
|
}
|
|
|
|
@Override
|
|
public String getPersistenceXMLSchemaVersion() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public ClassLoader getClassLoader() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void addTransformer(ClassTransformer transformer) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public ClassLoader getNewTempClassLoader() {
|
|
return null;
|
|
}
|
|
};
|
|
}
|
|
}
|