flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From labri...@apache.org
Subject git commit: [flex-flexunit] [refs/heads/develop] - Implemented the url property to allow use of remote swfs. The url is mutually exclusive with the localTrusted flag as, one using a url, there is no way to add the swf to the local trust and the remote se
Date Wed, 28 Aug 2013 19:39:24 GMT
Updated Branches:
  refs/heads/develop [created] 1b4ef800e


Implemented the url property to allow use of remote swfs. The url is mutually exclusive with
the localTrusted flag as, one using a url, there is no way to add the swf to the local trust
and the remote server must implement a policy file to allow the swf to communication with
the local test runner


Project: http://git-wip-us.apache.org/repos/asf/flex-flexunit/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-flexunit/commit/1b4ef800
Tree: http://git-wip-us.apache.org/repos/asf/flex-flexunit/tree/1b4ef800
Diff: http://git-wip-us.apache.org/repos/asf/flex-flexunit/diff/1b4ef800

Branch: refs/heads/develop
Commit: 1b4ef800efe208f65f4a593f2c2d32f439f71c11
Parents: 7d4c01c
Author: labriola <labriola@digitalprimates.net>
Authored: Wed Aug 28 14:32:05 2013 -0500
Committer: labriola <labriola@digitalprimates.net>
Committed: Wed Aug 28 14:32:05 2013 -0500

----------------------------------------------------------------------
 .../commands/player/FlashPlayerCommand.java     | 36 +++++++++++---------
 .../tasks/configuration/TaskConfiguration.java  | 36 ++++++++++++++++++--
 2 files changed, 53 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-flexunit/blob/1b4ef800/FlexUnit4AntTasks/src/org/flexunit/ant/launcher/commands/player/FlashPlayerCommand.java
----------------------------------------------------------------------
diff --git a/FlexUnit4AntTasks/src/org/flexunit/ant/launcher/commands/player/FlashPlayerCommand.java
b/FlexUnit4AntTasks/src/org/flexunit/ant/launcher/commands/player/FlashPlayerCommand.java
index 78a36ae..9d685eb 100644
--- a/FlexUnit4AntTasks/src/org/flexunit/ant/launcher/commands/player/FlashPlayerCommand.java
+++ b/FlexUnit4AntTasks/src/org/flexunit/ant/launcher/commands/player/FlashPlayerCommand.java
@@ -2,6 +2,7 @@ package org.flexunit.ant.launcher.commands.player;
 
 import java.io.File;
 
+
 /**
  * Abstracts the assembly of a command-line call to the Flash player for all platforms. 

  */
@@ -35,14 +36,28 @@ public class FlashPlayerCommand extends DefaultPlayerCommand
    @Override
    public void prepare()
    {
-	   if(getSwf() != null)
+	   //Determine if we have a URL value.
+	   //This should be populated by setting the 'swf' property equal to a remote http hosted
SWF.
+	   if(getUrl() != null && getUrl() != "")
 	   {
-		  //setup the command line now
+		  //setup the command line now for remote URL
 	      getCommandLine().setExecutable(getDefaults().getOpenCommand());
 	      getCommandLine().addArguments(getDefaults().getOpenSystemArguments());
-	      getCommandLine().addArguments(new String[]{getFileToExecute().getAbsolutePath()});
+	      getCommandLine().addArguments(new String[]{getUrl()});
+	      
+	      //There is no need to add to the local trust because we're going to be loading the
swf from a remote location.
 	      
-	      //handle local trust
+	   } 
+	   //Determine if we have a local SWF to run.
+	   //This should be populated by setting the 'swf' property equal to a swf on your local
file system. 
+	   else if(getSwf() != null) {
+		   
+		  //setup the command line now with local SWF file location
+		  getCommandLine().setExecutable(getDefaults().getOpenCommand());
+		  getCommandLine().addArguments(getDefaults().getOpenSystemArguments());
+		  getCommandLine().addArguments(new String[]{getFileToExecute().getAbsolutePath()});
+
+		  //handle local trust for locally stored swf file
 	      TrustFile trustFile = new TrustFile(getProject(), getDefaults().getFlashPlayerUserTrustDirectory(),
getDefaults().getFlashPlayerGlobalTrustDirectory());
 	      if (localTrusted)
 	      {
@@ -50,18 +65,7 @@ public class FlashPlayerCommand extends DefaultPlayerCommand
 	      }
 	      else
 	      {
-	         trustFile.remove(getSwf());
-	      }
-	   } else if(getUrl() != null) {
-	      //handle local trust
-	      TrustFile trustFile = new TrustFile(getProject(), getDefaults().getFlashPlayerUserTrustDirectory(),
getDefaults().getFlashPlayerGlobalTrustDirectory());
-	      if (localTrusted)
-	      {
-	         trustFile.add(getUrl());
-	      }
-	      else
-	      {
-	    	  trustFile.remove(getUrl());
+	    	  trustFile.remove(getSwf());
 	      }		   
 	   }
    }

http://git-wip-us.apache.org/repos/asf/flex-flexunit/blob/1b4ef800/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/configuration/TaskConfiguration.java
----------------------------------------------------------------------
diff --git a/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/configuration/TaskConfiguration.java
b/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/configuration/TaskConfiguration.java
index 5587bbb..2252d3d 100644
--- a/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/configuration/TaskConfiguration.java
+++ b/FlexUnit4AntTasks/src/org/flexunit/ant/tasks/configuration/TaskConfiguration.java
@@ -1,6 +1,8 @@
 package org.flexunit.ant.tasks.configuration;
 
 import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -38,6 +40,18 @@ public class TaskConfiguration
       }
    }
    
+   //Used to verify that a string is also a properly formatted URL
+   //When determining if the passed 'swf' property value is remote or local this is crucial.
+   protected boolean isValidURI(String uriStr) {
+	    try {
+	      URI uri = new URI(uriStr);
+	      return true;
+	    }
+	    catch (URISyntaxException e) {
+	        return false;
+	    }
+	}
+   
    public CompilationConfiguration getCompilationConfiguration()
    {
       return compilationConfiguration;
@@ -123,7 +137,15 @@ public class TaskConfiguration
 
    public void setSwf(String swf)
    {
-      testRunConfiguration.setSwf(project.resolveFile(swf));
+	   //match the swf URL to see if it's a remote location, if so, set the url instead of swf.
+		if( isValidURI( swf ) ) {
+			testRunConfiguration.setUrl(swf);
+			LoggingUtil.log("Remote path to SWF was given, setting URL property instead of SWF");
+		} else {
+			testRunConfiguration.setSwf(project.resolveFile(swf));
+			LoggingUtil.log("Local path to SWF was given, SWF property as usual.");
+		} 
+	   
    }
    
    public void setSwf(File swf)
@@ -179,10 +201,18 @@ public class TaskConfiguration
       
       File swf = testRunConfiguration.getSwf();
       boolean noTestSources = !compilationConfiguration.getTestSources().provided();
+      String swfURL = testRunConfiguration.getUrl();
+      
+      //Check to make sure we have a valid swf, testsource or remote url before proceeding.
+      //Otherwise, notify the user to fix this before continuing.
+      if ((swf == null || !swf.exists()) && noTestSources && (swfURL == ""
|| swfURL == null) )
+      {
+         throw new BuildException("The provided 'swf' property value [" + (swf == null ?
"" : swf.getPath()) + "] could not be found or is not a valid remote URL.");
+      }
       
-      if ((swf == null || !swf.exists()) && noTestSources)
+      if( (swfURL != null && swfURL != "") && testRunConfiguration.isLocalTrusted()
) 
       {
-         throw new BuildException("The provided 'swf' property value [" + (swf == null ?
"" : swf.getPath()) + "] could not be found.");
+    	  throw new BuildException("The provided 'swf' property value points to a remote location.
 Please set localTrusted = false or change the location of your swf to a local path.");
       }
       
       if(swf != null && !noTestSources)


Mime
View raw message