Continued the preparation of supporting Ant and Maven builds by extending the test-adapters to support additional parameters needed by FlexJS / ASJS
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d4aaeab9 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d4aaeab9 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d4aaeab9 Branch: refs/heads/feature/maven-migration Commit: d4aaeab9f6427f67fd46708e2a8894dd7adf457a Parents: 92d2b98 Author: Christofer Dutz <christofer.d...@codecentric.de> Authored: Fri Mar 11 15:15:07 2016 +0100 Committer: Christofer Dutz <christofer.d...@codecentric.de> Committed: Fri Mar 11 15:15:07 2016 +0100 ---------------------------------------------------------------------- .../feature-tests/as/ASFeatureTestsBase.java | 19 ++--- .../mxml/tags/MXMLFeatureTestsBase.java | 19 ++--- .../org/apache/flex/utils/AntTestAdapter.java | 54 +++++++++--- .../org/apache/flex/utils/EnvProperties.java | 13 ++- .../src/org/apache/flex/utils/ITestAdapter.java | 33 +++++++- .../org/apache/flex/utils/MavenTestAdapter.java | 86 +++++++++++++++----- .../apache/flex/utils/TestAdapterFactory.java | 41 ++++++++++ .../internal/tree/mxml/MXMLNodeBaseTests.java | 35 +++----- 8 files changed, 214 insertions(+), 86 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/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 e088970..f7ac2f9 100644 --- a/compiler.tests/feature-tests/as/ASFeatureTestsBase.java +++ b/compiler.tests/feature-tests/as/ASFeatureTestsBase.java @@ -51,10 +51,7 @@ public class ASFeatureTestsBase System.out.println("Generating test:"); // Write the MXML into a temp file. - // 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(); + ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter(); String tempDir = testAdapter.getTempDir(); File tempASFile = null; try @@ -81,25 +78,25 @@ public class ASFeatureTestsBase List<String> swcs = new ArrayList<String>(); if (withFramework) { - swcs.add(testAdapter.getArtifact("framework").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("framework").getPath()); + swcs.add(testAdapter.getFlexArtifact("framework").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("framework").getPath()); } if (withRPC) { - swcs.add(testAdapter.getArtifact("rpc").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("rpc").getPath()); + swcs.add(testAdapter.getFlexArtifact("rpc").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("rpc").getPath()); } if (withSpark) { - swcs.add(testAdapter.getArtifact("spark").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("spark").getPath()); + swcs.add(testAdapter.getFlexArtifact("spark").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("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=" + testAdapter.getPlayerglobal().getPath()); args.add(libraryPath); - args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getManifestPath()); + args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getFlexManifestPath("mxml-2009")); if (otherOptions != null) { Collections.addAll(args, otherOptions); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/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 fd5fc16..c36ad0f 100644 --- a/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java +++ b/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java @@ -52,10 +52,7 @@ public class MXMLFeatureTestsBase System.out.println("Generating test:"); // Write the MXML into a temp file. - // 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(); + ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter(); String tempDir = testAdapter.getTempDir(); File tempMXMLFile = null; try @@ -77,25 +74,25 @@ public class MXMLFeatureTestsBase List<String> swcs = new ArrayList<String>(); if (withFramework) { - swcs.add(testAdapter.getArtifact("framework").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("framework").getPath()); + swcs.add(testAdapter.getFlexArtifact("framework").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("framework").getPath()); } if (withRPC) { - swcs.add(testAdapter.getArtifact("rpc").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("rpc").getPath()); + swcs.add(testAdapter.getFlexArtifact("rpc").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("rpc").getPath()); } if (withSpark) { - swcs.add(testAdapter.getArtifact("spark").getPath()); - swcs.add(testAdapter.getArtifactResourceBundle("spark").getPath()); + swcs.add(testAdapter.getFlexArtifact("spark").getPath()); + swcs.add(testAdapter.getFlexArtifactResourceBundle("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=" + testAdapter.getPlayerglobal().getPath()); args.add(libraryPath); - args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getManifestPath()); + args.add("-namespace=" + NAMESPACE_2009 + "," + testAdapter.getFlexManifestPath("mxml-2009")); if (otherOptions != null) { Collections.addAll(args, otherOptions); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/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 c0d253d..c79c61a 100644 --- a/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/AntTestAdapter.java @@ -1,3 +1,22 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package org.apache.flex.utils; import java.io.File; @@ -38,19 +57,14 @@ public class AntTestAdapter implements ITestAdapter { libraries.add(getPlayerglobal()); if (withFlex) { - libraries.add(getArtifact("framework")); - libraries.add(getArtifact("rpc")); - libraries.add(getArtifact("spark")); + libraries.add(getFlexArtifact("framework")); + libraries.add(getFlexArtifact("rpc")); + libraries.add(getFlexArtifact("spark")); } return libraries; } @Override - public String getManifestPath() { - return env.SDK + "\\frameworks\\mxml-2009-manifest.xml"; - } - - @Override public File getPlayerglobal() { return PLAYERGLOBAL_SWC; } @@ -61,15 +75,35 @@ public class AntTestAdapter implements ITestAdapter { } @Override - public File getArtifact(String artifactName) { + public String getFlexManifestPath(String type) { + return env.SDK + "\\frameworks\\" + type + "-manifest.xml"; + } + + @Override + public File getFlexArtifact(String artifactName) { return getLib(artifactName); } @Override - public File getArtifactResourceBundle(String artifactName) { + public File getFlexArtifactResourceBundle(String artifactName) { return getResourceBundle(artifactName); } + @Override + public String getFlexJsManifestPath(String type) { + return null; + } + + @Override + public File getFlexJSArtifact(String artifactName) { + return null; + } + + @Override + public File getUnitTestBaseDir() { + return new File(FilenameNormalization.normalize("test-files")); + } + private File getLib(String artifactId) { return new File(LIBS_ROOT, artifactId + ".swc"); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/compiler.tests/src/org/apache/flex/utils/EnvProperties.java ---------------------------------------------------------------------- diff --git a/compiler.tests/src/org/apache/flex/utils/EnvProperties.java b/compiler.tests/src/org/apache/flex/utils/EnvProperties.java index 03805d5..b204b1b 100644 --- a/compiler.tests/src/org/apache/flex/utils/EnvProperties.java +++ b/compiler.tests/src/org/apache/flex/utils/EnvProperties.java @@ -80,8 +80,7 @@ public class EnvProperties { { String prefix = ""; Properties p = new Properties(); - String envFileName = FilenameNormalization - .normalize("../env.properties"); + String envFileName = FilenameNormalization.normalize("../env.properties"); try { File f = new File(envFileName); if (f.exists()) @@ -97,19 +96,19 @@ public class EnvProperties { } catch (FileNotFoundException e1) { System.out.println("unittest.properties not found"); } catch (IOException e1) { + // Ignore } } catch (IOException e) { + // Ignore } SDK = p.getProperty(prefix + "FLEX_HOME", System.getenv("FLEX_HOME")); if(SDK == null) { - SDK = FilenameNormalization - .normalize("../../flex-sdk"); + SDK = FilenameNormalization.normalize("../../flex-sdk"); File mxmlc = new File(SDK + "/lib/mxmlc.jar"); if (!mxmlc.exists()) - SDK = FilenameNormalization - .normalize("../compiler/generated/dist/sdk"); + SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk"); } System.out.println("environment property - FLEX_HOME = " + SDK); @@ -126,7 +125,7 @@ public class EnvProperties { TLF = p.getProperty(prefix + "TLF_HOME", System.getenv("TLF_HOME")); if (TLF == null) { - TLF = FilenameNormalization.normalize("../../flex-tlf"); + TLF = FilenameNormalization.normalize("../../flex-tlf"); } System.out.println("environment property - TLF_HOME = " + TLF); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/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 4790004..5f35557 100644 --- a/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/ITestAdapter.java @@ -1,3 +1,22 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package org.apache.flex.utils; import java.io.File; @@ -12,14 +31,20 @@ public interface ITestAdapter { List<File> getLibraries(boolean withFlex); - String getManifestPath(); - File getPlayerglobal(); File getFlashplayerDebugger(); - File getArtifact(String artifactName); + String getFlexManifestPath(String type); + + File getFlexArtifact(String artifactName); + + File getFlexArtifactResourceBundle(String artifactName); + + String getFlexJsManifestPath(String type); + + File getFlexJSArtifact(String artifactName); - File getArtifactResourceBundle(String artifactName); + File getUnitTestBaseDir(); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/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 a1f25e7..485d14b 100644 --- a/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java +++ b/compiler.tests/src/org/apache/flex/utils/MavenTestAdapter.java @@ -1,5 +1,26 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package org.apache.flex.utils; +import org.apache.commons.io.FilenameUtils; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -34,20 +55,6 @@ public class MavenTestAdapter implements ITestAdapter { } @Override - public String getManifestPath() { - File configsZip = getDependency("org.apache.flex.framework", "framework", - System.getProperty("flexVersion"), "zip", "configs"); - File frameworkDir = configsZip.getParentFile(); - File unpackedConfigsDir = new File(frameworkDir, "configs_zip"); - // If the directory doesn't exist, we have to create it by unpacking the zip archive. - // This is identical behaviour to Flexmojos, which does the same thing. - if(!unpackedConfigsDir.exists()) { - // TODO: Implement - } - 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); @@ -64,22 +71,61 @@ public class MavenTestAdapter implements ITestAdapter { } @Override - public File getArtifact(String artifactName) { + public String getFlexManifestPath(String type) { + File configsZip = getDependency("org.apache.flex.framework", "framework", + System.getProperty("flexVersion"), "zip", "configs"); + File frameworkDir = configsZip.getParentFile(); + File unpackedConfigsDir = new File(frameworkDir, "configs_zip"); + // If the directory doesn't exist, we have to create it by unpacking the zip archive. + // This is identical behaviour to Flexmojos, which does the same thing. + if(!unpackedConfigsDir.exists()) { + // TODO: Implement + } + return new File(unpackedConfigsDir, type + "-manifest.xml").getPath(); + } + + @Override + public File getFlexArtifact(String artifactName) { String flexVersion = System.getProperty("flexVersion"); return getDependency("org.apache.flex.framework", artifactName, flexVersion, "swc", null); } @Override - public File getArtifactResourceBundle(String artifactName) { + public File getFlexArtifactResourceBundle(String artifactName) { String flexVersion = System.getProperty("flexVersion"); return getDependency("org.apache.flex.framework", artifactName, flexVersion, "rb.swc", "en_US"); } + @Override + public String getFlexJsManifestPath(String type) { + File configsZip = getDependency("org.apache.flex.framework.flexjs", "framework", + System.getProperty("flexJsVersion"), "zip", "configs"); + File frameworkDir = configsZip.getParentFile(); + File unpackedConfigsDir = new File(frameworkDir, "configs_zip"); + // If the directory doesn't exist, we have to create it by unpacking the zip archive. + // This is identical behaviour to Flexmojos, which does the same thing. + if(!unpackedConfigsDir.exists()) { + // TODO: Implement + } + return new File(unpackedConfigsDir, type + "-manifest.xml").getPath(); + } + + @Override + public File getFlexJSArtifact(String artifactName) { + String flexJsVersion = System.getProperty("flexJsVersion"); + return getDependency("org.apache.flex.framework.flexjs", artifactName, flexJsVersion, "swc", null); + } + + @Override + public File getUnitTestBaseDir() { + return new File(FilenameUtils.normalize("target/test-classes")); + } + private File getDependency(String groupId, String artifactId, String version, String type, String classifier) { - String dependencyPath = System.getProperty("mavenLocalRepoDir") + "/" + groupId.replaceAll("\\.", "/") + "/" + - artifactId + "/" + version + "/" + artifactId + "-" + version + - ((classifier != null) ? "-" + classifier : "") + "." + type; - dependencyPath = FilenameNormalization.normalize(dependencyPath); + String dependencyPath = System.getProperty("mavenLocalRepoDir") + File.separator + + groupId.replaceAll("\\.", File.separator) + File.separator + artifactId + File.separator + version + + File.separator + artifactId + "-" + version + ((classifier != null) ? "-" + classifier : "") + "." + + type; File dependency = new File(dependencyPath); if(!dependency.exists()) { throw new RuntimeException("Could not read SWC dependency at " + dependency.getAbsolutePath()); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/compiler.tests/src/org/apache/flex/utils/TestAdapterFactory.java ---------------------------------------------------------------------- diff --git a/compiler.tests/src/org/apache/flex/utils/TestAdapterFactory.java b/compiler.tests/src/org/apache/flex/utils/TestAdapterFactory.java new file mode 100644 index 0000000..ccdb0c2 --- /dev/null +++ b/compiler.tests/src/org/apache/flex/utils/TestAdapterFactory.java @@ -0,0 +1,41 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.flex.utils; + +/** + * Created by christoferdutz on 10.03.16. + */ +public class TestAdapterFactory { + + private static final ITestAdapter adapter = + System.getProperty("buildType", "Ant").equals("Maven") ? + new MavenTestAdapter() : new AntTestAdapter(); + + /** + * Depending on the "buildType" system-property, create the corresponding test-adapter + * Make the AntTestAdapter the default. + * + * @return test adapter instance for the given type of build. + */ + public static ITestAdapter getTestAdapter() { + return adapter; + } + +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d4aaeab9/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java ---------------------------------------------------------------------- diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java index 70eed1a..1598e9d 100644 --- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java +++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java @@ -19,16 +19,6 @@ package org.apache.flex.compiler.internal.tree.mxml; -import static org.junit.Assert.assertNotNull; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import org.apache.flex.compiler.internal.mxml.MXMLNamespaceMapping; import org.apache.flex.compiler.internal.projects.FlexProject; import org.apache.flex.compiler.internal.projects.FlexProjectConfigurator; @@ -40,14 +30,17 @@ import org.apache.flex.compiler.tree.as.IASNode; import org.apache.flex.compiler.tree.mxml.IMXMLFileNode; import org.apache.flex.compiler.units.ICompilationUnit; import org.apache.flex.compiler.units.requests.ISyntaxTreeRequestResult; -import org.apache.flex.utils.EnvProperties; -import org.apache.flex.utils.FilenameNormalization; -import org.apache.flex.utils.StringUtils; -import org.apache.flex.utils.ITestAdapter; -import org.apache.flex.utils.AntTestAdapter; -import org.apache.flex.utils.MavenTestAdapter; +import org.apache.flex.utils.*; import org.junit.Ignore; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + /** * JUnit tests for {@link MXMLNodeBase}. * @@ -56,8 +49,7 @@ import org.junit.Ignore; @Ignore public class MXMLNodeBaseTests { - private static EnvProperties env = EnvProperties.initiate(); - + protected static Workspace workspace = new Workspace(); protected FlexProject project; @@ -130,10 +122,7 @@ public class MXMLNodeBaseTests project = new FlexProject(workspace); FlexProjectConfigurator.configure(project); - // 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(); + ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter(); String tempDir = testAdapter.getTempDir(); File tempMXMLFile = null; @@ -161,7 +150,7 @@ public class MXMLNodeBaseTests // Use the MXML 2009 manifest. List<IMXMLNamespaceMapping> namespaceMappings = new ArrayList<IMXMLNamespaceMapping>(); IMXMLNamespaceMapping mxml2009 = new MXMLNamespaceMapping( - "http://ns.adobe.com/mxml/2009", testAdapter.getManifestPath()); + "http://ns.adobe.com/mxml/2009", testAdapter.getFlexManifestPath("mxml-2009")); namespaceMappings.add(mxml2009); project.setNamespaceMappings(namespaceMappings);