Author: scottbw
Date: Tue Mar  5 15:43:22 2013
New Revision: 1452856

URL: http://svn.apache.org/r1452856
Log:
Refactored helper so we can use it as generic downloader also.

Modified:
    wookie/trunk/src-tests/org/apache/wookie/tests/helpers/WidgetUploader.java

Modified: 
wookie/trunk/src-tests/org/apache/wookie/tests/helpers/WidgetUploader.java
URL: 
http://svn.apache.org/viewvc/wookie/trunk/src-tests/org/apache/wookie/tests/helpers/WidgetUploader.java?rev=1452856&r1=1452855&r2=1452856&view=diff
==============================================================================
--- wookie/trunk/src-tests/org/apache/wookie/tests/helpers/WidgetUploader.java 
(original)
+++ wookie/trunk/src-tests/org/apache/wookie/tests/helpers/WidgetUploader.java 
Tue Mar  5 15:43:22 2013
@@ -43,13 +43,14 @@ public class WidgetUploader {
        
        public static final String SERVICE_URL = 
"http://localhost:8080/wookie/widgets";;
 
+       
        /**
-        * Upload a widget from a file at a given URL
+        * Download a widget from a given URL to file
         * @param url
         * @return
         * @throws IOException
         */
-       public static String uploadWidget(String url) throws IOException{
+       public static File downloadWidget(String url) throws IOException{
                HttpClient httpclient = new HttpClient();
                GetMethod get = new GetMethod(url);
                int status = httpclient.executeMethod(get);
@@ -59,7 +60,17 @@ public class WidgetUploader {
                File file = File.createTempFile("w3c", ".wgt");
                FileUtils.writeByteArrayToFile(file, 
IOUtils.toByteArray(get.getResponseBodyAsStream()));
                get.releaseConnection();
-               return uploadWidget(file);              
+               return file;            
+       }
+       
+       /**
+        * Upload a widget from a file at a given URL
+        * @param url
+        * @return
+        * @throws IOException
+        */
+       public static String uploadWidget(String url) throws IOException{
+               return uploadWidget(downloadWidget(url));               
        }
        
        /**


Reply via email to