Adding java8 patterns for test exclusion.

Author: Goktug Gokdogan
Change-Id: Ibfaa119e7cb150cb386ad36a333ac743db73f8d7
diff --git a/user/BUILD b/user/BUILD
index bc17c5c..b504ef2 100644
--- a/user/BUILD
+++ b/user/BUILD
@@ -484,6 +484,8 @@
         exclude = [
             "test/**/super/**",
             "test/**/tck/**",
+            "test/**/java8/**",
+            "test/**/*Java8Suite.java",
             "**/RunStyleSeleniumTest.java",
         ],
     ),
@@ -555,6 +557,7 @@
         exclude = [
             "test/**/ConstraintDefinitionsGwtSuite.java",
             "test/**/*JreSuite.java",
+            "test/**/*Java8Suite.java",
         ],
     ),
 )
@@ -579,6 +582,7 @@
             "test/**/RunAsyncSuite.java",
             "test/**/*JreSuite.java",
             "test/**/*JsInteropSuite.java",
+            "test/**/*Java8Suite.java",
         ],
     ),
 )
diff --git a/user/build.xml b/user/build.xml
index 356352c..4339909 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -13,11 +13,26 @@
 
   <property name="test.timeout" value="5"/>
   <property name="emma.merged.out" value="${junit.out}/emma-coverage"/>
+
+  <condition property="gwt.junit.user.excludes"
+             value="com/google/gwt/langtest/**,**/super/**,**/java8/**,**/*Java8Suite.java"
+             else="com/google/gwt/langtest/**,**/super/**">
+    <equals arg1="${javac.source}" arg2="1.7" />
+  </condition>
+
   <property name="gwt.junit.testcase.web.includes" value="${gwt.junit.testcase.includes}"/>
-  <property name="gwt.junit.testcase.web.excludes" value="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*"/>
+  <condition property="gwt.junit.testcase.web.excludes"
+            value="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*,**/*Java8Suite.class"
+            else="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*">
+    <equals arg1="${javac.source}" arg2="1.7" />
+  </condition>
 
   <property name="gwt.junit.testcase.dev.includes" value="${gwt.junit.testcase.includes}"/>
-  <property name="gwt.junit.testcase.dev.excludes" value="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*"/>
+  <condition property="gwt.junit.testcase.dev.excludes"
+            value="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*,**/*Java8Suite.class"
+            else="**/*JsInteropSuite.class,**/*JreSuite.class,**/OptimizedOnly*">
+    <equals arg1="${javac.source}" arg2="1.7" />
+  </condition>
 
   <property name="gwt.tck.testcase.dev.includes"
             value="com/google/gwt/validation/tck/**/*GwtSuite.class"/>
@@ -127,7 +142,7 @@
           depends="compile.dev.tests, compile.emma.if.enabled"
           unless="compile.tests.complete">
     <mkdir dir="${javac.junit.out}"/>
-    <gwt.javac srcdir="test" excludes="com/google/gwt/langtest/**,**/super/**" destdir="${javac.junit.out}">
+    <gwt.javac srcdir="test" destdir="${javac.junit.out}" excludes="${gwt.junit.user.excludes}">
       <classpath>
         <pathelement location="${javac.out}"/>
         <pathelement location="${gwt.tools.lib}/junit/junit-4.8.2.jar"/>
diff --git a/user/test/com/google/gwt/emultest/EmulJava8Suite.java b/user/test/com/google/gwt/emultest/EmulJava8Suite.java
new file mode 100644
index 0000000..ee43edf
--- /dev/null
+++ b/user/test/com/google/gwt/emultest/EmulJava8Suite.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.emultest;
+
+import com.google.gwt.emultest.java8.util.OptionalTest;
+import com.google.gwt.junit.tools.GWTTestSuite;
+
+import junit.framework.Test;
+
+/**
+ * Test Java8 JRE emulations.
+ */
+public class EmulJava8Suite {
+
+  public static Test suite() {
+    GWTTestSuite suite = new GWTTestSuite("Tests for com.google.gwt.emul.java8");
+
+    //-- java.util
+    suite.addTestSuite(OptionalTest.class);
+
+    return suite;
+  }
+}
diff --git a/user/test/com/google/gwt/emultest/EmulSuite.gwt.xml b/user/test/com/google/gwt/emultest/EmulSuite.gwt.xml
index 2d628ff..151b673 100644
--- a/user/test/com/google/gwt/emultest/EmulSuite.gwt.xml
+++ b/user/test/com/google/gwt/emultest/EmulSuite.gwt.xml
@@ -17,6 +17,7 @@
   <inherits name='com.google.gwt.testing.TestUtils' />
   <inherits name='org.apache.commons.Collections' />
   <source path='java' />
+  <source path='java8' />
 
   <define-configuration-property name="someConfigurationProperty" is-multi-valued='false'/>
   <set-configuration-property name="someConfigurationProperty" value="conf"/>
diff --git a/user/test/com/google/gwt/emultest/java8/util/OptionalTest.java b/user/test/com/google/gwt/emultest/java8/util/OptionalTest.java
new file mode 100644
index 0000000..fbb8daa
--- /dev/null
+++ b/user/test/com/google/gwt/emultest/java8/util/OptionalTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.emultest.java8.util;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests for Optional JRE emulation.
+ */
+public class OptionalTest extends GWTTestCase {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.emultest.EmulSuite";
+  }
+
+  public void testSomething() {
+    try {
+      requireNonNull(null, () -> "Must not be null");
+      fail("must throw NPE");
+    } catch (NullPointerException e) {
+      // expected
+    }
+  }
+
+  private static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
+    if (obj == null) {
+      throw new NullPointerException(messageSupplier.get());
+    }
+    return obj;
+  }
+
+  @FunctionalInterface
+  private interface Supplier<T> {
+    T get();
+  }
+}