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:
Luca Frosini 2016-02-25 17:08:44 +00:00
parent ccb566d5d2
commit f933e31423
4 changed files with 72 additions and 2 deletions

View File

@ -49,6 +49,12 @@
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>test</scope> <scope>test</scope>
</dependency> </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> <dependency>
<groupId>org.gcube.data.publishing</groupId> <groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib-mongodb</artifactId> <artifactId>document-store-lib-mongodb</artifactId>

View File

@ -80,7 +80,6 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class); AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
configuration.addProperty(AccountingPersistenceQueryCouchDB.DB_NAME, "accounting-my-dev-test"); configuration.addProperty(AccountingPersistenceQueryCouchDB.DB_NAME, "accounting-my-dev-test");
accountingPersistenceQueryCouchDB = new AccountingPersistenceQueryCouchDB(); accountingPersistenceQueryCouchDB = new AccountingPersistenceQueryCouchDB();
accountingPersistenceQueryCouchDB.prepareConnection(configuration); accountingPersistenceQueryCouchDB.prepareConnection(configuration);
} }

View File

@ -73,7 +73,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
public void singleParsingTest() throws Exception { public void singleParsingTest() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null); PersistenceBackendFactory.setFallbackLocation(null);
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope()); PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend); //persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend); PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);
temporalDataPersistenceBackendMonitor.run(); temporalDataPersistenceBackendMonitor.run();

View File

@ -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());
}
}