From 53a47e7eb942d3320a449a305062218723478ffa Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 8 Jan 2018 11:49:59 +0000 Subject: [PATCH] Improved test git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@161981 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../executor/client/DefaultExecutorTest.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/gcube/vremanagement/executor/client/DefaultExecutorTest.java b/src/test/java/org/gcube/vremanagement/executor/client/DefaultExecutorTest.java index 87ea0e7..5767ab2 100644 --- a/src/test/java/org/gcube/vremanagement/executor/client/DefaultExecutorTest.java +++ b/src/test/java/org/gcube/vremanagement/executor/client/DefaultExecutorTest.java @@ -6,6 +6,7 @@ package org.gcube.vremanagement.executor.client; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import java.util.concurrent.TimeUnit; import org.acme.HWPluginStateNotification; import org.acme.HelloWorldPlugin; @@ -17,6 +18,7 @@ import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin; import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy; import org.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException; import org.gcube.vremanagement.executor.exception.PluginNotFoundException; +import org.gcube.vremanagement.executor.json.SEMapper; import org.gcube.vremanagement.executor.plugin.PluginState; import org.junit.Assert; import org.junit.Before; @@ -67,7 +69,7 @@ public class DefaultExecutorTest extends ScopedTest { public void testOk() throws Exception { Map inputs = new HashMap(); inputs.put("Hello", "World"); - long sleepTime = 10000; // 1000 millisec * 10 = 10 sec + long sleepTime = TimeUnit.SECONDS.toMillis(10); inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime); LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs); @@ -76,7 +78,8 @@ public class DefaultExecutorTest extends ScopedTest { launchParameter.addPluginStateNotifications(HWPluginStateNotification.class, notificationInputs); try { String executionIdentifier = proxy.launch(launchParameter); - + logger.debug("Execution Identifier {}", executionIdentifier); + Thread.sleep(1000); // 1 sec Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState()); @@ -93,6 +96,27 @@ public class DefaultExecutorTest extends ScopedTest { } + @Test + public void testSerilization() throws Exception { + Map inputs = new HashMap(); + inputs.put("Hello", "World"); + long sleepTime = TimeUnit.SECONDS.toMillis(20); + inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime); + int minuteinterval = 2; + // Every 5 minutes, for 12 times (one hour totally). + Scheduling scheduling = new Scheduling(60*minuteinterval,12,true); + scheduling.setGlobal(false); + + LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs, scheduling); + Map notificationInputs = new HashMap(); + notificationInputs.put("Hello", "Hello World Notification:) :)"); + launchParameter.addPluginStateNotifications(HWPluginStateNotification.class, notificationInputs); + + + + logger.debug(SEMapper.marshal(launchParameter)); + } + @Test public void testScheduledTaskNotPersisted() throws Exception { @@ -101,7 +125,7 @@ public class DefaultExecutorTest extends ScopedTest { Map inputs = new HashMap(); inputs.put("Hello", "World"); - long sleepTime = 20000; // 1000 millisec * 20 = 20 sec + long sleepTime = TimeUnit.SECONDS.toMillis(20); inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime); int minuteinterval = 2; // Every 5 minutes, for 12 times (one hour totally).