- Made the ASFeatureTestsBase and MXMLFeatureTestsBase use the ITestAdapter - Added some features to the TestAdapters which are needed by the integration-tests (Maven is classified as pre-alpha for now as it will only work on my machine, but I'll fix that before we start using it)
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d37eaae5 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d37eaae5 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d37eaae5 Branch: refs/heads/master Commit: d37eaae590e859d540df34f4a5555371b258fba7 Parents: 04bc650 Author: Christofer Dutz <christofer.d...@codecentric.de> Authored: Wed Feb 24 12:57:50 2016 +0100 Committer: Christofer Dutz <christofer.d...@codecentric.de> Committed: Wed Feb 24 12:57:50 2016 +0100 ---------------------------------------------------------------------- .../feature-tests/as/ASFeatureTestsBase.java | 60 +++++++------------- .../mxml/tags/MXMLFeatureTestsBase.java | 60 +++++++------------- .../org/apache/flex/utils/AntTestAdapter.java | 43 ++++++++++++-- .../src/org/apache/flex/utils/ITestAdapter.java | 8 +++ .../org/apache/flex/utils/MavenTestAdapter.java | 30 +++++++++- 5 files changed, 119 insertions(+), 82 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d37eaae5/compiler.tests/feature-tests/as/ASFeatureTestsBase.java ---------------------------------------------------------------------- diff --git a/compiler.tests/feature-tests/as/ASFeatureTestsBase.java b/compiler.tests/feature-tests/as/ASFeatureTestsBase.java index cb1d7eb..e088970 100644 --- a/compiler.tests/feature-tests/as/ASFeatureTestsBase.java +++ b/compiler.tests/feature-tests/as/ASFeatureTestsBase.java @@ -19,9 +19,9 @@ package as; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import org.apache.flex.compiler.clients.MXMLC; +import org.apache.flex.compiler.problems.ICompilerProblem; +import org.apache.flex.utils.*; import java.io.BufferedWriter; import java.io.File; @@ -33,11 +33,9 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.*; -import org.apache.flex.compiler.clients.MXMLC; -import org.apache.flex.compiler.problems.ICompilerProblem; -import org.apache.flex.utils.EnvProperties; -import org.apache.flex.utils.FilenameNormalization; -import org.apache.flex.utils.StringUtils; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; /** @@ -46,32 +44,18 @@ import org.apache.flex.utils.StringUtils; */ public class ASFeatureTestsBase { - private static EnvProperties env = EnvProperties.initiate(); - - private static final String PLAYERGLOBAL_SWC = FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc"); - - private static final String FRAMEWORK_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\framework.swc"); - private static final String FRAMEWORK_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\framework_rb.swc"); - - private static final String RPC_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\rpc.swc"); - private static final String RPC_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\rpc_rb.swc"); - - private static final String SPARK_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\spark.swc"); - private static final String SPARK_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\spark_rb.swc"); - private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009"; - - private static final String MANIFEST_2009 = FilenameNormalization.normalize(env.SDK + "\\frameworks\\mxml-2009-manifest.xml"); - - // The Ant script for compiler.tests copies a standalone player to the temp directory. - private static final String FLASHPLAYER = FilenameNormalization.normalize(env.FDBG); protected void compileAndRun(String source, boolean withFramework, boolean withRPC, boolean withSpark, String[] otherOptions) { System.out.println("Generating test:"); // Write the MXML into a temp file. - String tempDir = FilenameNormalization.normalize("temp"); + // Depending on the "buildType" system-property, create the corresponding test-adapter. + // Make the AntTestAdapter the default. + ITestAdapter testAdapter = System.getProperty("buildType", "Ant").equals("Maven") ? + new MavenTestAdapter() : new AntTestAdapter(); + String tempDir = testAdapter.getTempDir(); File tempASFile = null; try { @@ -97,25 +81,25 @@ public class ASFeatureTestsBase List<String> swcs = new ArrayList<String>(); if (withFramework) { - swcs.add(FRAMEWORK_SWC); - swcs.add(FRAMEWORK_RB_SWC); + swcs.add(testAdapter.getArtifact("framework").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("framework").getPath()); } if (withRPC) { - swcs.add(RPC_SWC); - swcs.add(RPC_RB_SWC); + swcs.add(testAdapter.getArtifact("rpc").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("rpc").getPath()); } if (withSpark) { - swcs.add(SPARK_SWC); - swcs.add(SPARK_RB_SWC); + swcs.add(testAdapter.getArtifact("spark").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("spark").getPath()); } String libraryPath = "-library-path=" + StringUtils.join(swcs.toArray(new String[swcs.size()]), ","); List<String> args = new ArrayList<String>(); - args.add("-external-library-path=" + PLAYERGLOBAL_SWC); + args.add("-external-library-path=" + testAdapter.getPlayerglobal().getPath()); args.add(libraryPath); - args.add("-namespace=" + NAMESPACE_2009 + "," + MANIFEST_2009); + args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getManifestPath()); if (otherOptions != null) { Collections.addAll(args, otherOptions); @@ -142,15 +126,15 @@ public class ASFeatureTestsBase assertThat(sb.toString(), exitCode, is(0)); // Check the existence of the flashplayer executable - File playerExecutable = new File(FLASHPLAYER); + File playerExecutable = testAdapter.getFlashplayerDebugger(); if(!playerExecutable.isFile() || !playerExecutable.exists()) { - fail("The flashplayer executable " + FLASHPLAYER + " doesn't exist."); + fail("The flashplayer executable " + testAdapter.getFlashplayerDebugger().getPath() + " doesn't exist."); } // Run the SWF in the standalone player amd wait until the SWF calls System.exit(). String swf = FilenameNormalization.normalize(tempASFile.getAbsolutePath()); swf = swf.replace(".as", ".swf"); - String[] runArgs = new String[] { FLASHPLAYER, swf }; + String[] runArgs = new String[] { testAdapter.getFlashplayerDebugger().getPath(), swf }; try { System.out.println("Executing test:\n" + Arrays.toString(runArgs)); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d37eaae5/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java ---------------------------------------------------------------------- diff --git a/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java b/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java index 0e4a0f2..fd5fc16 100644 --- a/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java +++ b/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java @@ -19,9 +19,9 @@ package mxml.tags; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import org.apache.flex.compiler.clients.MXMLC; +import org.apache.flex.compiler.problems.ICompilerProblem; +import org.apache.flex.utils.*; import java.io.BufferedWriter; import java.io.File; @@ -33,11 +33,9 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.*; -import org.apache.flex.compiler.clients.MXMLC; -import org.apache.flex.compiler.problems.ICompilerProblem; -import org.apache.flex.utils.EnvProperties; -import org.apache.flex.utils.FilenameNormalization; -import org.apache.flex.utils.StringUtils; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; /** @@ -47,32 +45,18 @@ import org.apache.flex.utils.StringUtils; */ public class MXMLFeatureTestsBase { - private static EnvProperties env = EnvProperties.initiate(); - - private static final String PLAYERGLOBAL_SWC = FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc"); - - private static final String FRAMEWORK_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\framework.swc"); - private static final String FRAMEWORK_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\framework_rb.swc"); - - private static final String RPC_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\rpc.swc"); - private static final String RPC_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\rpc_rb.swc"); - - private static final String SPARK_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\spark.swc"); - private static final String SPARK_RB_SWC = FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US\\spark_rb.swc"); - private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009"; - private static final String MANIFEST_2009 = FilenameNormalization.normalize(env.SDK + "\\frameworks\\mxml-2009-manifest.xml"); - - // The Ant script for compiler.tests copies a standalone player to the temp directory. - private static final String FLASHPLAYER = FilenameNormalization.normalize(env.FDBG); - protected void compileAndRun(String mxml, boolean withFramework, boolean withRPC, boolean withSpark, String[] otherOptions) { System.out.println("Generating test:"); // Write the MXML into a temp file. - String tempDir = FilenameNormalization.normalize("temp"); + // Depending on the "buildType" system-property, create the corresponding test-adapter. + // Make the AntTestAdapter the default. + ITestAdapter testAdapter = System.getProperty("buildType", "Ant").equals("Maven") ? + new MavenTestAdapter() : new AntTestAdapter(); + String tempDir = testAdapter.getTempDir(); File tempMXMLFile = null; try { @@ -93,25 +77,25 @@ public class MXMLFeatureTestsBase List<String> swcs = new ArrayList<String>(); if (withFramework) { - swcs.add(FRAMEWORK_SWC); - swcs.add(FRAMEWORK_RB_SWC); + swcs.add(testAdapter.getArtifact("framework").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("framework").getPath()); } if (withRPC) { - swcs.add(RPC_SWC); - swcs.add(RPC_RB_SWC); + swcs.add(testAdapter.getArtifact("rpc").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("rpc").getPath()); } if (withSpark) { - swcs.add(SPARK_SWC); - swcs.add(SPARK_RB_SWC); + swcs.add(testAdapter.getArtifact("spark").getPath()); + swcs.add(testAdapter.getArtifactResourceBundle("spark").getPath()); } String libraryPath = "-library-path=" + StringUtils.join(swcs.toArray(new String[swcs.size()]), ","); List<String> args = new ArrayList<String>(); - args.add("-external-library-path=" + PLAYERGLOBAL_SWC); + args.add("-external-library-path=" + testAdapter.getPlayerglobal().getPath()); args.add(libraryPath); - args.add("-namespace=" + NAMESPACE_2009 + "," + MANIFEST_2009); + args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getManifestPath()); if (otherOptions != null) { Collections.addAll(args, otherOptions); @@ -138,15 +122,15 @@ public class MXMLFeatureTestsBase assertThat(sb.toString(), exitCode, is(0)); // Check the existence of the flashplayer executable - File playerExecutable = new File(FLASHPLAYER); + File playerExecutable = testAdapter.getFlashplayerDebugger(); if(!playerExecutable.isFile() || !playerExecutable.exists()) { - fail("The flashplayer executable " + FLASHPLAYER + " doesn't exist."); + fail("The flashplayer executable " + testAdapter.getFlashplayerDebugger().getPath() + " doesn't exist."); } // Run the SWF in the standalone player amd wait until the SWF calls System.exit(). String swf = FilenameNormalization.normalize(tempMXMLFile.getAbsolutePath()); swf = swf.replace(".mxml", ".swf"); - String[] runArgs = new String[] { FLASHPLAYER, swf }; + String[] runArgs = new String[] { testAdapter.getFlashplayerDebugger().getPath(), swf }; try { System.out.println("Executing test:\n" + Arrays.toString(runArgs)); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d37eaae5/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java ---------------------------------------------------------------------- diff --git a/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java b/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java index 32c24d5..c0d253d 100644 --- a/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java @@ -13,6 +13,13 @@ public class AntTestAdapter implements ITestAdapter { private static EnvProperties env = EnvProperties.initiate(); + private static final File PLAYERGLOBAL_SWC = new File(FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc")); + // The Ant script for compiler.tests copies a standalone player to the temp directory. + private static final File FLASHPLAYER = new File(FilenameNormalization.normalize(env.FDBG)); + + private static final File LIBS_ROOT = new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs")); + private static final File RESOURCE_BUNDLES_ROOT = new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\locale\\en_US")); + @Override public String getTempDir() { return FilenameNormalization.normalize("temp"); // ensure this exists @@ -28,12 +35,12 @@ public class AntTestAdapter implements ITestAdapter { // Create a list of libs needed to compile. List<File> libraries = new ArrayList<File>(); - libraries.add(new File(FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc"))); + libraries.add(getPlayerglobal()); if (withFlex) { - libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\framework.swc"))); - libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\rpc.swc"))); - libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\spark.swc"))); + libraries.add(getArtifact("framework")); + libraries.add(getArtifact("rpc")); + libraries.add(getArtifact("spark")); } return libraries; } @@ -43,4 +50,32 @@ public class AntTestAdapter implements ITestAdapter { return env.SDK + "\\frameworks\\mxml-2009-manifest.xml"; } + @Override + public File getPlayerglobal() { + return PLAYERGLOBAL_SWC; + } + + @Override + public File getFlashplayerDebugger() { + return FLASHPLAYER; + } + + @Override + public File getArtifact(String artifactName) { + return getLib(artifactName); + } + + @Override + public File getArtifactResourceBundle(String artifactName) { + return getResourceBundle(artifactName); + } + + private File getLib(String artifactId) { + return new File(LIBS_ROOT, artifactId + ".swc"); + } + + private File getResourceBundle(String artifactId) { + return new File(RESOURCE_BUNDLES_ROOT, artifactId + "_rb.swc"); + } + } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d37eaae5/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java ---------------------------------------------------------------------- diff --git a/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java b/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java index 460ce16..4790004 100644 --- a/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java @@ -14,4 +14,12 @@ public interface ITestAdapter { String getManifestPath(); + File getPlayerglobal(); + + File getFlashplayerDebugger(); + + File getArtifact(String artifactName); + + File getArtifactResourceBundle(String artifactName); + } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d37eaae5/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java ---------------------------------------------------------------------- diff --git a/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java b/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java index 403ee67..09f41c3 100644 --- a/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java @@ -23,8 +23,7 @@ public class MavenTestAdapter implements ITestAdapter { @Override public List<File> getLibraries(boolean withFlex) { List<File> libs = new ArrayList<File>(); - libs.add(getDependency("com.adobe.flash.framework", "playerglobal", - System.getProperty("flashVersion"), "swc", null)); + libs.add(getPlayerglobal()); if(withFlex) { String flexVersion = System.getProperty("flexVersion"); libs.add(getDependency("org.apache.flex.framework", "framework", flexVersion, "swc", null)); @@ -48,6 +47,33 @@ public class MavenTestAdapter implements ITestAdapter { return new File(unpackedConfigsDir, "mxml-2009-manifest.xml").getPath(); } + @Override + public File getPlayerglobal() { + return getDependency("com.adobe.flash.framework", "playerglobal", + System.getProperty("flashVersion"), "swc", null); + } + + @Override + public File getFlashplayerDebugger() { + // TODO: If the archive isn't unpacked, unpack it. + // TODO: Return a reference to the player debugger executable, depending on the current platform. + return new File("/Users/christoferdutz/Devtools/Adobe/Flash/19.0/Flash Player.app/Contents/MacOS/Flash Player Debugger"); + /*return getDependency("com.adobe.flash.runtime", "player-debugger", + System.getProperty("flashVersion"), "zip", null);*/ + } + + @Override + public File getArtifact(String artifactName) { + String flexVersion = System.getProperty("flexVersion"); + return getDependency("org.apache.flex.framework", artifactName, flexVersion, "swc", null); + } + + @Override + public File getArtifactResourceBundle(String artifactName) { + String flexVersion = System.getProperty("flexVersion"); + return getDependency("org.apache.flex.framework", artifactName, flexVersion, "rb.swc", "en_US"); + } + private File getDependency(String groupId, String artifactId, String version, String type, String classifier) { String dependencyPath = System.getProperty("mavenLocalRepoDir") + "/" + groupId.replaceAll("\\.", "/") + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version +