Browse Source

add new JUnitTest cases

master
Roberto Cirillo 2 months ago
parent
commit
c50b3d6ba8
  1. 8
      src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java
  2. 30
      src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java

8
src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java

@ -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();
}

30
src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java

@ -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);
}
@ -55,12 +57,26 @@ public class UrlResolverTest {
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() {

Loading…
Cancel
Save