Repository: flex-asjs
Updated Branches:
  refs/heads/develop fbc7d5c06 -> 83804e4af


- Added a Unit-Test that checks if the examples builds all produce both Flash 
and JavaScript output.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/83804e4a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/83804e4a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/83804e4a

Branch: refs/heads/develop
Commit: 83804e4afd240f40e2a76f75066c414e522d06c4
Parents: fbc7d5c
Author: Christofer Dutz <christofer.d...@codecentric.de>
Authored: Thu Oct 13 13:21:07 2016 +0200
Committer: Christofer Dutz <christofer.d...@codecentric.de>
Committed: Thu Oct 13 13:21:07 2016 +0200

----------------------------------------------------------------------
 examples/examples-tests/pom.xml                 |  46 ++++++++
 .../flexjs/examples/tests/ExampleBuildTest.java | 104 +++++++++++++++++++
 examples/flexjs/pom.xml                         |  41 +++++++-
 examples/pom.xml                                |   2 +
 4 files changed, 192 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83804e4a/examples/examples-tests/pom.xml
----------------------------------------------------------------------
diff --git a/examples/examples-tests/pom.xml b/examples/examples-tests/pom.xml
new file mode 100644
index 0000000..31a5e8d
--- /dev/null
+++ b/examples/examples-tests/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.flex.flexjs.examples</groupId>
+    <artifactId>examples</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>examples-tests</artifactId>
+  <version>0.8.0-SNAPSHOT</version>
+
+  <name>Apache Flex - FlexJS: Framework: Example-Tests</name>
+
+  <build>
+    <sourceDirectory>src/main/java</sourceDirectory>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83804e4a/examples/examples-tests/src/main/java/org/apache/flex/flexjs/examples/tests/ExampleBuildTest.java
----------------------------------------------------------------------
diff --git 
a/examples/examples-tests/src/main/java/org/apache/flex/flexjs/examples/tests/ExampleBuildTest.java
 
b/examples/examples-tests/src/main/java/org/apache/flex/flexjs/examples/tests/ExampleBuildTest.java
new file mode 100644
index 0000000..1842d8a
--- /dev/null
+++ 
b/examples/examples-tests/src/main/java/org/apache/flex/flexjs/examples/tests/ExampleBuildTest.java
@@ -0,0 +1,104 @@
+/*
+ *
+ *  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.flexjs.examples.tests;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * A simple JUnit test, that checks the typical build artifacts for an SWF
+ * build are produced. It currently just checks the existence of the artifacts,
+ * it doesn't check, if they are valid or runnable.
+ */
+public class ExampleBuildTest {
+
+    /**
+     * Test the existence of the SWF output for the Flash/air build.
+     */
+    @Test
+    public void testFlashBuild() {
+        Assume.assumeTrue("Only run this test in SWF projects", 
isSwfProject());
+
+        File buildDirectory = getBuildDirectory();
+
+        File swfFile = new File(buildDirectory, getArtifactId() + "-" + 
getVersion() + ".swf");
+        Assert.assertTrue("The SWF file doesn't exist: " + 
swfFile.getAbsolutePath(), swfFile.exists());
+        Assert.assertTrue("The SWF file is not a file.", swfFile.isFile());
+        Assert.assertTrue("The SWF file is empty.", swfFile.length() > 0);
+    }
+
+    /**
+     * Test the existence of the JavaScript and WAR output for the JavaScript 
build.
+     */
+    @Test
+    public void testJavaScriptBuild() {
+        Assume.assumeTrue("Only run this test in SWF projects", 
isSwfProject());
+
+        File buildDirectory = getBuildDirectory();
+
+        File explodedWarDirectory = new File(buildDirectory, getArtifactId() + 
"-" + getVersion());
+        Assert.assertTrue("The exploded WAR directory doesn't exist.", 
explodedWarDirectory.exists());
+        Assert.assertTrue("The exploded WAR directory is not a directory.", 
explodedWarDirectory.isDirectory());
+        Assert.assertTrue("The exploded WAR directory is empty.", 
explodedWarDirectory.length() > 0);
+
+        File warFile = new File(buildDirectory, getArtifactId() + "-" + 
getVersion() + ".war");
+        Assert.assertTrue("The WAR file doesn't exist.", warFile.exists());
+        Assert.assertTrue("The WAR file is not a file.", warFile.isFile());
+        Assert.assertTrue("The WAR file is empty.", warFile.length() > 0);
+    }
+
+    ///////////////////////////////////////////////////////////////////
+    // Utility methods
+    ///////////////////////////////////////////////////////////////////
+
+    protected boolean isSwfProject() {
+        String type = System.getProperty("type", "jar");
+        return "swf".equalsIgnoreCase(type);
+    }
+
+    protected File getBuildDirectory() {
+        Assert.assertNotNull("The 'buildDirectory' system property is not 
set.",
+                System.getProperty("buildDirectory", null));
+
+        File buildDirectory = new File(System.getProperty("buildDirectory"));
+        Assert.assertTrue("The directory specified by the 'buildDirectory' 
system property doesn't exist.",
+                buildDirectory.exists());
+        Assert.assertTrue("The directory specified by the 'buildDirectory' 
system property is not a directory.",
+                buildDirectory.isDirectory());
+
+        return buildDirectory;
+    }
+
+    protected String getArtifactId() {
+        Assert.assertNotNull("The 'artifactId' system property is not set.",
+                System.getProperty("artifactId", null));
+        return System.getProperty("artifactId");
+    }
+
+    protected String getVersion() {
+        Assert.assertNotNull("The 'version' system property is not set.",
+                System.getProperty("version", null));
+        return System.getProperty("version");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83804e4a/examples/flexjs/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/pom.xml b/examples/flexjs/pom.xml
index 2098382..cf65ec1 100644
--- a/examples/flexjs/pom.xml
+++ b/examples/flexjs/pom.xml
@@ -49,14 +49,45 @@
     <module>HelloWorld</module>
     <module>MapSearch</module>
     <module>MobileMap</module>
-    <module>MobileTrader</module>
     <module>MobileStocks</module>
+    <module>MobileTrader</module>
     <module>StorageExample</module>
     <module>StyleExample</module>
     <module>TodoListSampleApp</module>
     <module>TreeExample</module>
   </modules>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.19.1</version>
+        <executions>
+          <execution>
+            <id>tests-default</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              <!-- Run the tests from the 'examples-tests' artifact -->
+              <dependenciesToScan>
+                
<dependency>org.apache.flex.flexjs.examples:examples-tests</dependency>
+              </dependenciesToScan>
+              <systemPropertyVariables>
+                <artifactId>${project.artifactId}</artifactId>
+                <version>${project.version}</version>
+                <type>${project.packaging}</type>
+                <buildDirectory>${project.build.directory}</buildDirectory>
+              </systemPropertyVariables>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.flex.flexjs.framework</groupId>
@@ -94,6 +125,14 @@
       <version>0.8.0-SNAPSHOT</version>
       <type>swc</type>
     </dependency>
+
+    <!-- Import the shared unit-tests we want to run on all examples -->
+    <dependency>
+      <groupId>org.apache.flex.flexjs.examples</groupId>
+      <artifactId>examples-tests</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83804e4a/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index c18b9f8..6c5c156 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -37,6 +37,8 @@
   <modules>
     <module>flexjs</module>
     <!--module>native</module-->
+
+    <module>examples-tests</module>
   </modules>
 
   <build>

Reply via email to