test updated

This commit is contained in:
Lucio Lelii 2022-11-15 12:22:54 +01:00
parent 9c5ba19f43
commit 28e4e9eb56
1 changed files with 57 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.IntStream;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
@ -41,7 +42,7 @@ public class Items {
private static final String propFile = "/home/lucio/tokens.properties";
private static final String tokens = "dev-root";
private static final String tokens = "dev-devvre";
//private static final String tokens = "prod-root";
@BeforeClass
@ -98,14 +99,67 @@ public class Items {
StorageHubClient shc = new StorageHubClient();
String vresFile = "/home/lucio/Downloads/gardaland_prenotazione.pdf";
String vresFile = "/home/lucio/Downloads/stampa_crossover_retro.pdf";
File file = new File(vresFile);
System.out.println(shc.uploadFileOnVolatile(file));
try ( InputStream fileIS = new FileInputStream(file)){
shc.getWSRoot().uploadFile(fileIS, "stampa_crossover_retro.pdf", "description");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void removeTest() {
try {
StorageHubClient shc = new StorageHubClient();
FolderContainer root = shc.getWSRoot();
root.list().getContainers().stream().filter(c -> c.get().getTitle().startsWith("stressTest")).forEach(c-> {
try {
c.forceDelete();
} catch (StorageHubException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});;
}catch (Exception e ) {
e.printStackTrace();
}
}
@Test
public void stressTest() {
try {
IntStream.range(1, 100).forEach( i-> {
try {
StorageHubClient shc = new StorageHubClient();
FolderContainer vre = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
FolderContainer fc = vre.newFolder("folder"+i, "");
IntStream.range(1, 3).forEach(k -> {
String vresFile = "/home/lucio/Scaricati/NLP-Hub-Algorithms.pptx";
File file = new File(vresFile);
try ( InputStream fileIS = new FileInputStream(file)){
fc.uploadFile(fileIS, "file"+k, "description");
} catch (Exception e) {
e.printStackTrace();
}
});
} catch (StorageHubException e) {
System.out.println("error creating stressTest"+i);
}
});
}catch (Exception e ) {
e.printStackTrace();
}
}
@Test
public void search() {
try {