diff --git a/pom.xml b/pom.xml
index cc585c1..41df6e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
org.gcube.accounting
accounting-analytics-persistence-couchbase
- [1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)
+ [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)
diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryConfigurationTest.java b/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryConfigurationTest.java
index cd36de9..63c2035 100644
--- a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryConfigurationTest.java
+++ b/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryConfigurationTest.java
@@ -8,6 +8,7 @@ import org.gcube.accounting.analytics.persistence.couchdb.AccountingPersistenceQ
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -33,19 +34,20 @@ public class AccountingPersistenceQueryConfigurationTest {
}
@Test
- public void test() throws Exception {
+ public void accountingPersistenceQueryCouchDBConfigurationTest() throws Exception {
AccountingPersistenceBackendQueryConfiguration acbqc =
new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
logger.debug("{}", acbqc);
}
@Test
- public void test() throws Exception {
- AccountingPersistenceBackendQueryConfiguration acbqc = new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
+ public void accountingPersistenceQueryCouchBaseConfigurationTest() throws Exception {
+ AccountingPersistenceBackendQueryConfiguration acbqc =
+ new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
logger.debug("{}", acbqc);
}
- @Test
+ //@Test
public void getUsernamePasswordForScopes() throws Exception{
try {
AccountingPersistenceBackendQueryConfiguration persitenceConfiguration = new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryFactoryTest.java b/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryFactoryTest.java
index 111bba7..0733d11 100644
--- a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryFactoryTest.java
+++ b/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQueryFactoryTest.java
@@ -25,6 +25,7 @@ import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/src/test/java/org/gcube/accounting/couchdb/query/TestUtility.java b/src/test/java/org/gcube/accounting/couchdb/query/TestUtility.java
deleted file mode 100644
index bc28c67..0000000
--- a/src/test/java/org/gcube/accounting/couchdb/query/TestUtility.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.couchdb.query;
-
-import java.io.StringWriter;
-
-import org.gcube.common.authorization.client.Constants;
-import org.gcube.common.authorization.library.AuthorizationEntry;
-import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
-import org.gcube.common.resources.gcore.Resource;
-import org.gcube.common.resources.gcore.Resources;
-import org.gcube.informationsystem.publisher.RegistryPublisher;
-import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
-import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- *
- */
-public class TestUtility {
-
- public static final String TOKEN = "";
-
- /**
- * Logger
- */
- private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
-
- public static String getScopeFromToken(){
- String token = SecurityTokenProvider.instance.get();
- AuthorizationEntry authorizationEntry;
- try {
- authorizationEntry = Constants.authorizationService().get(token);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- String scope = authorizationEntry.getContext();
- return scope;
- }
-
- /**
- * Publish the provided resource on current scope
- * @param resource to be published
- * @throws RegistryNotFoundException if the Registry is not found so the
- * resource has not be published
- */
- public static void publishResource(Resource resource) throws Exception {
- StringWriter stringWriter = new StringWriter();
- Resources.marshal(resource, stringWriter);
-
- RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
-
- try {
- logger.debug("Trying to publish to {}:\n{}", getScopeFromToken(), stringWriter);
- registryPublisher.create(resource);
- } catch (Exception e) {
- logger.error("The resource was not published", e);
- throw e;
- }
- }
-
- /**
- * Remove the resource from IS from curretn scope
- * @param resource to be unpublished
- * @throws RegistryNotFoundException if the Registry is not found so the
- * resource has not be published
- */
- public static void unPublishResource(Resource resource) throws Exception {
- //StringWriter stringWriter = new StringWriter();
- //Resources.marshal(resource, stringWriter);
-
- RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
-
- String id = resource.id();
- logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScopeFromToken());
-
- registryPublisher.remove(resource);
-
- logger.debug("{} with ID {} removed successfully", resource.getClass().getSimpleName(), id);
- }
-
-}
diff --git a/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendMonitorTest.java b/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendMonitorTest.java
index 86b0808..c6f48d5 100644
--- a/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendMonitorTest.java
+++ b/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendMonitorTest.java
@@ -8,11 +8,11 @@ import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
-import org.gcube.accounting.testutility.StressTestUtility;
-import org.gcube.accounting.testutility.TestOperation;
import org.gcube.accounting.testutility.TestUtility;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.utils.StressTestUtility;
+import org.gcube.utils.TestOperation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
diff --git a/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendTest.java b/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendTest.java
index e945ac8..721ea58 100644
--- a/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendTest.java
+++ b/src/test/java/org/gcube/accounting/documentstore/persistence/PersistenceBackendTest.java
@@ -9,11 +9,11 @@ import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
-import org.gcube.accounting.testutility.StressTestUtility;
-import org.gcube.accounting.testutility.TestOperation;
import org.gcube.accounting.testutility.TestUtility;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.utils.StressTestUtility;
+import org.gcube.utils.TestOperation;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/src/test/java/org/gcube/accounting/documentstore/records/aggregation/AggregationSchedulerTest.java b/src/test/java/org/gcube/accounting/documentstore/records/aggregation/AggregationSchedulerTest.java
index 268f5af..5907fbe 100644
--- a/src/test/java/org/gcube/accounting/documentstore/records/aggregation/AggregationSchedulerTest.java
+++ b/src/test/java/org/gcube/accounting/documentstore/records/aggregation/AggregationSchedulerTest.java
@@ -10,13 +10,13 @@ import java.util.Map;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
-import org.gcube.accounting.testutility.StressTestUtility;
-import org.gcube.accounting.testutility.TestOperation;
import org.gcube.accounting.testutility.TestUtility;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.persistence.PersistenceExecutor;
import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.documentstore.records.Record;
+import org.gcube.utils.StressTestUtility;
+import org.gcube.utils.TestOperation;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/src/test/java/org/gcube/accounting/persistence/TestUtility.java b/src/test/java/org/gcube/accounting/persistence/TestUtility.java
deleted file mode 100644
index 6f5fbee..0000000
--- a/src/test/java/org/gcube/accounting/persistence/TestUtility.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.persistence;
-
-import java.io.StringWriter;
-
-import org.gcube.common.authorization.client.Constants;
-import org.gcube.common.authorization.library.AuthorizationEntry;
-import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
-import org.gcube.common.resources.gcore.Resource;
-import org.gcube.common.resources.gcore.Resources;
-import org.gcube.informationsystem.publisher.RegistryPublisher;
-import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
-import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- *
- */
-public class TestUtility {
-
- public static final String TOKEN = "";
- public static final String PARENT_TOKEN = "";
-
- /**
- * Logger
- */
- private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
-
- public static String getScopeFromToken(){
- String token = SecurityTokenProvider.instance.get();
- AuthorizationEntry authorizationEntry;
- try {
- authorizationEntry = Constants.authorizationService().get(token);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- String scope = authorizationEntry.getContext();
- return scope;
- }
-
- /**
- * Publish the provided resource on current scope
- * @param resource to be published
- * @throws RegistryNotFoundException if the Registry is not found so the
- * resource has not be published
- */
- public static void publishResource(Resource resource) throws Exception {
- StringWriter stringWriter = new StringWriter();
- Resources.marshal(resource, stringWriter);
-
- RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
-
- try {
- logger.debug("Trying to publish to {}:\n{}", getScopeFromToken(), stringWriter);
- registryPublisher.create(resource);
- } catch (Exception e) {
- logger.error("The resource was not published", e);
- throw e;
- }
- }
-
- /**
- * Remove the resource from IS from curretn scope
- * @param resource to be unpublished
- * @throws RegistryNotFoundException if the Registry is not found so the
- * resource has not be published
- */
- public static void unPublishResource(Resource resource) throws Exception {
- //StringWriter stringWriter = new StringWriter();
- //Resources.marshal(resource, stringWriter);
-
- RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
-
- String id = resource.id();
- logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScopeFromToken());
-
- registryPublisher.remove(resource);
-
- logger.debug("{} with ID {} removed successfully", resource.getClass().getSimpleName(), id);
- }
-
-}
diff --git a/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java
new file mode 100644
index 0000000..4d82f52
--- /dev/null
+++ b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java
@@ -0,0 +1,69 @@
+/**
+ *
+ */
+package org.gcube.informationsystem.sweeper;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+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.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) http://www.lucafrosini.com/
+ */
+public class ISSweeperPluginSmartExecutorSchedulerTest {
+
+ private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginSmartExecutorSchedulerTest.class);
+
+ private SmartExecutorProxy proxy;
+
+ @Before
+ public void before() throws Exception{
+ SecurityTokenProvider.instance.set("");
+ proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
+ Assert.assertNotNull(proxy);
+ }
+
+ public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception {
+ Map inputs = new HashMap();
+ logger.debug("Inputs : {}", inputs);
+
+ LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
+ 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 {
+ CronExpression cronExpression = new CronExpression("0 */10 * * * ?"); // every 10 minutes starting from now
+ Scheduling scheduling = new Scheduling(cronExpression, true);
+ scheduling.setGlobal(true);
+ UUID uuid = scheduleTest(scheduling, new Long(1000*60)); // 1 min
+ logger.debug("Launched with UUID : {}", uuid);
+ }
+
+ //@Test
+ public void unSchedule() throws Exception {
+ proxy.unSchedule(null, true);
+ }
+
+}
diff --git a/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginTest.java b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginTest.java
new file mode 100644
index 0000000..c7df731
--- /dev/null
+++ b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginTest.java
@@ -0,0 +1,36 @@
+package org.gcube.informationsystem.sweeper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
+ */
+public class ISSweeperPluginTest {
+
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginTest.class);
+
+ @Before
+ public void before(){
+ SecurityTokenProvider.instance.set("");
+ }
+
+ @Test
+ public void testLaunch() throws Exception {
+ logger.debug("Starting to test launch");
+ Map inputs = new HashMap();
+ ISSweeperPlugin couchDBQueryPlugin = new ISSweeperPlugin(null);
+ couchDBQueryPlugin.launch(inputs);
+ logger.debug("-------------- launch test finished");
+ }
+
+}
diff --git a/src/test/java/org/gcube/accounting/testutility/StressTestUtility.java b/src/test/java/org/gcube/utils/StressTestUtility.java
similarity index 96%
rename from src/test/java/org/gcube/accounting/testutility/StressTestUtility.java
rename to src/test/java/org/gcube/utils/StressTestUtility.java
index 7eddd95..90d09b7 100644
--- a/src/test/java/org/gcube/accounting/testutility/StressTestUtility.java
+++ b/src/test/java/org/gcube/utils/StressTestUtility.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.gcube.accounting.testutility;
+package org.gcube.utils;
import java.util.Calendar;
import java.util.GregorianCalendar;
diff --git a/src/test/java/org/gcube/accounting/testutility/TestOperation.java b/src/test/java/org/gcube/utils/TestOperation.java
similarity index 80%
rename from src/test/java/org/gcube/accounting/testutility/TestOperation.java
rename to src/test/java/org/gcube/utils/TestOperation.java
index 62406a4..a4d1b71 100644
--- a/src/test/java/org/gcube/accounting/testutility/TestOperation.java
+++ b/src/test/java/org/gcube/utils/TestOperation.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.gcube.accounting.testutility;
+package org.gcube.utils;
/**
diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/TestUtility.java b/src/test/java/org/gcube/utils/TestUtility.java
similarity index 75%
rename from src/test/java/org/gcube/accounting/analytics/persistence/TestUtility.java
rename to src/test/java/org/gcube/utils/TestUtility.java
index e6dd9e1..f8f2688 100644
--- a/src/test/java/org/gcube/accounting/analytics/persistence/TestUtility.java
+++ b/src/test/java/org/gcube/utils/TestUtility.java
@@ -1,7 +1,7 @@
/**
*
*/
-package org.gcube.accounting.analytics.persistence;
+package org.gcube.utils;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/