fix JUnit tests; upgrade JUnit to 4.12 version

This commit is contained in:
Roberto Cirillo 2021-03-12 17:20:09 +01:00
parent 8a5cbc8ed3
commit dfb11e63dc
14 changed files with 170 additions and 179 deletions

View File

@ -59,7 +59,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -46,7 +46,7 @@ public class ISClientConnector {
/**
* identify the ServiceEndpoint name of the storage-manager backend
*/
public final String NAME="StorageManager-S3";
public final String NAME="StorageManager";
public ISClientConnector(String backendType){
setBackendType(backendType);

View File

@ -9,34 +9,34 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class CopyDirTest {
private String owner="rcirillo";
private static String owner="rcirillo";
// local file
private String localPath="src/test/resources/CostaRica1.jpg";
private static String localPath="src/test/resources/CostaRica1.jpg";
//remote files
private String remoteOriginalFilePath="/test/img/original.jpg";
private String remoteOriginalFilePath2="/test/img/original2.jpg";
private String remoteCopyFilePath="/test/copyImg/img/original.jpg";
private String remoteCopyFilePath2="/test/copyImg/img/original2.jpg";
private static String remoteOriginalFilePath="/test/img/original.jpg";
private static String remoteOriginalFilePath2="/test/img/original2.jpg";
private static String remoteCopyFilePath="/test/copyImg/img/original.jpg";
private static String remoteCopyFilePath2="/test/copyImg/img/original2.jpg";
//remote directories
private String remoteOriginalDirPath="/test/img/";
private String remoteCopyDirPath="/test/copyImg";
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private static String remoteOriginalDirPath="/test/img/";
private static String remoteCopyDirPath="/test/copyImg";
private static String absoluteLocalPath;
private static String newFilePath="src/test/resources";
private static IClient client;
// private String scope="/gcube/devsec";//"/d4science.research-infrastructures.eu/FARM";//"/CNR.it/ISTI";//"/gcube"; // "/d4science.research-infrastructures.eu/FARM/VTI";//
private String serviceClass="JUnitTest-CopyDir";
private String serviceName="StorageManager";
private static String serviceClass="JUnitTest-CopyDir";
private static String serviceName="StorageManager";
@Before
public void getClient() throws RemoteBackendException{
@BeforeClass
public static void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
@ -124,15 +124,15 @@ public class CopyDirTest {
}
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunitLink.jpg";
absoluteLocalPath=new File(localPath).getAbsolutePath();
}
@After
public void deleteRemoteDir(){
@AfterClass
public static void deleteRemoteDir(){
client.removeDir().RDir(remoteCopyDirPath);
client.removeDir().RDir(remoteOriginalDirPath);
}

View File

@ -48,9 +48,6 @@ public class CopyTest {
e.printStackTrace();
}
setLocalResources();
// String id=client.put(true).LFile(absoluteLocalFrog).RFile(remoteOriginalFilePath);
// System.out.println("id of the following path "+remoteOriginalFilePath+" is: "+id );
// assertNotNull(id);
}
@ -60,7 +57,7 @@ public class CopyTest {
*/
@Test
public void removeCopiedFileTest() throws RemoteBackendException {
// put orignal file
// put orignal file
String id=client.put(true).LFile(absoluteLocalFrog).RFile(remoteOriginalFilePath);
System.out.println("id of the following path "+remoteOriginalFilePath+" is: "+id );
//first copy
@ -69,6 +66,7 @@ public class CopyTest {
File f =new File(newFilePath);
System.out.println("path new File downloaded: "+f.getAbsolutePath());
assertTrue(f.exists());
// removing local and copied file
removeLocalFile();
removeCopiedFile(remoteCopyPath, "test/copyDir/");
checkOriginalFileIsAlive();

View File

@ -17,30 +17,32 @@ 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.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class DownloadsTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica1.jpg";
private String remotePath="/test/img/CostaRica1.jpg";
private String remotePath1="/test/img/CostaRica2.jpg";
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 serviceClass="JUnitTest";
private String serviceName="StorageManager";
private static String owner="rcirillo";
private static String localPath="src/test/resources/CostaRica1.jpg";
private static String remotePath="/test/img/CostaRica1.jpg";
private static String remotePath1="/test/img/CostaRica2.jpg";
private static String absoluteLocalPath;
private static String newFilePath="src/test/resources";
private static 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 static String serviceClass="JUnitTest";
private static String serviceName="StorageManager";
private String NotExistingId="5a5c7d1d1b9b060285bbe2bd";
private String id;
private String id1;
private static String id;
private static String id1;
private String encryptedId="OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SG1EN2JFNXIELzZ1czdsSkRIa0Evd3VzcGFHU3J6L2RHbWJQNStIS0N6Yz0";//"OE5tOCtuTUt5eXVNd3JkRDlnRFpDY1h1MVVWaTg0cUtHbWJQNStIS0N6Yz0";//"SThtL0xRU281M2UzY29ldE44SkhkbzVkMlBWVmM4aEJHbWJQNStIS0N6Yz0";//"dExaYzNKelNyQVZMemxpcXplVXYzZGN4OGZTQ2w4aU5HbWJQNStIS0N6Yz0";//"Mm9nc0tZbXR1TVI2cVRxL3pVUElrRXJkbk9vVDY2eEJHbWJQNStIS0N6Yz0";//"FemRmUEFtRGVZMnozcEdBekVHU3E4Skt5dkh2OXJObHFHbWJQNStIS0N6Yz0";//"L0p3OGJjUHhFaEJoTmppdjlsK0l0Z0h1b3VpVlloUzVHbWJQNStIS0N6Yz0";//"NWJTRFdxQkQxclJHV05FbExrRDJjL0g4QTBwSnV1TVdHbWJQNStIS0N6Yz0";//"M2JIM2hqNUNyRkxBdG00cnRaWDBpUGxRTmtVQmtEdXBHbWJQNStIS0N6Yz0";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"huivj74/QCHnj376YGe/FicgYHSHcwph7SoMty7FBmAh+80AzGQtOdanne6zJBd5";//"lfV6BqnBWUbN5dUiQ6xpkMgI69wEwcm6Ygh60bFzaL3h2Run5e9uZMoTix+ykL5H";//"bksxMGVWTlZ3WjM5Z1ZXYXlUOUtMZzVSNlBhZXFGb05HbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQzZXQ5UVNxWHZURGJHbWJQNStIS0N6Yz0";//"bEVydmtsOHhCclZMZGd4cEtnTVQz";//"cHEvek1sbjdBaWJkc0s4SzZpSUJpU0c2ZEgyOEVyUGJHbWJQNStIS0N6Yz0";//"RnpoMy9ZaVRoRkZjbk8ybGx0QnlRR";//"L1pWTlV3ZWxPbHRyMloxZ0JnWUVHdHYvUnZDVHJiMTBHbWJQNStIS0N6Yz0";
@Before
public void getClient() throws RemoteBackendException{
// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
ScopeProvider.instance.set(scope);
@BeforeClass
public static void getClient() throws RemoteBackendException{
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);
@ -50,10 +52,11 @@ public class DownloadsTest {
}
setLocalResources();
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
System.out.println("upload done ");
System.out.println("upload done. Returned id "+id);
id1=client.put(true).LFile(absoluteLocalPath).RFile(remotePath1);
System.out.println("upload done ");
System.out.println("upload done. Returned id1: "+id1);
assertNotNull(id);
assertNotNull(id1);
}
@ -97,8 +100,8 @@ public class DownloadsTest {
@Test
public void downloadByInputStream() throws IOException, InterruptedException {
downloadByIS(id);
downloadByIS(id1);
downloadByIS(id);
}
@ -164,8 +167,8 @@ public class DownloadsTest {
}
@After
public void removeRemoteFile() throws RemoteBackendException{
@AfterClass
public static void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);
System.out.println("removeRemotePath id: "+id);
String id1=client.remove().RFile(remotePath1);
@ -181,7 +184,7 @@ public class DownloadsTest {
}
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/Junit.jpg";

View File

@ -1,6 +1,7 @@
package org.gcube.contentmanager.storageclient.test;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import static org.junit.Assert.assertNotNull;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
import java.util.ArrayList;
import java.util.List;
@ -92,6 +93,7 @@ public class FwsQueryTest {
System.out.println("retrieve server from RuntimeResource");
ISClientConnector isConnector= new ISClientConnector();
ServiceEndpoint resource = isConnector.getStorageEndpoint(scope);
assertNotNull(resource);
String[] server=isConnector.retrieveConnectionInfo(resource);
for(int j=0; j<server.length; j++){
System.out.println("s" +j+" = "+server[j]);

View File

@ -14,26 +14,28 @@ 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.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class GetMetaFileTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica1.jpg";
private String remotePath="/test/img2/CostaRica1.jpg";
private String remotePath2="/test/img2/CostaRica2.jpg";
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private static String owner="rcirillo";
private static String localPath="src/test/resources/CostaRica1.jpg";
private static String remotePath="/test/img2/CostaRica1.jpg";
private static String remotePath2="/test/img2/CostaRica2.jpg";
private static String absoluteLocalPath;
private static String newFilePath="src/test/resources";
private static 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 serviceClass="JUnitTest";
private String serviceName="StorageManager";
private String id;
private String id2;
private static String serviceClass="JUnitTest";
private static String serviceName="StorageManager";
private static String id;
private static String id2;
@Before
public void getClient() throws RemoteBackendException{
@BeforeClass
public static void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
@ -81,10 +83,10 @@ public class GetMetaFileTest {
}
@After
public void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);
String id2=client.remove().RFile(remotePath2);
@AfterClass
public static void removeRemoteFile() throws RemoteBackendException{
client.remove().RFile(remotePath);
client.remove().RFile(remotePath2);
List<StorageObject> list=client.showDir().RDir("test/img2");
assertTrue(list.isEmpty());
}
@ -107,7 +109,7 @@ public class GetMetaFileTest {
}
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunit.jpg";

View File

@ -20,6 +20,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class HLcheckTest {
@ -30,13 +31,13 @@ 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="/gcube";//"/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;
private String id1;
@Before
// @Before
public void getClient() throws RemoteBackendException{
// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
ScopeProvider.instance.set(scope);
@ -56,7 +57,7 @@ public class HLcheckTest {
}
@Test
// @Test
public void downloadByPath() throws RemoteBackendException {
String idFound=client.get().LFile(newFilePath).RFile(remotePath);
System.out.println("downloadByPath id: "+idFound+" id orig "+id );
@ -66,14 +67,14 @@ public class HLcheckTest {
removeLocalFile();
}
@Test
// @Test
public void downloadByInputStream() throws IOException, InterruptedException {
downloadByIS(id);
downloadByIS(id1);
}
@Test
// @Test
public void downloadById() throws RemoteBackendException{
// String idReturned=client.get().LFile(newFilePath).RFileById(id);
String idReturned=client.get().LFile(newFilePath).RFile(id);
@ -85,7 +86,7 @@ public class HLcheckTest {
removeLocalFile();
}
@Test
// @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";
@ -101,7 +102,7 @@ public class HLcheckTest {
@After
// @After
public void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);
System.out.println("removeRemotePath id: "+id);

View File

@ -9,31 +9,30 @@ 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.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class MoveDirTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica1.jpg";
private String remoteOriginalFilePath="/test/move/img/original.jpg";
private String remoteOriginalFilePath2="/test/move/img/original2.jpg";
private String remoteMovePath="/test/move/";
private String remoteMovePath2="/test/trash/";
private String remoteMoveFilePath="/test/trash/move/img/original.jpg";
private String remoteMoveFilePath2="/test/trash/move/img/original2.jpg";
private String absoluteLocalPath;
private String newFilePath="src/test/resources";
private IClient client;
private static String owner="rcirillo";
private static String localPath="src/test/resources/CostaRica1.jpg";
private static String remoteOriginalFilePath="/test/move/img/original.jpg";
private static String remoteOriginalFilePath2="/test/move/img/original2.jpg";
private static String remoteMovePath="/test/move/";
private static String remoteMovePath2="/test/trash/";
private static String remoteMoveFilePath="/test/trash/move/img/original.jpg";
private static String remoteMoveFilePath2="/test/trash/move/img/original2.jpg";
private static String absoluteLocalPath;
private static String newFilePath="src/test/resources";
private static IClient client;
// private String scope="/gcube/devsec";//"/d4science.research-infrastructures.eu";//"/CNR.it/ISTI";//"/gcube"; // "/d4science.research-infrastructures.eu/FARM/VTI";//
private String serviceClass="JUnitTest-MoveDir";
private String serviceName="StorageManager";
private static String serviceClass="JUnitTest-MoveDir";
private static String serviceName="StorageManager";
@Before
public void getClient() throws RemoteBackendException{
@BeforeClass
public static void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
@ -82,20 +81,20 @@ public class MoveDirTest {
}
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunitMoveOp.jpg";
absoluteLocalPath=new File(localPath).getAbsolutePath();
}
private void removeLocalFile(){
private static void removeLocalFile(){
File f=new File(newFilePath);
f.delete();
assertFalse(f.exists());
}
private void checkOriginalFileIsAlive(String remoteOriginalFilePath) {
private static void checkOriginalFileIsAlive(String remoteOriginalFilePath) {
String id=null;
try{
id=client.get().LFile(newFilePath).RFile(remoteOriginalFilePath);
@ -103,15 +102,15 @@ public class MoveDirTest {
assertNull(id);
}
private void checkMoveFileIsAlive() {
private static void checkMoveFileIsAlive() {
String id=client.get().LFile(newFilePath).RFile(remoteMovePath);
System.out.println("id link is alive: "+id);
assertNotNull(id);
removeLocalFile();
}
@After
public void removeRemoteDirs(){
@AfterClass
public static void removeRemoteDirs(){
client.removeDir().RDir(remoteMovePath2);
}

View File

@ -12,29 +12,28 @@ 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.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class PropertiesTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica1.jpg";
private String remotePath="/test/mimeTest/CostaRica1.jpg";
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 serviceClass="JUnitTest";
private String serviceName="StorageManager";
private String id;
private String field="mimetype";
private String value="image/png";
private static String owner="rcirillo";
private static String localPath="src/test/resources/CostaRica1.jpg";
private static String remotePath="/test/mimeTest/CostaRica1.jpg";
private static String absoluteLocalPath;
private static String newFilePath="src/test/resources";
private static IClient client;
private static 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 static String serviceClass="JUnitTest";
private static String serviceName="StorageManager";
private static String id;
private static String field="mimetype";
private static String value="image/png";
@Before
public void getClient() throws RemoteBackendException{
@BeforeClass
public static void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
@ -46,6 +45,8 @@ public class PropertiesTest {
setLocalResources();
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
assertNotNull(id);
String result= client.setMetaInfo(field, value).RFile(id);
}
@ -82,17 +83,16 @@ public class PropertiesTest {
}
// @Test
@Test
public void setProperty() throws RemoteBackendException {
String result= client.setMetaInfo(field, value).RFile(id);
RequestObject f= client.getMetaFile().RFile(remotePath);
assertNotNull(f);
print(f);
}
@After
public void removeRemoteFile() throws RemoteBackendException{
@AfterClass
public static void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);
List<StorageObject> list=client.showDir().RDir("test/mimeTest");
assertTrue(list.isEmpty());
@ -111,14 +111,14 @@ public class PropertiesTest {
}
private void removeLocalFile(){
private static void removeLocalFile(){
File f=new File(newFilePath);
f.delete();
assertFalse(f.exists());
}
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
newFilePath=dir+"/testJunit.jpg";

View File

@ -33,7 +33,8 @@ public class RemoveVolatileArea {
@Before
public void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
// 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);
@ -47,7 +48,7 @@ public class RemoveVolatileArea {
}
@Test
// @Test
public void removeVolatile(){
client.removeDir().RDir("/Home/roberto.cirillo/Workspace/Trash/");
}

View File

@ -16,6 +16,7 @@ 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.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
@ -24,28 +25,28 @@ import org.junit.Test;
*/
public class SoftCopyTest {
private String owner="rcirillo";
private String localFrog="src/test/resources/CostaRica1.jpg";//"src/test/resources/testFile.txt";//"src/test/resources/CostaRica1.jpg";
private String localDog="src/test/resources/dog.jpg";
private static String owner="rcirillo";
private static String localFrog="src/test/resources/CostaRica1.jpg";//"src/test/resources/testFile.txt";//"src/test/resources/CostaRica1.jpg";
private static String localDog="src/test/resources/dog.jpg";
private String remoteOriginalFilePath="/test/frog.jpg";
private String remoteCopyPath="/test/SoftCopy1/frog1.jpg";
private String remoteCopyPath2="/test/SoftCopy2/frog2.jpg";
private String remoteCopyPath3="/test/SoftCopy3/frog3.jpg";
private String remoteCopyPath3="/test/SoftCopy3/frog3.jpg";
private String remoteCopyDir="/test/copyDir/";
private String absoluteLocalFrog;
private String absoluteLocalDog;
private String newFilePath="src/test/resources";
private IClient client;
private String serviceClass="CopyTest";
private String serviceName="StorageManager";
private String newFilePath2;
private long frogSize;
private long dogSize;
private static String absoluteLocalFrog;
private static String absoluteLocalDog;
private static String newFilePath="src/test/resources";
private static IClient client;
private static String serviceClass="CopyTest";
private static String serviceName="StorageManager";
private static String newFilePath2;
private static long frogSize;
private static long dogSize;
@Before
public void getClient() throws RemoteBackendException{
@BeforeClass
public static void getClient() throws RemoteBackendException{
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
@ -272,7 +273,7 @@ public class SoftCopyTest {
}
private void setLocalResources() {
private static void setLocalResources() {
File f1=new File(localFrog);
absoluteLocalFrog=f1.getAbsolutePath();
frogSize=f1.length();

View File

@ -20,24 +20,25 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class UploadsTest {
private String owner="rcirillo";
private String localPath="src/test/resources/CostaRica.jpg";//"src/test/resources/empty.txt";//"src/test/resources/CostaRica1.jpg";
private String localPath1="src/test/resources/CostaRica1.jpg";
private static String owner="rcirillo";
private static String localPath="src/test/resources/CostaRica.jpg";//"src/test/resources/empty.txt";//"src/test/resources/CostaRica1.jpg";
private static String localPath1="src/test/resources/CostaRica1.jpg";
private String remotePath="/tests/img/tabulardatadump.tar.gz";//"/tests/img/CostaRica1.jpg";//"/tests/img/empty.txt";//
private String absoluteLocalPath;
private String absoluteLocalPath1;
private static String absoluteLocalPath;
private static String absoluteLocalPath1;
// private String newFilePath="src/test/resources";
private IClient client;
private static IClient client;
// private String scope="/gcube";//"/d4science.research-infrastructures.eu"; //"/d4science.research-infrastructures.eu"; //"/gcube/devsec";//"/d4science.research-infrastructures.eu"; //"/CNR.it";////"/gcube/devsec";//""/CNR.it/ISTI";//"/gcube";//"/gcube/devNext/NextNext";//
private String serviceClass="JUnitTest";
private String serviceName="StorageManager";
private static String serviceClass="JUnitTest";
private static String serviceName="StorageManager";
@Before
public void getClient(){
@BeforeClass
public static void getClient(){
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
@ -136,10 +137,12 @@ public class UploadsTest {
private void setLocalResources() {
private static void setLocalResources() {
absoluteLocalPath=new File(localPath).getAbsolutePath();
String dir=new File(absoluteLocalPath).getParent();
absoluteLocalPath1=new File(localPath1).getAbsolutePath();
String dir1=new File(absoluteLocalPath1).getParent();
}
}

View File

@ -58,50 +58,28 @@ public class UrlResolverByIdTest {
}
// @Test
public void getUrlbyIdNotPaylloadCheck() throws RemoteBackendException {
String url=client.getUrl(true).RFile(remotePath);
System.out.println("url generated: "+url);
assertNotNull(url);
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
System.out.println("id retrieved: "+id);
client.moveFile().from(remotePath).to(newPath);
verifyUrl(url);
}
@Test
public void getUrlbyId() throws RemoteBackendException {
public void getHttpsbyId() throws RemoteBackendException {
// id="5aa16dfe02cadc50bff0eaf1";//"5aa16dfe02cadc50bff0eaf7";//"5a0c1cddf1d47d0c2fea0c1c";//"5a0c1cddf1d47d0c2fea0c1c";//"5a056737f1d47d0c2fe1ccb8";//"5a048c4cf1d47d0c2fe10537";//client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
String url=client.getHttpUrl(true).RFile(id);
// String url=client.getUrl().RFileById(id);
System.out.println("httpUrl generated: "+url);
String url=client.getHttpsUrl(true).RFile(id);
System.out.println("httpsUrl generated: "+url);
assertNotNull(url);
// id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
// System.out.println("id retrieved: "+id);
// client.moveFile().from(remotePath).to(newPath);
// verifyUrl(url);
verifyUrl(url);
}
// @Test
// public void getUrlbyId() throws RemoteBackendException {
//// id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
// String url=client.getHttpUrl().RFileById("5aa16dfe02cadc50bff0eaf7");
// System.out.println("url generated: "+url);
// assertNotNull(url);
//// url=url+"-VLT";
// System.out.println("id retrieved: "+id);
// client.moveFile().from(remotePath).to(newPath);
// verifyUrl(url);
// }
@Test
public void getUrlbyPath() throws RemoteBackendException {
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
String url=client.getUrl(true).RFile(remotePath);
String url=client.getHttpsUrl(true).RFile(remotePath);
System.out.println("url generated: "+url);
assertNotNull(url);
System.out.println("id retrieved: "+id);
@ -113,7 +91,7 @@ public class UrlResolverByIdTest {
@Test
public void getFilebyEncryptedId() throws RemoteBackendException {
id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
String url=client.getUrl(true).RFile(remotePath);
String url=client.getHttpsUrl(true).RFile(remotePath);
System.out.println("url generated: "+url);
assertNotNull(url);
String idEncrypted=url.substring(url.lastIndexOf(".org/")+5);
@ -129,7 +107,7 @@ public class UrlResolverByIdTest {
* download the file and verify if the file exist
* @param url
*/
@Deprecated
private void verifyUrl(String url) {
Handler.activateProtocol();
URL smsHome = null;
@ -160,6 +138,9 @@ public class UrlResolverByIdTest {
assertTrue(f.exists());
}
@After
public void removeRemoteFile() throws RemoteBackendException{
String id=client.remove().RFile(remotePath);