From 1a10ead1416291fbec0a33e8ffb954d8a7cb4350 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 9 Feb 2016 17:55:16 +0000 Subject: [PATCH] refs #2201: Remove the use of ScopeProvider if any from accounting-lib https://support.d4science.org/issues/2201 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@124021 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../AggregatedServiceUsageRecordTest.java | 9 ++++++++- .../AggregatedStorageUsageRecordTest.java | 9 ++++++++- .../usagerecords/JobUsageRecordTest.java | 5 +++-- .../usagerecords/ServiceUsageRecordTest.java | 5 +++-- .../usagerecords/StorageUsageRecordTest.java | 5 +++-- .../usagerecords/TaskUsageRecordTest.java | 5 +++-- .../gcube/accounting/testutility/TestUtility.java | 14 ++++++++++++++ .../PersistenceBackendMonitorTest.java | 6 +++--- .../persistence/PersistenceBackendTest.java | 15 ++++++++------- .../aggregation/AggregationSchedulerTest.java | 5 +++-- 10 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 src/test/java/org/gcube/accounting/testutility/TestUtility.java diff --git a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecordTest.java index 5df2048..b24cd7e 100644 --- a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecordTest.java @@ -8,9 +8,11 @@ import java.util.Set; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -27,7 +29,12 @@ public class AggregatedServiceUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); + } + + @After + public void after() throws Exception{ + SecurityTokenProvider.instance.reset(); } @Test diff --git a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java index 584407f..e7a6c25 100644 --- a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java @@ -6,9 +6,11 @@ package org.gcube.accounting.datamodel.aggregation; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -25,7 +27,12 @@ public class AggregatedStorageUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); + } + + @After + public void after() throws Exception{ + SecurityTokenProvider.instance.reset(); } @Test diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java index 96b43e6..3730736 100644 --- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java @@ -9,6 +9,7 @@ import java.util.Set; import org.gcube.accounting.datamodel.UsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.records.Record; @@ -29,11 +30,11 @@ public class JobUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java index 8102f52..9322a4d 100644 --- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java @@ -9,6 +9,7 @@ import java.util.Set; import org.gcube.accounting.datamodel.UsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.records.Record; @@ -29,11 +30,11 @@ public class ServiceUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java index c769b21..8b2563a 100644 --- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java @@ -9,6 +9,7 @@ import java.util.Set; import org.gcube.accounting.datamodel.UsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.records.Record; @@ -29,11 +30,11 @@ public class StorageUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/TaskUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/TaskUsageRecordTest.java index 4b065eb..a285d9e 100644 --- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/TaskUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/TaskUsageRecordTest.java @@ -9,6 +9,7 @@ import java.util.Set; import org.gcube.accounting.datamodel.UsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; +import org.gcube.accounting.testutility.TestUtility; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.records.Record; @@ -29,11 +30,11 @@ public class TaskUsageRecordTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } diff --git a/src/test/java/org/gcube/accounting/testutility/TestUtility.java b/src/test/java/org/gcube/accounting/testutility/TestUtility.java new file mode 100644 index 0000000..b4040f9 --- /dev/null +++ b/src/test/java/org/gcube/accounting/testutility/TestUtility.java @@ -0,0 +1,14 @@ +/** + * + */ +package org.gcube.accounting.testutility; + +/** + * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ + * + */ +public class TestUtility { + + public static final String TOKEN = ""; + +} diff --git a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java index 7678d64..86b0808 100644 --- a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java +++ b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendMonitorTest.java @@ -10,6 +10,7 @@ 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.junit.After; @@ -31,15 +32,14 @@ public class PersistenceBackendMonitorTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } - @Test public void parsingTest() throws Exception { PersistenceBackendFactory.setFallbackLocation(null); diff --git a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendTest.java b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendTest.java index 643fda9..e945ac8 100644 --- a/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendTest.java +++ b/src/test/java/org/gcube/documentstore/persistence/PersistenceBackendTest.java @@ -11,11 +11,12 @@ 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.junit.AfterClass; +import org.junit.After; import org.junit.Assert; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,13 +37,13 @@ public class PersistenceBackendTest { public static final TimeUnit timeUnit = TimeUnit.MILLISECONDS; - @BeforeClass - public static void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + @Before + public void before() throws Exception{ + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } - @AfterClass - public static void after(){ + @After + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); } diff --git a/src/test/java/org/gcube/documentstore/records/aggregation/AggregationSchedulerTest.java b/src/test/java/org/gcube/documentstore/records/aggregation/AggregationSchedulerTest.java index 4ebfc64..268f5af 100644 --- a/src/test/java/org/gcube/documentstore/records/aggregation/AggregationSchedulerTest.java +++ b/src/test/java/org/gcube/documentstore/records/aggregation/AggregationSchedulerTest.java @@ -12,6 +12,7 @@ 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; @@ -33,11 +34,11 @@ public class AggregationSchedulerTest { @Before public void before() throws Exception{ - SecurityTokenProvider.instance.set(""); + SecurityTokenProvider.instance.set(TestUtility.TOKEN); } @After - public void after(){ + public void after() throws Exception{ SecurityTokenProvider.instance.reset(); }