refs #2222: Move infrastructure tests outside of components junit tests

https://support.d4science.org/issues/2222

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@124074 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-10 15:52:53 +00:00
parent c1d3e71f41
commit 5982f63f8a
8 changed files with 14 additions and 92 deletions

View File

@ -127,15 +127,6 @@
<scope>test</scope>
</dependency>
<!-- This is used to test deprecated constructor
<dependency>
<groupId>org.acme</groupId>
<artifactId>DeprecatedHelloWorldPlugin</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>
<plugins>

View File

@ -61,19 +61,6 @@ public class JSONLaunchParameter extends LaunchParameter {
this.scope = SmartExecutorInitializator.getScopeFromToken();
}
@Deprecated
public JSONLaunchParameter(String pluginName, Map<String, Object> inputs, Scheduling scheduling, boolean persist) throws ParseException {
super(pluginName, inputs, scheduling, persist);
this.scope = SmartExecutorInitializator.getScopeFromToken();
}
@Deprecated
public JSONLaunchParameter(String pluginName, Map<String, String> pluginCapabilities, Map<String, Object> inputs, Scheduling scheduling, boolean persist) throws ParseException {
super(pluginName, pluginCapabilities, inputs, scheduling, persist);
this.scheduling = new JSONScheduling(scheduling);
this.scope = SmartExecutorInitializator.getScopeFromToken();
}
public JSONLaunchParameter(LaunchParameter parameter) throws ParseException {
super(parameter.getPluginName(), parameter.getPluginCapabilities(), parameter.getInputs(), parameter.getScheduling());
this.scheduling = new JSONScheduling(parameter.getScheduling());

View File

@ -20,6 +20,8 @@ import org.gcube.vremanagement.executor.exception.SchedulePersistenceException;
import org.json.JSONException;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@ -27,6 +29,8 @@ import org.junit.Test;
*/
public class ConfiguredTasksTest {
private static Logger logger = LoggerFactory.getLogger(ConfiguredTasksTest.class);
public static final String TEST = "test";
public void checkOriginal(FileScheduledTaskConfiguration parser, int size){
@ -39,7 +43,6 @@ public class ConfiguredTasksTest {
Assert.assertEquals(1000, inputs.get(HelloWorldPlugin.SLEEP_TIME));
Assert.assertEquals(1, inputs.get(TEST));
Assert.assertEquals(null, parameter.getScheduling());
Assert.assertEquals(true, parameter.isPersist());
parameter = (JSONLaunchParameter) configuredTasks.get(1);
Assert.assertEquals(parameter.getPluginName(), HelloWorldPluginDeclaration.NAME);
@ -53,7 +56,7 @@ public class ConfiguredTasksTest {
Assert.assertEquals(null, scheduling.getFirtStartTime());
Assert.assertEquals(null, scheduling.getEndTime());
Assert.assertEquals(false, scheduling.mustPreviousExecutionsCompleted());
Assert.assertEquals(true, parameter.isPersist());
Assert.assertEquals(true, scheduling.getGlobal());
parameter = (JSONLaunchParameter) configuredTasks.get(2);
Assert.assertEquals(parameter.getPluginName(), HelloWorldPluginDeclaration.NAME);
@ -61,15 +64,16 @@ public class ConfiguredTasksTest {
Assert.assertEquals(1000, inputs.get(HelloWorldPlugin.SLEEP_TIME));
Assert.assertEquals(3, inputs.get(TEST));
Assert.assertEquals(null, parameter.getScheduling());
Assert.assertEquals(true, parameter.isPersist());
Assert.assertEquals(true, scheduling.getGlobal());
}
public static final String TASK_FILE_PATH = "/src/test/resources/";
@Test
public void testLaunchConfiguredTask() throws SchedulePersistenceException, IOException, JSONException, ParseException {
String location = new File(".").getAbsolutePath();
location = location + "/src/test/resources";
File file = new File(".", TASK_FILE_PATH);
String location = file.getAbsolutePath();
logger.trace("File location : {}", location);
FileScheduledTaskConfiguration parser = new FileScheduledTaskConfiguration(location);
checkOriginal(parser, 3);
@ -90,7 +94,6 @@ public class ConfiguredTasksTest {
Assert.assertEquals(1000, inputs.get(HelloWorldPlugin.SLEEP_TIME));
Assert.assertEquals(4, inputs.get(TEST));
Assert.assertEquals(null, parameter.getScheduling());
Assert.assertEquals(true, parameter.isPersist());
parser.releaseLaunch(parameter);

View File

@ -9,17 +9,13 @@ import java.util.List;
import java.util.UUID;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfigurationFactory;
import org.gcube.vremanagement.executor.persistence.couchdb.CouchDBPersistenceConnector;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
import org.gcube.vremanagement.executor.pluginmanager.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -32,16 +28,6 @@ public class SmartExecutorPersistenceConnectorTest {
private static Logger logger = LoggerFactory.getLogger(SmartExecutorPersistenceConnectorTest.class);
@Before
public void bfore(){
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void getConnectionTest() throws Exception {
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();

View File

@ -9,16 +9,13 @@ import java.util.UUID;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.vremanagement.executor.exception.InputsNullException;
import org.gcube.vremanagement.executor.exception.InvalidInputsException;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -31,18 +28,6 @@ public class RunnablePluginTest {
private static Logger logger = LoggerFactory.getLogger(SmartExecutorSchedulerTest.class);
@Before
public void before() throws Exception {
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
SmartExecutorPersistenceFactory.getPersistenceConnector();
}
@After
public void after() throws Exception {
SecurityTokenProvider.instance.reset();
SmartExecutorPersistenceFactory.getPersistenceConnector().close();
}
@Test
public void launchNullInputsTest() throws Exception {
logger.debug("Testing Null inputs");

View File

@ -10,18 +10,14 @@ import java.util.UUID;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.exception.PluginStateNotRetrievedException;
import org.gcube.vremanagement.executor.exception.UnableToInterruptTaskException;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.quartz.CronExpression;
import org.slf4j.Logger;
@ -38,19 +34,7 @@ public class SmartExecutorSchedulerTest {
public static final String END = "END";
public static SmartExecutorPersistenceConnector pc;
@BeforeClass
public static void before() throws Exception {
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
pc = SmartExecutorPersistenceFactory.getPersistenceConnector();
}
@AfterClass
public static void after() throws Exception {
pc.close();
SecurityTokenProvider.instance.reset();
}
public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
if(sleepTime==null){

View File

@ -1,14 +0,0 @@
/**
*
*/
package org.gcube.vremanagement.executor.pluginmanager;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class TestUtility {
public static final String TOKEN = "";
}

View File

@ -20,7 +20,8 @@
"scheduling" : {
"delay" : "2000",
"schedulingTimes" : "2",
"previuosExecutionsMustBeCompleted" : false
"previuosExecutionsMustBeCompleted" : false,
"global" : true
}
},
@ -29,8 +30,7 @@
"inputs" : {
"sleepTime" : 1000,
"test" : 3
},
"persist" : true
}
}
]