diff --git a/pom.xml b/pom.xml
index 35f10b0..fe127a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.gcube.accounting
accounting-lib
- 2.4.0-SNAPSHOT
+ 2.4.1-SNAPSHOT
Accounting Library
Accounting Library
jar
diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java
index 51313c3..b8bec27 100644
--- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java
+++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java
@@ -48,4 +48,9 @@ public class AccountingPersistenceFactory {
PersistenceBackendFactory.flushAll(timeout, timeUnit);
}
+ public static void shutDown(long timeout, TimeUnit timeUnit){
+ //flush all and shutdown connection and thread
+ PersistenceBackendFactory.flushAll(timeout, timeUnit);
+ PersistenceBackendFactory.shutdown();
+ }
}
diff --git a/src/test/java/org/gcube/testutility/MyTest.java b/src/test/java/org/gcube/testutility/MyTest.java
new file mode 100644
index 0000000..39634d3
--- /dev/null
+++ b/src/test/java/org/gcube/testutility/MyTest.java
@@ -0,0 +1,89 @@
+package org.gcube.testutility;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.gcube.accounting.datamodel.BasicUsageRecord;
+import org.gcube.accounting.datamodel.UsageRecord;
+import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
+import org.gcube.accounting.persistence.AccountingPersistence;
+import org.gcube.accounting.persistence.AccountingPersistenceFactory;
+import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.RecordUtility;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MyTest {
+
+ private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
+
+ @Before
+ public void beforeClass() throws Exception{
+ SecurityTokenProvider.instance.set("36501a0d-a205-4bf1-87ad-4c7185faa0d6-98187548");
+ ScopeProvider.instance.set("/gcube/devNext");
+
+ }
+
+ @Test
+ public void test() throws Exception{
+
+
+
+ AccountingPersistence apq= AccountingPersistenceFactory.getPersistence();
+
+ //Record record=TestUsageRecord.createTestServiceUsageRecord();
+ //Record record2=TestUsageRecord.createTestServiceUsageRecord();
+
+
+ Record record=TestUsageRecord.createTestStorageVolumeUsageRecord();
+
+ logger.debug("----record:{}",record);
+ apq.account(record);
+ //apq.account(record);
+ //apq.account(record2);
+ Thread.sleep(3000);
+
+ apq.flush(3000, TimeUnit.MILLISECONDS);
+
+ logger.debug("end flush");
+
+
+ File elaborationFile = new File("/home/pieve/_gcube_devNext.fallback.log");
+
+
+ try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
+ for(String line; (line = br.readLine()) != null; ) {
+ try {
+ //Record r =DSMapper.unmarshal(Record.class, line);
+
+ Record r = RecordUtility.getRecord( line);
+ logger.debug("{}", r);
+
+ } catch(Exception e){
+ logger.error("Was not possible parse line {} to obtain a valid Record. Going to writing back this line as string fallback file.", line, e);
+
+ }
+ }
+ } catch (FileNotFoundException e) {
+ logger.error("File non trovato", e);
+ } catch (IOException e) {
+ logger.error("IOException", e);
+ }
+
+
+
+
+
+ }
+
+}