57 lines
1.5 KiB
Java
57 lines
1.5 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.accounting.persistence;
|
|
|
|
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
|
import org.gcube.accounting.datamodel.TestUsageRecord;
|
|
import org.gcube.accounting.testutility.StressTestUtility;
|
|
import org.gcube.accounting.testutility.TestOperation;
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
*
|
|
*/
|
|
public class PersistenceTest {
|
|
|
|
protected final static String HOME_SYSTEM_PROPERTY = "user.home";
|
|
|
|
public static Persistence getPersistence(){
|
|
Persistence.setFallbackLocation(System.getProperty(HOME_SYSTEM_PROPERTY));
|
|
return Persistence.getInstance();
|
|
}
|
|
|
|
@Test
|
|
public void test() throws Exception {
|
|
getPersistence();
|
|
}
|
|
|
|
@Test
|
|
public void stressTestNoAggregation() throws Exception {
|
|
final Persistence persistence = getPersistence();
|
|
StressTestUtility.stressTest(new TestOperation() {
|
|
@Override
|
|
public void operate(int i) {
|
|
SingleUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
|
persistence.validateAccountAggregate(usageRecord, true, false);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Test
|
|
public void stressTestWithAggregation() throws Exception {
|
|
final Persistence persistence = getPersistence();
|
|
|
|
StressTestUtility.stressTest(new TestOperation() {
|
|
@Override
|
|
public void operate(int i) throws Exception {
|
|
SingleUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
|
persistence.account(usageRecord);
|
|
}
|
|
});
|
|
persistence.flush();
|
|
}
|
|
|
|
}
|