You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2016/02/12 14:22:02 UTC

[1/4] incubator-taverna-osgi git commit: Test DownloadMnagerImpl

Repository: incubator-taverna-osgi
Updated Branches:
  refs/heads/master be135cb32 -> c41687d21


Test DownloadMnagerImpl


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/commit/f06a0028
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/tree/f06a0028
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/diff/f06a0028

Branch: refs/heads/master
Commit: f06a00285bc0f61d484dc2782663694b0f463239
Parents: be135cb
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 11 18:38:42 2016 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 11 18:38:42 2016 +0000

----------------------------------------------------------------------
 .../download/impl/TestDownloadManagerImpl.java  | 61 ++++++++++++++++++++
 1 file changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/f06a0028/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
new file mode 100644
index 0000000..10fb30c
--- /dev/null
+++ b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
@@ -0,0 +1,61 @@
+package org.apache.taverna.download.impl;
+
+import java.io.File;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collections;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+
+import org.apache.taverna.download.DownloadException;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class TestDownloadManagerImpl {
+	
+	/**
+	 * This test should remain commented out 
+	 * as it relies on a third-party 
+	 * web service.
+	 * 
+	 * Verifies 
+	 * 
+	 */
+	@Test(expected=DownloadException.class)
+	public void handle300MultipleChoice() throws Exception {
+		DownloadManagerImpl dl = new DownloadManagerImpl();
+		Path pomFile = Files.createTempFile("test", ".pom");
+		// NOTE: The below URL is a Taverna 2 POM - not related to 
+		// taverna-plugin-impl
+		URL wrongURL = new URL("http://192.185.115.65/~diana/DIANA_plugin_updated/test-plugins/gr/dianatools/diana.services-activity/1.0-SNAPSHOT/diana.services-activity-1.0-SNAPSHOT.pom");
+		dl.download(wrongURL, pomFile.toFile(), "MD5");	
+	}
+	
+	/**
+	 * Test downloading a file:/// to a File, checking md5 hashsum.
+	 * 
+	 * This might seem silly, but avoids spinning up a Jetty instance
+	 * just for this unit test.
+	 * 
+	 */
+	@Test
+	public void downloadLocalFile() throws Exception {
+		Path example = Files.createTempFile("example", ".txt");
+		Files.write(example, "Hello world".getBytes(US_ASCII)); // No newline
+		Path exampleMd5 = example.resolve(example.getFileName() + ".md5");
+//		stain@biggie:~$ echo -n "Hello world"|md5sum
+//		3e25960a79dbc69b674cd4ec67a72c62  -
+		Files.write(exampleMd5, "3e25960a79dbc69b674cd4ec67a72c62".getBytes(US_ASCII));
+		
+		DownloadManagerImpl dl = new DownloadManagerImpl();
+		
+		Path toFile = Files.createTempFile("downloaded", ".txt");
+		
+		dl.download(example.toUri().toURL(), toFile.toFile(), "MD5");
+		String hello = Files.readAllLines(toFile, US_ASCII).get(0);
+		
+		assertEquals("Hello world", hello);
+		
+	}
+	
+}


[2/4] incubator-taverna-osgi git commit: TAVERNA-893 test 300 Multiple Choices handling

Posted by st...@apache.org.
TAVERNA-893 test 300 Multiple Choices handling

.. also fix downloadLocalFile test :)


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/commit/db3bd18c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/tree/db3bd18c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/diff/db3bd18c

Branch: refs/heads/master
Commit: db3bd18c5d7277a7423c0c56608ff251648f6d97
Parents: f06a002
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Feb 12 13:19:44 2016 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Feb 12 13:19:44 2016 +0000

----------------------------------------------------------------------
 .../download/impl/TestDownloadManagerImpl.java  | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/db3bd18c/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
index 10fb30c..07c02d7 100644
--- a/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
+++ b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
@@ -1,24 +1,22 @@
 package org.apache.taverna.download.impl;
 
-import java.io.File;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.junit.Assert.assertEquals;
+
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.Collections;
-import static java.nio.charset.StandardCharsets.US_ASCII;
 
 import org.apache.taverna.download.DownloadException;
 import org.junit.Test;
-import static org.junit.Assert.*;
 
 public class TestDownloadManagerImpl {
 	
 	/**
 	 * This test should remain commented out 
-	 * as it relies on a third-party 
-	 * web service.
+	 * as it relies on a third-party web site
 	 * 
-	 * Verifies 
+	 * Verifies TAVERNA-893
 	 * 
 	 */
 	@Test(expected=DownloadException.class)
@@ -28,7 +26,12 @@ public class TestDownloadManagerImpl {
 		// NOTE: The below URL is a Taverna 2 POM - not related to 
 		// taverna-plugin-impl
 		URL wrongURL = new URL("http://192.185.115.65/~diana/DIANA_plugin_updated/test-plugins/gr/dianatools/diana.services-activity/1.0-SNAPSHOT/diana.services-activity-1.0-SNAPSHOT.pom");
-		dl.download(wrongURL, pomFile.toFile(), "MD5");	
+		
+		// With this we get an exception - but only because the 
+		// 300 erorr page fails the MD5 check
+		//dl.download(wrongURL, pomFile.toFile(), "MD5");
+		// so we'll try without hashsum
+		dl.download(wrongURL, pomFile.toFile());
 	}
 	
 	/**
@@ -42,10 +45,10 @@ public class TestDownloadManagerImpl {
 	public void downloadLocalFile() throws Exception {
 		Path example = Files.createTempFile("example", ".txt");
 		Files.write(example, "Hello world".getBytes(US_ASCII)); // No newline
-		Path exampleMd5 = example.resolve(example.getFileName() + ".md5");
+		Path exampleMd5 = example.resolveSibling(example.getFileName() + ".md5");
 //		stain@biggie:~$ echo -n "Hello world"|md5sum
 //		3e25960a79dbc69b674cd4ec67a72c62  -
-		Files.write(exampleMd5, "3e25960a79dbc69b674cd4ec67a72c62".getBytes(US_ASCII));
+		Files.write(exampleMd5, "3e25960a79dbc69b674cd4ec67a72c62".getBytes(US_ASCII)); // no newline
 		
 		DownloadManagerImpl dl = new DownloadManagerImpl();
 		


[4/4] incubator-taverna-osgi git commit: TAVERNA-893 don't normally run handle300MultipleChoice test

Posted by st...@apache.org.
TAVERNA-893 don't normally run handle300MultipleChoice test


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/commit/c41687d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/tree/c41687d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/diff/c41687d2

Branch: refs/heads/master
Commit: c41687d2140ec8880fb31ca556c67b8bf19bf03d
Parents: 9177249
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Feb 12 13:21:56 2016 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Feb 12 13:21:56 2016 +0000

----------------------------------------------------------------------
 .../apache/taverna/download/impl/TestDownloadManagerImpl.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c41687d2/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
index 07c02d7..a260c59 100644
--- a/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
+++ b/taverna-download-impl/src/test/java/org/apache/taverna/download/impl/TestDownloadManagerImpl.java
@@ -8,17 +8,20 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 
 import org.apache.taverna.download.DownloadException;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestDownloadManagerImpl {
 	
 	/**
-	 * This test should remain commented out 
+	 * This test should remain @Ignored  
 	 * as it relies on a third-party web site
+	 * and should not break the build.
 	 * 
 	 * Verifies TAVERNA-893
 	 * 
 	 */
+	@Ignore
 	@Test(expected=DownloadException.class)
 	public void handle300MultipleChoice() throws Exception {
 		DownloadManagerImpl dl = new DownloadManagerImpl();
@@ -34,6 +37,7 @@ public class TestDownloadManagerImpl {
 		dl.download(wrongURL, pomFile.toFile());
 	}
 	
+	
 	/**
 	 * Test downloading a file:/// to a File, checking md5 hashsum.
 	 * 


[3/4] incubator-taverna-osgi git commit: TAVERNA-893 30 second timeout, not 30 ms

Posted by st...@apache.org.
TAVERNA-893 30 second timeout, not 30 ms


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/commit/9177249d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/tree/9177249d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/diff/9177249d

Branch: refs/heads/master
Commit: 9177249de85555cc95b81904ec3cdd348ed03385
Parents: db3bd18
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Feb 12 13:20:28 2016 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Feb 12 13:20:28 2016 +0000

----------------------------------------------------------------------
 .../apache/taverna/download/impl/DownloadManagerImpl.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/9177249d/taverna-download-impl/src/main/java/org/apache/taverna/download/impl/DownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/taverna-download-impl/src/main/java/org/apache/taverna/download/impl/DownloadManagerImpl.java b/taverna-download-impl/src/main/java/org/apache/taverna/download/impl/DownloadManagerImpl.java
index eee6ff4..7292c8e 100644
--- a/taverna-download-impl/src/main/java/org/apache/taverna/download/impl/DownloadManagerImpl.java
+++ b/taverna-download-impl/src/main/java/org/apache/taverna/download/impl/DownloadManagerImpl.java
@@ -30,11 +30,11 @@ import org.apache.taverna.download.DownloadManager;
 
 /**
  *
- *
- * @author David Withers
  */
 public class DownloadManagerImpl implements DownloadManager {
 
+	private static final int TIMEOUT = Integer.getInteger("taverna.download.timeout.seconds", 30) * 1000;
+	
 	private static final Logger logger = Logger.getLogger(DownloadManagerImpl.class);
 
 	public void download(URL source, File destination) throws DownloadException {
@@ -69,7 +69,7 @@ public class DownloadManagerImpl implements DownloadManager {
 			tempFile = File.createTempFile("DownloadManager", "tmp");
 			tempFile.deleteOnExit();
 			logger.info(String.format("Downloading %1$s to %2$s", source, tempFile));
-			FileUtils.copyURLToFile(source, tempFile, 30, 30);
+			FileUtils.copyURLToFile(source, tempFile, TIMEOUT, TIMEOUT);
 		} catch (IOException e) {
 			throw new DownloadException(String.format("Error downloading %1$s to %2$s.", source, destination), e);
 		}
@@ -80,7 +80,7 @@ public class DownloadManagerImpl implements DownloadManager {
 				digestFile = File.createTempFile("DownloadManager", "tmp");
 				digestFile.deleteOnExit();
 				logger.info(String.format("Downloading %1$s to %2$s", digestSource, digestFile));
-				FileUtils.copyURLToFile(digestSource, digestFile, 30, 30);
+				FileUtils.copyURLToFile(digestSource, digestFile, TIMEOUT, TIMEOUT);
 			} catch (IOException e) {
 				throw new DownloadException(String.format("Error checking digest for %1$s.", source), e);
 			}