Removed eclipse properties to compile with java 1.7

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@148760 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-05-17 08:46:00 +00:00
parent 7a77bc501e
commit 6811208246
6 changed files with 199 additions and 2 deletions

View File

@ -154,6 +154,14 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>is-exporter-se-plugin</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.acme</groupId>
<artifactId>HelloWorldPlugin</artifactId>

View File

@ -0,0 +1,90 @@
/**
*
*/
package org.gcube.informationsystem.exporter;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.testutility.ScopedTest;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(ISExporterPluginSmartExecutorSchedulerTest.class);
private SmartExecutorProxy proxy;
@Before
public void before() throws Exception{
proxy = ExecutorPlugin.getExecutorProxy(ISExporterPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
}
public UUID scheduleTest(Scheduling scheduling) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
logger.debug("Inputs : {}", inputs);
LaunchParameter parameter = new LaunchParameter(ISExporterPluginDeclaration.NAME, inputs);
if(scheduling!=null){
parameter.setScheduling(scheduling);
}
try {
String uuidString = proxy.launch(parameter);
return UUID.fromString(uuidString);
} catch(Exception e){
logger.error("Error launching sheduled task", e);
throw e;
}
}
@Test
public void cronExpPreviousMustBeTerminated() throws Exception {
Map<String, String> tokenMinutes = new HashMap<>();
tokenMinutes.put(ScopedTest.GCUBE, "1");
tokenMinutes.put(ScopedTest.GCUBE_DEVSEC, "20");
tokenMinutes.put(ScopedTest.GCUBE_DEVSEC_DEVVRE, "30");
tokenMinutes.put(ScopedTest.GCUBE_DEVNEXT, "40");
tokenMinutes.put(ScopedTest.GCUBE_DEVNEXT_NEXTNEXT, "50");
for(String token : tokenMinutes.keySet()){
logger.info("\n\n\n-------------------------------------------------------------------------");
ScopedTest.setContext(token);
CronExpression cronExpression = new CronExpression("0 " + tokenMinutes.get(token) + " 0/1 * * ?"); // every hour at tokenMinutes.get(token) minutes
Scheduling scheduling = new Scheduling(cronExpression, true);
scheduling.setGlobal(true);
UUID uuid = scheduleTest(scheduling);
logger.debug("Launched with UUID : {}", uuid);
logger.info("\n\n\n");
}
}
//@Test
public void unSchedule() throws Exception {
proxy.unSchedule(null, true);
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.informationsystem.resource_checker.utils;
import java.util.Map;
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
public class SendNotification extends PluginStateNotification{
public SendNotification(Map<String, String> inputs) {
super(inputs);
// TODO Auto-generated constructor stub
}
@Override
public void pluginStateEvolution(PluginStateEvolution pluginStateEvolution, Exception exception) throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,71 @@
package org.gcube.informationsystem.socialdataindexer;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.resource_checker.utils.SendNotification;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Launch the ResourceCheckerPlugin
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceCheckerPluginSmartExecutorSchedulerTest {
private static Logger logger = LoggerFactory.getLogger(ResourceCheckerPluginSmartExecutorSchedulerTest.class);
private SmartExecutorProxy proxy;
@Before
public void before() throws Exception{
ScopeProvider.instance.set("/gcube");
SecurityTokenProvider.instance.set("2c56a96d-5f17-41a0-94a8-b8efa44d9e7c-98187548"); // gcube scope, ResourceCheckerPlugin application
proxy = ExecutorPlugin.getExecutorProxy("resource-checker-se-plugin").build();
Assert.assertNotNull(proxy);
}
@Test
public void cronExpPreviousMustBeTerminated() throws Exception {
//CronExpression cronExpression = new CronExpression("0 0 0/4 * * ? *"); // every 30 minutes starting from now
CronExpression cronExpression = new CronExpression("0 0 0/1 * * ?"); // every 30 minutes starting from now
Scheduling scheduling = new Scheduling(cronExpression, true);
scheduling.setGlobal(true);
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("role", "Administrator");
logger.debug("Inputs : {}", inputs);
LaunchParameter parameter = new LaunchParameter("resource-checker-se-plugin", inputs);
Map<String, String> inputsNotification = new HashMap<String, String>();
inputsNotification.put("recipient", "costantino.perciante");
parameter.addPluginStateNotifications(SendNotification.class, inputsNotification);
parameter.setScheduling(scheduling);
try {
String uuidString = proxy.launch(parameter);
logger.info("Launched with UUID : {}" + uuidString);
} catch(Exception e){
logger.error("Error launching sheduled task" + e);
throw e;
}
}
//@Test
public void unSchedule() throws Exception {
String id = "c2918249-4644-47fb-b151-8f8448f67f05";
//proxy.unSchedule(id, true);
proxy.stop(id);
}
}

View File

@ -39,6 +39,11 @@ public class ScopedTest {
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
public static final String GCUBE_DEVSEC_DEVVRE;
public static final String GCUBE_VARNAME = "GCUBE";
public static final String GCUBE;
public static final String DEFAULT_TEST_SCOPE;
public static final String ALTERNATIVE_TEST_SCOPE;
@ -59,8 +64,10 @@ public class ScopedTest {
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
GCUBE = properties.getProperty(GCUBE_VARNAME);
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC_DEVVRE;
}
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{

View File

@ -36,7 +36,7 @@ public class DefaultExecutorTest extends ScopedTest {
@Before
public void before() throws Exception{
proxy = ExecutorPlugin.getExecutorProxy().build();
proxy = ExecutorPlugin.getExecutorProxy("HelloWorld").build();
Assert.assertNotNull(proxy);
}