fix fillConnectionFields method; update some JUnit Test classes

This commit is contained in:
Roberto Cirillo 2021-11-19 12:41:39 +01:00
parent 7fd4e6c0c1
commit 4d76042cb3
5 changed files with 13 additions and 63 deletions

View File

@ -102,10 +102,9 @@ public class ISClientConnector {
private String[] fillConnectionFields(ServiceEndpoint resource) {
logger.debug("fillConnectionsFields method ");
if(resource!=null){
<<<<<<< HEAD
logger.debug("checking resource "+resource.id());
ArrayList<String> server=new ArrayList<String> ();//new String[resource.profile().accessPoints().size()];
if(!(getBackendType().equals(BackendType.MongoDB.name()))) {
if(!(getBackendType(resource).equals(BackendType.MongoDB.name()))) {
logger.info("searching backend: "+getBackendType());
for (AccessPoint ap:resource.profile().accessPoints()) {
if( (ap.name().equals(getBackendType()))){
@ -134,25 +133,6 @@ public class ISClientConnector {
// TODO Auto-generated catch block
e.printStackTrace();
}
=======
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();
srvs.add(ap.address());
// if presents, try to get user and password
setUsername(ap.username());
// set password default value to empty string
setPassword("");
if(getUsername() != null && getUsername().length() > 0){
try {
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
>>>>>>> master
}
i++;
}
@ -160,13 +140,13 @@ public class ISClientConnector {
logger.info("credentials Mongodb: "+getUsername()+" "+getPassword());
// setBackendType(retrievePropertyValue(resource, "type"));
}
<<<<<<< HEAD
=======
String [] server=new String[srvs.size()];
server = srvs.toArray(server);
setBackendType(retrievePropertyValue(resource, "type"));
>>>>>>> master
//<<<<<<< HEAD
//
//=======
// String [] server=new String[srvs.size()];
// server = srvs.toArray(server);
// setBackendType(retrievePropertyValue(resource, "type"));
//>>>>>>> master
String [] volatileHost= new String [1];
volatileHost[0]=retrievePropertyValue(resource, "volatile");
setVolatileHost(volatileHost);

View File

@ -39,13 +39,9 @@ public class DownloadsTest {
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";
<<<<<<< HEAD
@BeforeClass
public static void getClient() throws RemoteBackendException{
=======
@Before
public void getClient() throws RemoteBackendException{
>>>>>>> master
ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
// ScopeProvider.instance.set(scope);
try {

View File

@ -53,12 +53,6 @@ public class ForceCloseTest {
@Test
public void forceCloseTest(){
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
client.forceClose();
//download
try {
@ -66,23 +60,9 @@ public class ForceCloseTest {
}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

View File

@ -8,7 +8,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
@ -16,7 +15,6 @@ 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.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -88,16 +86,12 @@ public class HLcheckTest {
@Test
public void downloadBySpecificIdOnlyForTest() throws RemoteBackendException{
<<<<<<< HEAD
// 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 file="/Users/roberto/VivianaOtero/detailed_simulation_4327.csv";
String idReturned=client.get().LFile(file).RFile("60830489d56b08199c3407c6");
=======
//// String file="/home/rcirillo-pc/Downloads/ce1159aa-a87f-4074-a3f9-36fe26d62f87-d4science.research-infrastructures.eu-gCubeApps-DESCRAMBLE.zip";
// String file="/Users/roberto/VivianaOtero/detailed_simulation_4327.csv";
// String idReturned=client.get().LFile(file).RFile("60830489d56b08199c3407c6");
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");
>>>>>>> master
System.out.println("downloadById id: "+idReturned);
File f =new File(newFilePath);
// File f =new File(file);

View File

@ -17,6 +17,6 @@ public final class Costants {
public static final MemoryType DEFAULT_MEMORY_TYPE = MemoryType.PERSISTENT;
public static final String DEFAULT_SCOPE_STRING="/gcube/devsec/devVRE";//"/gcube/devNext/NextNext";//"/gcube/devsec/devVRE";
public static final String DEFAULT_PASS_PHRASE="this is a phrasethis is a phrase";
public static final BackendType BACKEND_TYPE=BackendType.S3;
public static final BackendType BACKEND_TYPE=BackendType.MongoDB;
}