Fixing tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124143 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-12 16:56:12 +00:00
parent 19f579d5ba
commit 6dade1f7dc
23 changed files with 115 additions and 282 deletions

View File

@ -30,6 +30,7 @@
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib-couchbase</artifactId>
@ -79,6 +80,7 @@
<groupId>org.gcube.vremanagement</groupId>
<artifactId>smart-executor</artifactId>
<version>[1.4.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<type>war</type>
<scope>test</scope>
</dependency>
<dependency>
@ -118,19 +120,19 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT]</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT]</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT]</version>
<scope>test</scope>
</dependency>

View File

@ -5,12 +5,9 @@ package org.gcube.accounting.analytics.persistence;
import org.gcube.accounting.analytics.persistence.couchbase.AccountingPersistenceQueryCouchBase;
import org.gcube.accounting.analytics.persistence.couchdb.AccountingPersistenceQueryCouchDB;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,20 +16,10 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class AccountingPersistenceQueryConfigurationTest {
public class AccountingPersistenceQueryConfigurationTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryConfigurationTest.class);
@Before
public void before(){
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void accountingPersistenceQueryCouchDBConfigurationTest() throws Exception {
AccountingPersistenceBackendQueryConfiguration acbqc =
@ -54,7 +41,7 @@ public class AccountingPersistenceQueryConfigurationTest {
String uri = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.URL_PROPERTY_KEY);
String username = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.USERNAME_PROPERTY_KEY);
String password = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.PASSWORD_PROPERTY_KEY);
logger.debug("{} {} - {} : {}", BasicUsageRecord.getScopeFromToken(), uri, username, password);
logger.debug("{} {} - {} : {}", TestUtility.getScope(), uri, username, password);
}catch(IndexOutOfBoundsException e){
logger.debug("No AccountingPersistenceConfiguration : \n {} {} \n\n", e.getClass().getName(), e.getMessage());
} catch(Exception e){

View File

@ -23,10 +23,8 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -37,7 +35,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class AccountingPersistenceQueryFactoryTest {
public class AccountingPersistenceQueryFactoryTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryFactoryTest.class);
@ -45,17 +43,9 @@ public class AccountingPersistenceQueryFactoryTest {
@Before
public void before() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
apq = AccountingPersistenceBackendQueryFactory.getInstance();
}
@After
public void after(){
apq = null;
SecurityTokenProvider.instance.reset();
}
@Test
public void testNullFilters() throws Exception {
Calendar startTime = Calendar.getInstance();

View File

@ -7,13 +7,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.TestUtility;
import org.gcube.utils.ScopedTest;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.quartz.CronExpression;
@ -23,7 +21,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class CouchDBQueryPluginSmartExecutorSchedulerTest {
public class CouchDBQueryPluginSmartExecutorSchedulerTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(CouchDBQueryPluginSmartExecutorSchedulerTest.class);
@ -36,16 +34,10 @@ public class CouchDBQueryPluginSmartExecutorSchedulerTest {
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
proxy = ExecutorPlugin.getExecutorProxy(CouchDBQueryPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
if(sleepTime==null){

View File

@ -3,10 +3,7 @@ package org.gcube.accounting.couchdb.query;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Before;
import org.gcube.utils.ScopedTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,23 +11,13 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class CouchDBQueryPluginTest {
public class CouchDBQueryPluginTest extends ScopedTest {
/**
* Logger
*/
private static Logger logger = LoggerFactory.getLogger(CouchDBQueryPluginTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void testLaunch() throws Exception {
logger.debug("Starting to test launch");

View File

@ -5,13 +5,10 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,26 +17,15 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class JobUsageRecordScopedTest extends JobUsageRecordTest {
public class JobUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(JobUsageRecordScopedTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
}
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
JobUsageRecord usageRecord = TestUsageRecord.createTestJobUsageRecord();
Set<String> expectedRequiredFields = getExpectedRequiredFields();
Set<String> expectedRequiredFields = JobUsageRecordTest.getExpectedRequiredFields();
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
Set<String> gotRequiredFields = usageRecord.getRequiredFields();

View File

@ -5,13 +5,10 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,25 +17,15 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class ServiceUsageRecordScopedTest extends ServiceUsageRecordTest {
public class ServiceUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(ServiceUsageRecordScopedTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
}
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
Set<String> expectedRequiredFields = getExpectedRequiredFields();
Set<String> expectedRequiredFields = ServiceUsageRecordTest.getExpectedRequiredFields();
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
Set<String> gotRequiredFields = usageRecord.getRequiredFields();

View File

@ -5,13 +5,10 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.accounting.testutility.ScopedTest;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,25 +17,15 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class StorageUsageRecordScopedTest extends StorageUsageRecordTest {
public class StorageUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(StorageUsageRecordScopedTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
}
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
StorageUsageRecord usageRecord = TestUsageRecord.createTestStorageUsageRecord();
Set<String> expectedRequiredFields = getExpectedRequiredFields();
Set<String> expectedRequiredFields = StorageUsageRecordTest.getExpectedRequiredFields();
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
Set<String> gotRequiredFields = usageRecord.getRequiredFields();

View File

@ -8,6 +8,7 @@ import java.util.Set;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
import org.gcube.accounting.testutility.ScopedTest;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
@ -24,7 +25,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class TaskUsageRecordScopedTest extends TaskUsageRecordTest {
public class TaskUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(TaskUsageRecordScopedTest.class);
@ -57,7 +58,7 @@ public class TaskUsageRecordScopedTest extends TaskUsageRecordTest {
public void testRequiredFieldsScoped() throws InvalidValueException{
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecord();
Set<String> expectedRequiredFields = getExpectedRequiredFields();
Set<String> expectedRequiredFields = TaskUsageRecordTest.getExpectedRequiredFields();
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
Set<String> gotRequiredFields = usageRecord.getRequiredFields();

View File

@ -6,8 +6,6 @@ package org.gcube.accounting.persistence;
import java.io.StringWriter;
import java.net.URL;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
@ -17,10 +15,9 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Runtime;
import org.gcube.common.resources.gcore.common.Platform;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.documentstore.persistence.PersistenceBackend;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,7 +25,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class AccountingPersistenceConfigurationTest {
public class AccountingPersistenceConfigurationTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(AccountingPersistenceConfigurationTest.class);
@ -54,16 +51,6 @@ public class AccountingPersistenceConfigurationTest {
}
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
/**
* Create the Service Endpoint using information related to discovered
* available plugins and their own discovered capabilities
@ -156,7 +143,7 @@ public class AccountingPersistenceConfigurationTest {
String uri = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.URL_PROPERTY_KEY);
String username = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.USERNAME_PROPERTY_KEY);
String password = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.PASSWORD_PROPERTY_KEY);
logger.debug("{} - {} - {} - {}", BasicUsageRecord.getScopeFromToken(), uri, username, password);
logger.debug("{} - {} - {} - {}", TestUtility.getScope(), uri, username, password);
}catch(IndexOutOfBoundsException e){
logger.debug("No AccountingPersistenceConfiguration : \n {} {} \n\n", e.getClass().getName(), e.getMessage());
} catch(Exception e){

View File

@ -7,7 +7,6 @@ import java.io.StringWriter;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
@ -15,12 +14,12 @@ import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.documentstore.persistence.PersistenceBackend;
import org.gcube.documentstore.persistence.PersistenceBackendFactory;
import org.gcube.documentstore.persistence.PersistenceCouchBase;
//import org.gcube.documentstore.persistence.PersistenceCouchBase;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceCouchBaseTest {
public class PersistenceCouchBaseTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBaseTest.class);
@ -37,19 +36,9 @@ public class PersistenceCouchBaseTest {
public static final TimeUnit timeUnit = TimeUnit.MILLISECONDS;
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
public static PersistenceBackend getPersistence(){
PersistenceBackendFactory.setFallbackLocation(null);
return PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
return PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
}
@Test
@ -65,7 +54,7 @@ public class PersistenceCouchBaseTest {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}", BasicUsageRecord.getScopeFromToken(), stringWriter);
logger.debug("Trying to publish to {}:\n{}", TestUtility.getScope(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -82,7 +71,7 @@ public class PersistenceCouchBaseTest {
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}",
resource.getClass().getSimpleName(), id,
BasicUsageRecord.getScopeFromToken());
TestUtility.getScope());
registryPublisher.remove(resource);
@ -114,7 +103,7 @@ public class PersistenceCouchBaseTest {
}
logger.debug("Going to check First Time");
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("First {} : {}", PersistenceBackend.class.getSimpleName(), first);
publishResource(serviceEndpoint);
@ -126,7 +115,7 @@ public class PersistenceCouchBaseTest {
}
logger.debug("Going to check Second Time");
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("Second {} : {}", PersistenceBackend.class.getSimpleName(), second);
Assert.assertNotEquals(first, second);

View File

@ -7,7 +7,6 @@ import java.io.File;
import java.io.StringWriter;
import java.util.Calendar;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
@ -17,10 +16,9 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
import org.gcube.documentstore.persistence.PersistenceCouchDB;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -29,23 +27,13 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceCouchDBTest {
public class PersistenceCouchDBTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchDBTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
public static PersistenceBackend getPersistence(){
PersistenceBackendFactory.setFallbackLocation(null);
return PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
return PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
}
@Test
@ -61,7 +49,7 @@ public class PersistenceCouchDBTest {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}", BasicUsageRecord.getScopeFromToken(), stringWriter);
logger.debug("Trying to publish to {}:\n{}", TestUtility.getScope(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -78,7 +66,7 @@ public class PersistenceCouchDBTest {
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}",
resource.getClass().getSimpleName(), id,
BasicUsageRecord.getScopeFromToken());
TestUtility.getScope());
registryPublisher.remove(resource);
@ -115,7 +103,7 @@ public class PersistenceCouchDBTest {
}
logger.debug("Going to check First Time");
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("First {} : {}", PersistenceBackend.class.getSimpleName(), first);
publishResource(serviceEndpoint);
@ -127,7 +115,7 @@ public class PersistenceCouchDBTest {
}
logger.debug("Going to check Second Time");
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("Second {} : {}", PersistenceBackend.class.getSimpleName(), second);
Assert.assertNotEquals(first, second);

View File

@ -6,7 +6,6 @@ package org.gcube.accounting.persistence;
import java.io.StringWriter;
import java.util.Calendar;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
@ -16,10 +15,9 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
import org.gcube.documentstore.persistence.PersistenceMongoDB;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,23 +26,13 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceMongoDBTest {
public class PersistenceMongoDBTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceMongoDBTest.class);
@Before
public void before() throws Exception {
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
public static PersistenceBackend getPersistence(){
PersistenceBackendFactory.setFallbackLocation(null);
return PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
return PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
}
@Test
@ -60,7 +48,7 @@ public class PersistenceMongoDBTest {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}", BasicUsageRecord.getScopeFromToken(), stringWriter);
logger.debug("Trying to publish to {}:\n{}", TestUtility.getScope(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -77,7 +65,7 @@ public class PersistenceMongoDBTest {
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}",
resource.getClass().getSimpleName(), id,
BasicUsageRecord.getScopeFromToken());
TestUtility.getScope());
registryPublisher.remove(resource);
@ -110,7 +98,7 @@ public class PersistenceMongoDBTest {
}
logger.debug("Going to check First Time");
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("First {} : {}", PersistenceBackend.class.getSimpleName(), first);
publishResource(serviceEndpoint);
@ -122,7 +110,7 @@ public class PersistenceMongoDBTest {
}
logger.debug("Going to check Second Time");
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("Second {} : {}", PersistenceBackend.class.getSimpleName(), second);
Assert.assertNotEquals(first, second);

View File

@ -5,16 +5,13 @@ package org.gcube.documentstore.persistence;
import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.StressTestUtility;
import org.gcube.utils.TestOperation;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -23,27 +20,17 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceBackendMonitorTest {
public class PersistenceBackendMonitorTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceBackendMonitorTest.class);
public static final long timeout = 5000;
public static final TimeUnit timeUnit = TimeUnit.MILLISECONDS;
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
}
@Test
public void parsingTest() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null);
final PersistenceBackend persistence = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
final PersistenceBackend persistence = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
StressTestUtility.stressTest(new TestOperation() {
@ -74,7 +61,7 @@ public class PersistenceBackendMonitorTest {
persistence.flush(timeout, timeUnit);
logger.debug(" END -----------------------------------------------");
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);
@ -85,7 +72,7 @@ public class PersistenceBackendMonitorTest {
@Test
public void singleParsingTest() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null);
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);

View File

@ -6,9 +6,9 @@ package org.gcube.documentstore.persistence;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.StressTestUtility;
import org.gcube.utils.TestOperation;
import org.gcube.utils.TestUsageRecord;
@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceBackendTest {
public class PersistenceBackendTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(PersistenceBackendTest.class);
@ -44,7 +44,7 @@ public class PersistenceBackendTest {
public static PersistenceBackend getPersistence(){
PersistenceBackendFactory.setFallbackLocation(null);
return PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
return PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
}
@Test
@ -108,9 +108,9 @@ public class PersistenceBackendTest {
public void testScopeRecheck() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null);
logger.debug("Going to check First Time");
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("First {} : {}", PersistenceBackend.class.getSimpleName(), first);
Long firstCheck = PersistenceBackendFactory.getFallbackLastCheck(BasicUsageRecord.getScopeFromToken());
Long firstCheck = PersistenceBackendFactory.getFallbackLastCheck(TestUtility.getScope());
logger.debug("First Check Time {}", firstCheck);
long startTime = Calendar.getInstance().getTimeInMillis();
@ -121,9 +121,9 @@ public class PersistenceBackendTest {
}
logger.debug("Going to check Second Time");
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(BasicUsageRecord.getScopeFromToken());
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(TestUtility.getScope());
logger.debug("Second {} : {}", PersistenceBackend.class.getSimpleName(), second);
Long secondCheck = PersistenceBackendFactory.getFallbackLastCheck(BasicUsageRecord.getScopeFromToken());
Long secondCheck = PersistenceBackendFactory.getFallbackLastCheck(TestUtility.getScope());
logger.debug("Second Check Time {}", secondCheck);
Assert.assertNotEquals(firstCheck, secondCheck);

View File

@ -7,6 +7,7 @@ import java.net.URL;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.records.Record;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
@ -22,7 +23,7 @@ import com.couchbase.client.deps.com.fasterxml.jackson.databind.JsonNode;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceCouchBaseTest {
public class PersistenceCouchBaseTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBaseTest.class);

View File

@ -6,13 +6,10 @@ package org.gcube.documentstore.persistence;
import java.net.URL;
import org.codehaus.jackson.JsonNode;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.records.Record;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,20 +18,10 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class PersistenceCouchDBTest {
public class PersistenceCouchDBTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchDBTest.class);
@Before
public void before() throws Exception {
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void testJsonNodeUsageRecordConversions() throws Exception {
Record record = TestUsageRecord.createTestServiceUsageRecord();

View File

@ -8,12 +8,9 @@ import java.net.URL;
import org.bson.Document;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.records.Record;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.gcube.utils.TestUsageRecord;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,15 +23,6 @@ public class PersistenceMongoDBTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceMongoDBTest.class);
@Before
public void before() throws Exception {
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void testJsonNodeUsageRecordConversions() throws Exception {
@ -94,6 +82,5 @@ public class PersistenceMongoDBTest {
EnumCodec<OperationType> enumCodec = new EnumCodec<OperationType>(OperationType.class);
Assert.assertEquals(OperationType.class, enumCodec.getEncoderClass());
}
}

View File

@ -9,17 +9,14 @@ import java.util.Map;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.documentstore.persistence.PersistenceExecutor;
import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.documentstore.records.Record;
import org.gcube.utils.ScopedTest;
import org.gcube.utils.StressTestUtility;
import org.gcube.utils.TestOperation;
import org.gcube.utils.TestUsageRecord;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,26 +25,14 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class AggregationSchedulerTest {
public class AggregationSchedulerTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(AggregationSchedulerTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after() throws Exception{
SecurityTokenProvider.instance.reset();
}
public static AggregationScheduler getAggregationScheduler(){
return AggregationScheduler.newInstance();
}
public static PersistenceExecutor persistenceExecutor = new PersistenceExecutor(){
@Override
public void persist(Record... records) throws Exception {

View File

@ -7,16 +7,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.TestUtility;
import org.gcube.utils.ScopedTest;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,7 +21,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class ISSweeperPluginSmartExecutorSchedulerTest {
public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginSmartExecutorSchedulerTest.class);
@ -32,16 +29,10 @@ public class ISSweeperPluginSmartExecutorSchedulerTest {
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
logger.debug("Inputs : {}", inputs);

View File

@ -3,10 +3,7 @@ package org.gcube.informationsystem.sweeper;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.utils.TestUtility;
import org.junit.After;
import org.junit.Before;
import org.gcube.utils.ScopedTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,23 +11,13 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class ISSweeperPluginTest {
public class ISSweeperPluginTest extends ScopedTest {
/**
* Logger
*/
private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
}
@After
public void after(){
SecurityTokenProvider.instance.reset();
}
@Test
public void testLaunch() throws Exception {
logger.debug("Starting to test launch");

View File

@ -0,0 +1,29 @@
/**
*
*/
package org.gcube.utils;
//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.After;
import org.junit.Before;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class ScopedTest {
@Before
public void before() throws Exception{
//SecurityTokenProvider.instance.set(TestUtility.TOKEN);
ScopeProvider.instance.set("/gcube/devsec");
}
@After
public void after() throws Exception{
//SecurityTokenProvider.instance.reset();
ScopeProvider.instance.reset();
}
}

View File

@ -10,6 +10,7 @@ import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
@ -22,7 +23,7 @@ import org.slf4j.LoggerFactory;
*/
public class TestUtility {
public static final String TOKEN = "82a84741-debe-4c90-a907-c429c8272071";
public static final String TOKEN = "";
public static final String PARENT_TOKEN = "";
/**
@ -30,6 +31,12 @@ public class TestUtility {
*/
private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
public static String getScope(){
return ScopeProvider.instance.get();
//return getScopeFromToken();
}
/*
public static String getScopeFromToken(){
String token = SecurityTokenProvider.instance.get();
AuthorizationEntry authorizationEntry;
@ -41,6 +48,7 @@ public class TestUtility {
String scope = authorizationEntry.getContext();
return scope;
}
*/
/**
* Publish the provided resource on current scope
@ -55,7 +63,7 @@ public class TestUtility {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}", getScopeFromToken(), stringWriter);
logger.debug("Trying to publish to {}:\n{}", getScope(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -76,7 +84,7 @@ public class TestUtility {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScopeFromToken());
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScope());
registryPublisher.remove(resource);