Compare commits

...

22 Commits

Author SHA1 Message Date
Roberto Cirillo a6d6c0535b Merge branch 'master' of https://code-repo.d4science.org/gCubeSystem/storage-manager-wrapper 2021-10-14 10:10:36 +02:00
Roberto Cirillo c50b3d6ba8 add new JUnitTest cases 2021-10-14 10:10:17 +02:00
Roberto Cirillo 0e612d3467 Update 'CHANGELOG.md'
removed SNAPSHOT
2021-10-08 09:32:20 +02:00
Roberto Cirillo b15a9ce64c Update 'pom.xml'
removed SNAPSHOT
2021-10-08 09:31:59 +02:00
Roberto Cirillo c3386d6a3f Update 'CHANGELOG.md'
moved to snapshot
2021-10-08 09:27:49 +02:00
Roberto Cirillo 6f4e939a12 Update 'pom.xml'
moved to snapshot
2021-10-08 09:27:27 +02:00
Roberto Cirillo 76ee09b1be removed SNAPSHOT from version 2021-10-07 10:26:04 +02:00
Roberto Cirillo af22df8613 moved version from 2.6.1 to 3.0.0-SNAPSHOT 2021-10-07 10:24:11 +02:00
Roberto Cirillo a235ed76a7 convert getHttp to getHttps method 2021-10-07 09:16:42 +02:00
Roberto Cirillo 8617614b0e update CHANGELOG 2021-09-10 11:27:40 +02:00
Roberto Cirillo 9366b0a3ad update CHANGELOG 2021-09-10 11:23:46 +02:00
Roberto Cirillo bf6e5355f7 update to version 2.6.1 2021-09-10 11:19:32 +02:00
Roberto Cirillo 496e4d05f4 add Costants to Storage ServiceEndpoint coordinates 2021-09-03 15:34:21 +02:00
Roberto Cirillo 81a3481faa move from RequestObject to MyFile in some test classes 2021-09-03 10:35:14 +02:00
Roberto Cirillo 9c3bf60362 add TestCase forceClose method 2021-09-03 10:01:51 +02:00
Roberto Cirillo 25f7cc90f1 update range storage-manager-core dep 2021-09-03 10:01:27 +02:00
Roberto Cirillo e10b0d8012 bug fix #20505. New ServiceEndpoint with category Storage ##21245. Update to version 2.6.1-SNAPSHOT 2021-08-04 17:16:04 +02:00
Roberto Cirillo 59b841ba94 JUnitTest updated 2021-06-18 10:25:14 +02:00
Roberto Cirillo 4e58624c4a removed slf4j-log4j implementation, declared slf4j-api dependency 2021-05-17 12:47:43 +02:00
Roberto Cirillo e0c8834848 refactoring TestClass parameters 2021-05-13 18:08:49 +02:00
roberto cirillo a6c9be2eaf added description in changelo, created new constructor on Configuration
class
2020-11-13 12:57:53 +01:00
roberto cirillo 055827e3f2 update to version 2.6.0-SNAPSHOT, added new input param backendType 2020-11-12 18:14:30 +01:00
18 changed files with 296 additions and 69 deletions

View File

@ -6,24 +6,21 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -1,12 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,5 +1,14 @@
# Changelog for storage-manager-wrapper
## [v3.0.0] 2021-09-10
* bug fix #20505
* update gcub-bom version
* Change serviceEndpoint Category from DataStorage to Storage
* bugfix #20505
* adding new constructor with the backendType as input parameter
* retrieving specific backend credentials if a specific backend si specified as input parameter
* moved from 2.6.1 to 3.0.0-SNAPSHOT
## [v2.5.3] 2019-03-20
* Added wrapper for HomeLibrary configuration related to the new preproduction infrastructure

22
pom.xml
View File

@ -8,7 +8,7 @@
</parent>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<version>2.5.3</version>
<version>3.0.0</version>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
@ -22,7 +22,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>1.4.0</version>
<version>2.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -32,7 +32,7 @@
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.9.0, 3.0.0-SNAPSHOT)</version>
<version>[3.0.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -62,12 +62,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
<scope>provided</scope>
</dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@ -122,4 +126,4 @@
<!-- </plugin> -->
</plugins>
</build>
</project>
</project>

View File

@ -1,15 +0,0 @@
log4j.rootLogger=DEBUG, A1, stdout
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=log.txt
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
# ***** Max file size is set to 100KB
log4j.appender.A1.MaxFileSize=100MB
# ***** Keep one backup file
log4j.appender.A1.MaxBackupIndex=1
#CONSOLE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %d{dd MMM yyyy ;HH:mm:ss.SSS} - %m%n

View File

@ -0,0 +1,5 @@
package org.gcube.contentmanager.storageclient.wrapper;
public enum BackendType {
MongoDB, S3
}

View File

@ -51,8 +51,8 @@ public class Configuration {
private static final String HL_CONTEXT = "/d4science.research-infrastructures.eu";
private static final String HL_CONTEXT_DEV = "/gcube";
private static final String HL_CONTEXT_PRE = "/pred4s";
protected static final String STORAGE_SERVICEENDPOINT_NAME="StorageManager";
protected static final String STORAGE_SERVICEENDPOINT_CATEGORY="Storage";
/**
* Loads all the configuration parameters in a java object
* @param sc: service class of the remote resource
@ -73,6 +73,29 @@ public class Configuration {
setScopeString(scopeString);
}
/**
* Loads all the configuration parameters in a java object for a specific backend
*
* @param sc: service class of the remote resource
* @param sn service name of the remote resource
* @param scopeString string that identifies the scope
* @param owner user of the client library
* @param clientID
* @param accessType indicates the type of access to the storage
* @param memory indicates the type of memory used by the storage: Persistent or Volatile
*
*/
public Configuration(String sc, String sn, String scopeString, String owner, String clientID, String accessType, String memory, BackendType backend){
this.sc=sc;
this.sn=sn;
this.owner=owner;
this.clientID=clientID;
this.typeAccess=accessType;
this.memoryType=memory;
setScopeString(scopeString);
setBackendType(backend.toString());
}
/**
* Retrieve a valid configuration from IS for instantiating the engine
*/

View File

@ -63,7 +63,7 @@ public class ISClientConnector {
ScopeProvider.instance.set(scope);
}
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'DataStorage' and $resource/Profile/Name eq 'StorageManager' ");
query.addCondition("$resource/Profile/Category/text() eq '"+Configuration.STORAGE_SERVICEENDPOINT_CATEGORY+"' and $resource/Profile/Name eq '"+Configuration.STORAGE_SERVICEENDPOINT_NAME+"' ");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
if(scope!=null){
@ -85,11 +85,13 @@ public class ISClientConnector {
private String[] fillConnectionFields(ServiceEndpoint resource) {
if(resource!=null){
String [] server=new String[resource.profile().accessPoints().size()];
ArrayList<String> srvs=new ArrayList <String>();
// String [] server=new String[resource.profile().accessPoints().size()];
int i=0;
for (AccessPoint ap:resource.profile().accessPoints()) {
if (ap.name().equals("server"+(i+1))) {
server[i] = ap.address();
// server[i] = ap.address();
srvs.add(ap.address());
// if presents, try to get user and password
setUsername(ap.username());
// set password default value to empty string
@ -105,6 +107,8 @@ public class ISClientConnector {
i++;
}
}
String [] server=new String[srvs.size()];
server = srvs.toArray(server);
setBackendType(retrievePropertyValue(resource, "type"));
String [] volatileHost= new String [1];
volatileHost[0]=retrievePropertyValue(resource, "volatile");

View File

@ -1,6 +1,6 @@
package org.gcube.contentmanager.storageclient.wrapper;
//import org.gcube.contentmanagement.blobstorage.resource.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
//import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
@ -96,6 +96,34 @@ public class StorageClient {
}
/**
* New constructor with another optional argument created for gcube infrastructure internal use.
* Available in v1.6.0
* It's possible to specify a specific backend.
* @param ServiceClass
* @param ServiceName
* @param owner
* @param typeAccess
* @param scope
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, BackendType backend){
checkScopeProvider();
String id=owner;
this.owner=owner;
this.scopeString=ScopeProvider.instance.get();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
this.memoryType=MemoryType.BOTH;
this.serviceClass=serviceClass;
this.serviceName=serviceName;
this.setBackendType(backend.toString());
setClientId(serviceClass, serviceName, id);
}
/**
* Constructor created for external use
* @param owner
@ -170,6 +198,35 @@ public class StorageClient {
this.serviceName=serviceName;
setClientId(serviceClass, serviceName, id);
}
/**
* Available in v1.6.0
* It's possible to specify a specific backend.
* @param ServiceClass
* @param ServiceName
* @param owner
* @param typeAccess
* @param backend: specify mongodb (default) or s3
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
* @param scope
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory, BackendType backend){
checkScopeProvider();
String id=owner;
this.owner=owner;
this.scopeString=ScopeProvider.instance.get();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
if(memory!=null)
this.memoryType=memory;
else throw new RuntimeException("MemoryType parameter must be not null");
this.serviceClass=serviceClass;
this.serviceName=serviceName;
setClientId(serviceClass, serviceName, id);
this.setBackendType(backend.toString());
}
@ -370,6 +427,7 @@ public class StorageClient {
public String getBackendType() {
logger.debug("backend type returned is "+backendType);
return backendType;
}

View File

@ -29,7 +29,7 @@ public class DownloadsTest {
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private String scope="/d4science.research-infrastructures.eu"; //"/gcube";//"/gcube";//"/d4science.research-infrastructures.eu"; //"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
// private String scope="/d4science.research-infrastructures.eu"; //"/gcube";//"/gcube";//"/d4science.research-infrastructures.eu"; //"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
private String serviceClass="JUnitTest";
private String serviceName="StorageManager";
private String NotExistingId="5a5c7d1d1b9b060285bbe2bd";
@ -39,8 +39,8 @@ public class DownloadsTest {
@Before
public void getClient() throws RemoteBackendException{
// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
ScopeProvider.instance.set(scope);
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
// ScopeProvider.instance.set(scope);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
@ -58,7 +58,7 @@ public class DownloadsTest {
}
@Test
// @Test
public void getId(){
String id= client.getId(encryptedId);
System.out.println("id decrypted: "+id);

View File

@ -0,0 +1,125 @@
package org.gcube.contentmanager.storageclient.test;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ForceCloseTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica.jpg";
private String localPath2="src/test/resources/dog.jpg";
private String localPathDownload="src/test/resources/download.png";
private String remotePath="/test/test-resources/CostaRica1.jpg";
private String absoluteLocalPath;
private String absoluteLocalPath2;
private String absoluteLocalPathDownload;
private String newFilePath="src/test/resources";
private String remoteDirPath= "test/test-forceclose";
private IClient client;
private String serviceClass="JUnitTest-ForceCloseTest";
private String serviceName="StorageManager";
private static final Logger logger = LoggerFactory.getLogger(ForceCloseTest.class);
@Before
public void getClient(){
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setLocalResources();
//upload costaRica
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
System.out.println("UploadByPath id: "+id);
assertNotNull(id);
}
@Test
public void forceCloseTest(){
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
client.forceClose();
//download
try {
client.get().LFile(absoluteLocalPathDownload).RFile(remotePath);
}catch(Exception e ) {
assertNotNull(e);
}
// try {
// client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
// assertNotNull(client);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// delete
removeRemoteFile();
client.forceClose();
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@After
public void removeLocalFile(){
File f=new File(newFilePath);
f.delete();
assertFalse(f.exists());
}
private void removeRemoteFile() throws RemoteBackendException{
List<StorageObject> list = printDir(remoteDirPath);
client.remove().RFile(remotePath);
list = printDir(remoteDirPath);
assertTrue(list.isEmpty());
}
private List<StorageObject> printDir(String dir) {
List<StorageObject> list=client.showDir().RDir(dir);
for(StorageObject obj : list){
System.out.println("found "+obj.getName()+" and id " +obj.getId());
}
return list;
}
private void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunit.jpg";
absoluteLocalPath=new File(localPath).getAbsolutePath();
absoluteLocalPath2=new File(localPath2).getAbsolutePath();
absoluteLocalPathDownload=new File(localPathDownload).getAbsolutePath();
}
}

View File

@ -30,7 +30,7 @@ public class HLcheckTest {
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private String scope="/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//Costants.DEFAULT_SCOPE_STRING;//"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
// private String scope="/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//Costants.DEFAULT_SCOPE_STRING;//"/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";//"/d4science.research-infrastructures.eu";// //"/CNR.it";// ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
private String serviceClass="org.gcube.portlets.user";//"JUnitTest";
private String serviceName="home-library";//"test-home-library";//"StorageManager";
private String id;
@ -38,10 +38,10 @@ public class HLcheckTest {
@Before
public void getClient() throws RemoteBackendException{
// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
ScopeProvider.instance.set(scope);
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
// ScopeProvider.instance.set(scope);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, scope, false).getClient();
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_SCOPE_STRING, false).getClient();
assertNotNull(client);
} catch (Exception e) {
// TODO Auto-generated catch block
@ -87,12 +87,12 @@ public class HLcheckTest {
@Test
public void downloadBySpecificIdOnlyForTest() throws RemoteBackendException{
// String idReturned=client.get().LFile(newFilePath).RFileById(id);
String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
String idReturned=client.get().LFile(file).RFile("5f6a1f405b0bde3544cbd3be");
String idReturned=client.get().LFile(newFilePath).RFileById(id);
// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
// String idReturned=client.get().LFile(absoluteLocalPath).RFile("5f6a1f405b0bde3544cbd3be");
System.out.println("downloadById id: "+idReturned);
// File f =new File(newFilePath);
File f =new File(file);
File f =new File(newFilePath);
// File f =new File(file);
System.out.println("path new File downloaded: "+f.getAbsolutePath());
assertTrue(f.exists());
removeLocalFile();

View File

@ -52,7 +52,7 @@ public class LockTest {
assertNotNull(id);
}
@Test
// @Test
public void lockTest(){
//download & lock
String idLock=client.lock().LFile(absoluteLocalPathDownload).RFile(remotePath);

View File

@ -26,7 +26,7 @@ public class PropertiesTest {
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private String scope="/gcube/devsec"; //"/d4science.research-infrastructures.eu"; ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
// private String scope="/gcube/devsec"; //"/d4science.research-infrastructures.eu"; ///gcube/devsec/devVRE"; //"/CNR.it/ISTI";//"/gcube/devsec/devVRE"; // /d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/CNR.it/ISTI";//
private String serviceClass="JUnitTest";
private String serviceName="StorageManager";
private String id;

View File

@ -58,7 +58,7 @@ public class UrlResolverByIdTest {
}
// @Test
@Test
public void getUrlbyIdNotPaylloadCheck() throws RemoteBackendException {
String url=client.getUrl(true).RFile(remotePath);
System.out.println("url generated: "+url);
@ -165,9 +165,9 @@ public class UrlResolverByIdTest {
String id=client.remove().RFile(remotePath);
List<StorageObject> list=client.showDir().RDir("Uritest/img");
assertTrue(list.isEmpty());
// String id2=client.remove().RFile(newPath);
// List<StorageObject> list2=client.showDir().RDir("Uritest/img5");
// assertTrue(list.isEmpty());
String id2=client.remove().RFile(newPath);
List<StorageObject> list2=client.showDir().RDir("Uritest/img5");
assertTrue(list.isEmpty());
removeLocalFiles();
}

View File

@ -28,10 +28,12 @@ public class UrlResolverTest {
private String remotePath="/test/img4/CostaRicaine.jpg";
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private String id=null;
@Before
public void init() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client = new StorageClient(serviceClass, serviceName, owner , AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
} catch (Exception e) {
@ -39,7 +41,7 @@ public class UrlResolverTest {
e.printStackTrace();
}
setLocalResources();
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
id=client.put(false).LFile(absoluteLocalPath).RFile(remotePath);
}
@ -50,17 +52,31 @@ public class UrlResolverTest {
}
@Test
public void getHttpUrl() throws RemoteBackendException {
String url=client.getHttpUrl().RFile(remotePath);
public void getHttpsUrl() throws RemoteBackendException {
String url=client.getHttpsUrl().RFile(remotePath);
System.out.println("HttpUrl generated: "+url);
}
// @After
// public void removeRemoteFile() throws RemoteBackendException{
// String id=client.remove().RFile(remotePath);
// List<StorageObject> list=client.showDir().RDir("test/img4");
// assertTrue(list.isEmpty());
// }
@Test
public void testSerialStorage(){
long start=System.currentTimeMillis();
int n=100;
for(int i = 0; i<n;i++){
System.out.println("retrieve "+(i+1)+" url");
//get ID
System.out.println(client.getHttpsUrl().RFile(id));
}
long time=System.currentTimeMillis() - start;
System.out.println("test serial storage. Total time on "+n+" objects: "+time);
}
@After
public void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);
List<StorageObject> list=client.showDir().RDir("test/img4");
assertTrue(list.isEmpty());
}
private void setLocalResources() {

View File

@ -14,7 +14,7 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
public final class Costants {
public static final MemoryType DEFAULT_MEMORY_TYPE = MemoryType.PERSISTENT;
public static final String DEFAULT_SCOPE_STRING="/gcube/devsec";
public static final String DEFAULT_SCOPE_STRING="/gcube";
public static final String DEFAULT_PASS_PHRASE="this is a phrasethis is a phrase";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 346 KiB