Addes some tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124590 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ccb566d5d2
commit
f933e31423
6
pom.xml
6
pom.xml
|
@ -49,6 +49,12 @@
|
|||
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>couchdb-connector</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>document-store-lib-mongodb</artifactId>
|
||||
|
|
|
@ -80,7 +80,6 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
|||
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
|
||||
configuration.addProperty(AccountingPersistenceQueryCouchDB.DB_NAME, "accounting-my-dev-test");
|
||||
accountingPersistenceQueryCouchDB = new AccountingPersistenceQueryCouchDB();
|
||||
|
||||
accountingPersistenceQueryCouchDB.prepareConnection(configuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
|
|||
public void singleParsingTest() throws Exception {
|
||||
PersistenceBackendFactory.setFallbackLocation(null);
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
|
||||
persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
|
||||
//persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
|
||||
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);
|
||||
|
||||
temporalDataPersistenceBackendMonitor.run();
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.documentstore.persistence;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.gcube.accounting.persistence.AccountingPersistence;
|
||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.gcube.testutility.TestUsageRecord;
|
||||
import org.gcube.testutility.TestUtility;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class RenameFileTest extends ScopedTest {
|
||||
|
||||
private final static String ELABORATION_FILE_SUFFIX = ".ELABORATION";
|
||||
|
||||
public void printLine(File file, String line) throws Exception {
|
||||
synchronized (file) {
|
||||
try(FileWriter fw = new FileWriter(file, true);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
PrintWriter out = new PrintWriter(bw)){
|
||||
out.println(line);
|
||||
out.flush();
|
||||
} catch( IOException e ){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renameFileTest() throws Exception{
|
||||
File first = new File("./test.txt");
|
||||
Long timestamp = Calendar.getInstance().getTimeInMillis();
|
||||
File elaborationFile = new File(first.getAbsolutePath() + ELABORATION_FILE_SUFFIX + "." + timestamp.toString());
|
||||
first.renameTo(elaborationFile);
|
||||
|
||||
printLine(first, "-FIRST-");
|
||||
for(int i=0; i<100; i++){
|
||||
printLine(elaborationFile, "-ELABORATION-" + i);
|
||||
printLine(first, "-FIRST MOVED-"+i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersistenceBackendMonitor() throws Exception{
|
||||
AccountingPersistenceFactory.setFallbackLocation(".");
|
||||
AccountingPersistence accountingPersistence = AccountingPersistenceFactory.getPersistence();
|
||||
accountingPersistence.account(TestUsageRecord.createTestStorageUsageRecord());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue