2017-05-09 15:41:59 +02:00
|
|
|
package org.gcube.informationsystem.exporter.mapper;
|
|
|
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileWriter;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
2019-02-12 18:12:24 +01:00
|
|
|
import org.gcube.informationsystem.exporter.ContextTest;
|
2017-05-09 15:41:59 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2019-02-12 18:12:24 +01:00
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
|
|
|
public class GCoreResourceMapperTest extends ContextTest {
|
2017-05-09 15:41:59 +02:00
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(GenericResourceExporterTest.class);
|
|
|
|
|
|
|
|
protected File getFile(GCoreResourceMapper<?,?> grm) throws Exception {
|
|
|
|
String contextName = GCoreResourceMapper.getCurrentContextName();
|
|
|
|
String dateString = GCoreResourceMapper.getDateString(Calendar.getInstance());
|
|
|
|
File file = grm.getFile(GenericResourceExporterTest.class, contextName, dateString);
|
|
|
|
String json = "{}";
|
|
|
|
synchronized (file) {
|
|
|
|
try(FileWriter fw = new FileWriter(file, true);
|
|
|
|
BufferedWriter bw = new BufferedWriter(fw);
|
|
|
|
PrintWriter out = new PrintWriter(bw)){
|
|
|
|
out.println(json);
|
|
|
|
out.flush();
|
|
|
|
} catch( IOException e ){
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
public void testWorkspace() throws Exception {
|
|
|
|
|
|
|
|
String[] tokens = {
|
2019-02-12 18:12:24 +01:00
|
|
|
ContextTest.GCUBE,
|
|
|
|
ContextTest.GCUBE_DEVSEC,
|
|
|
|
ContextTest.GCUBE_DEVSEC_DEVVRE,
|
|
|
|
ContextTest.GCUBE_DEVNEXT,
|
|
|
|
ContextTest.GCUBE_DEVNEXT_NEXTNEXT
|
2017-05-09 15:41:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
for(String token : tokens){
|
|
|
|
logger.info("\n\n\n-------------------------------------------------------------------------");
|
2019-02-12 18:12:24 +01:00
|
|
|
ContextTest.setContext(token);
|
2017-09-05 16:14:57 +02:00
|
|
|
GenericResourceExporter gre = new GenericResourceExporter(false);
|
2017-05-09 15:41:59 +02:00
|
|
|
File file = getFile(gre);
|
2017-09-05 16:14:57 +02:00
|
|
|
logger.info("\n\n\n {}", file);
|
|
|
|
/*
|
2017-05-09 15:41:59 +02:00
|
|
|
gre.publishFileToWorkspace(file);
|
|
|
|
logger.info("\n\n\n");
|
|
|
|
file.delete();
|
2017-09-05 16:14:57 +02:00
|
|
|
*/
|
2017-05-09 15:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|