Fixed tests
This commit is contained in:
parent
e6c16252b9
commit
24765a9bee
|
@ -28,10 +28,10 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class TestClientCalls {
|
public class TestClientCalls {
|
||||||
|
|
||||||
static String hostname="http://thredds-pre-d4s.d4science.org:80";
|
static String hostname="http://thredds-d-d4s.d4science.org:80";
|
||||||
// static String hostname="https://geoserver1-spatial-dev.d4science.org";
|
// static String hostname="https://geoserver1-spatial-dev.d4science.org";
|
||||||
// static String scope="/gcube/devNext/NextNext";
|
static String scope="/gcube/devsec/devVRE";
|
||||||
static String scope="/pred4s/preprod/preVRE";
|
// static String scope="/pred4s/preprod/preVRE";
|
||||||
static Client client;
|
static Client client;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,13 @@ package org.gcube.data.transfer.library;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -26,23 +32,33 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class TransfererTest {
|
public class TransfererTest {
|
||||||
|
|
||||||
static String hostname="http://node3-d-d4s.d4science.org:80";
|
static String hostname="http://thredds-d-d4s.d4science.org:80";
|
||||||
// static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea";
|
// static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea";
|
||||||
static String scope="/gcube/devNext";
|
static String scope="/gcube/devsec/devVRE";
|
||||||
|
|
||||||
static DataTransferClient client;
|
static DataTransferClient client;
|
||||||
|
|
||||||
|
static String link="http://maven.research-infrastructures.eu/nexus/content/groups/gcube-releases-all/org/gcube/data/transfer/data-transfer-model/1.0.0-3.11.0-128236/data-transfer-model-1.0.0-3.11.0-128236-javadoc.jar";
|
||||||
|
|
||||||
|
static File tempFile;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init() throws UnreachableNodeException, ServiceNotFoundException, HostingNodeNotFoundException{
|
public static void init() throws UnreachableNodeException, ServiceNotFoundException, HostingNodeNotFoundException, IOException{
|
||||||
TokenSetter.set(scope);
|
TokenSetter.set(scope);
|
||||||
client=DataTransferClient.getInstanceByEndpoint(hostname);
|
client=DataTransferClient.getInstanceByEndpoint(hostname);
|
||||||
// client=DataTransferClient.getInstanceByNodeId(nodeId);
|
// client=DataTransferClient.getInstanceByNodeId(nodeId);
|
||||||
|
|
||||||
|
// Download file from mvn
|
||||||
|
InputStream in = new URL(link).openStream();
|
||||||
|
Path file=Files.createTempFile("test", ".jar");
|
||||||
|
Files.copy(in, file, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
tempFile=file.toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void localFile() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
public void localFile() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
||||||
for(int i=0;i<3;i++){
|
for(int i=0;i<3;i++){
|
||||||
String localFile="/home/fabio/Dropbox/Mindless/01- COMA - Mindless.mp3";
|
String localFile=tempFile.getAbsolutePath();
|
||||||
String transferredFileName="Mindless.mp3";
|
String transferredFileName="Mindless.mp3";
|
||||||
Destination dest=new Destination(transferredFileName);
|
Destination dest=new Destination(transferredFileName);
|
||||||
dest.setOnExistingFileName(DestinationClashPolicy.REWRITE);
|
dest.setOnExistingFileName(DestinationClashPolicy.REWRITE);
|
||||||
|
@ -56,7 +72,7 @@ public class TransfererTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void httpUrl() throws MalformedURLException, InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
public void httpUrl() throws MalformedURLException, InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
||||||
String link="http://maven.research-infrastructures.eu/nexus/service/local/artifact/maven/redirect?r=central&g=org.apache.commons&a=commons-io&v=1.3.2&e=jar&c=javadoc";
|
|
||||||
System.out.println(client.httpSource(link,new Destination("Some import")));
|
System.out.println(client.httpSource(link,new Destination("Some import")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +80,7 @@ public class TransfererTest {
|
||||||
@Test
|
@Test
|
||||||
public void storage() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, RemoteBackendException, FileNotFoundException, InvalidDestinationException, DestinationNotSetException{
|
public void storage() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, RemoteBackendException, FileNotFoundException, InvalidDestinationException, DestinationNotSetException{
|
||||||
TokenSetter.set(scope);
|
TokenSetter.set(scope);
|
||||||
String toUpload="/home/fabio/Documents/Personal/DND/Incantesimi 3.5 - Mago e Stregone.pdf";
|
String toUpload=tempFile.getAbsolutePath();
|
||||||
String id=StorageUtils.putOntoStorage(new File(toUpload));
|
String id=StorageUtils.putOntoStorage(new File(toUpload));
|
||||||
Destination dest=new Destination("some/where","My Pdf.pdf");
|
Destination dest=new Destination("some/where","My Pdf.pdf");
|
||||||
TransferResult res=client.storageId(id,dest);
|
TransferResult res=client.storageId(id,dest);
|
||||||
|
@ -95,6 +111,6 @@ public class TransfererTest {
|
||||||
public void decompressPlugin() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
public void decompressPlugin() throws InvalidSourceException, SourceNotSetException, FailedTransferException, InitializationException, InvalidDestinationException, DestinationNotSetException{
|
||||||
HashMap<String,String> invocationParams=new HashMap<String,String>();
|
HashMap<String,String> invocationParams=new HashMap<String,String>();
|
||||||
invocationParams.put("SOURCE_ARCHIVE", PluginInvocation.DESTINATION_FILE_PATH);
|
invocationParams.put("SOURCE_ARCHIVE", PluginInvocation.DESTINATION_FILE_PATH);
|
||||||
client.localFile(new File("/home/fabio/eclipse/Eclipse-mars/lombok.jar"), new Destination("MyJar"),Collections.singleton(new PluginInvocation("DECOMPRESS", invocationParams)));
|
client.localFile(tempFile, new Destination("MyJar"),Collections.singleton(new PluginInvocation("DECOMPRESS", invocationParams)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue