You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/03/25 11:25:05 UTC
groovy git commit: Move java test files to "test" directory
Repository: groovy
Updated Branches:
refs/heads/master 0f0c96d5a -> ef0ac1fe5
Move java test files to "test" directory
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ef0ac1fe
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ef0ac1fe
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ef0ac1fe
Branch: refs/heads/master
Commit: ef0ac1fe50e88a012296c13909e6daf6c03c3dea
Parents: 0f0c96d
Author: danielsun1106 <re...@hotmail.com>
Authored: Sun Mar 25 19:24:53 2018 +0800
Committer: danielsun1106 <re...@hotmail.com>
Committed: Sun Mar 25 19:24:53 2018 +0800
----------------------------------------------------------------------
.../java/org/apache/groovy/util/MapsTest.java | 49 -----------
.../ConcurrentLinkedHashMapTest.java | 89 --------------------
.../runtime/EncodingGroovyMethodsTest.java | 36 --------
src/test/org/apache/groovy/util/MapsTest.java | 49 +++++++++++
.../ConcurrentLinkedHashMapTest.java | 89 ++++++++++++++++++++
.../runtime/EncodingGroovyMethodsTest.java | 36 ++++++++
6 files changed, 174 insertions(+), 174 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/java/org/apache/groovy/util/MapsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/groovy/util/MapsTest.java b/src/test/java/org/apache/groovy/util/MapsTest.java
deleted file mode 100644
index 6a00785..0000000
--- a/src/test/java/org/apache/groovy/util/MapsTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.groovy.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Map;
-
-public class MapsTest {
-
- @Test
- public void inverse() {
- Map<String, Integer> map = Maps.of("a", 1, "b", 2, "c", 3);
- Map<Integer, String> inversedMap = Maps.inverse(map);
-
- Assert.assertEquals(map.size(), inversedMap.size());
- for (Map.Entry<Integer, String> entry : inversedMap.entrySet()) {
- Assert.assertEquals(map.get(entry.getValue()), entry.getKey());
- }
-
- try {
- Maps.inverse(Maps.of("a", 1, "b", 2, "c", 2));
- } catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains("duplicated key found: 2"));
- }
-
- Map<Integer, String> inversedMap2 = Maps.inverse(Maps.of("a", 1, "b", 2, "c", 2), true);
- Assert.assertEquals(2, inversedMap2.size());
- Assert.assertEquals("a", inversedMap2.get(1));
- Assert.assertEquals("c", inversedMap2.get(2));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java b/src/test/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
deleted file mode 100644
index 055b3c7..0000000
--- a/src/test/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.groovy.util.concurrentlinkedhashmap;
-
-import org.junit.Test;
-
-import java.util.TreeSet;
-import java.util.concurrent.CountDownLatch;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-public class ConcurrentLinkedHashMapTest {
- @Test
- public void computeIfAbsent() {
- ConcurrentLinkedHashMap m = new ConcurrentLinkedHashMap.Builder<>()
- .maximumWeightedCapacity(3)
- .build();
-
- assertEquals(1, m.computeIfAbsent("a", k -> 1));
- assertEquals(1, m.computeIfAbsent("a", k -> 2));
-
- assertEquals(1, m.get("a"));
-
- assertEquals(3, m.computeIfAbsent("b", k -> 3));
- assertEquals(4, m.computeIfAbsent("c", k -> 4));
- assertEquals(5, m.computeIfAbsent("d", k -> 5));
- assertEquals(5, m.computeIfAbsent("d", k -> 6));
-
- assertArrayEquals(new String[] {"b", "c", "d"}, m.keySet().toArray(new String[0]));
- assertArrayEquals(new Integer[] {3, 4, 5}, m.values().toArray(new Integer[0]));
- }
-
- @Test
- public void computeIfAbsentConcurrently() throws InterruptedException {
- final ConcurrentLinkedHashMap m = new ConcurrentLinkedHashMap.Builder<>()
- .maximumWeightedCapacity(3)
- .build();
-
- final int threadNum = 20;
- final CountDownLatch countDownLatch = new CountDownLatch(1);
- final CountDownLatch countDownLatch2 = new CountDownLatch(threadNum);
-
- for (int i = 0; i < threadNum; i++) {
- final int num = i;
- new Thread(() -> {
- try {
- countDownLatch.await();
-
- m.computeIfAbsent(num % 3, k -> num);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } finally {
- countDownLatch2.countDown();
- }
- }).start();
- }
-
- countDownLatch.countDown();
- countDownLatch2.await();
-
- m.computeIfAbsent(0, k -> 100);
-
- assertArrayEquals(new Integer[] {0, 1, 2}, new TreeSet(m.keySet()).toArray(new Integer[0]));
-
- assertNotEquals(100, m.get(0));
- assertEquals(0, (Integer) m.get(0) % 3);
- assertEquals(1, (Integer) m.get(1) % 3);
- assertEquals(2, (Integer) m.get(2) % 3);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/java/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java b/src/test/java/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
deleted file mode 100644
index 20c0897..0000000
--- a/src/test/java/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.codehaus.groovy.runtime;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class EncodingGroovyMethodsTest {
- @Test
- public void md5() throws Exception {
- Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.md5("abc123"));
- Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.md5("abc123".getBytes("UTF-8")));
- }
-
- @Test
- public void digest() throws Exception {
- Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.digest("abc123", "MD5"));
- Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.digest("abc123".getBytes("UTF-8"), "MD5"));
- }
-}
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/org/apache/groovy/util/MapsTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/groovy/util/MapsTest.java b/src/test/org/apache/groovy/util/MapsTest.java
new file mode 100644
index 0000000..6a00785
--- /dev/null
+++ b/src/test/org/apache/groovy/util/MapsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.groovy.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+
+public class MapsTest {
+
+ @Test
+ public void inverse() {
+ Map<String, Integer> map = Maps.of("a", 1, "b", 2, "c", 3);
+ Map<Integer, String> inversedMap = Maps.inverse(map);
+
+ Assert.assertEquals(map.size(), inversedMap.size());
+ for (Map.Entry<Integer, String> entry : inversedMap.entrySet()) {
+ Assert.assertEquals(map.get(entry.getValue()), entry.getKey());
+ }
+
+ try {
+ Maps.inverse(Maps.of("a", 1, "b", 2, "c", 2));
+ } catch (IllegalArgumentException e) {
+ Assert.assertTrue(e.getMessage().contains("duplicated key found: 2"));
+ }
+
+ Map<Integer, String> inversedMap2 = Maps.inverse(Maps.of("a", 1, "b", 2, "c", 2), true);
+ Assert.assertEquals(2, inversedMap2.size());
+ Assert.assertEquals("a", inversedMap2.get(1));
+ Assert.assertEquals("c", inversedMap2.get(2));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java b/src/test/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
new file mode 100644
index 0000000..055b3c7
--- /dev/null
+++ b/src/test/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMapTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.groovy.util.concurrentlinkedhashmap;
+
+import org.junit.Test;
+
+import java.util.TreeSet;
+import java.util.concurrent.CountDownLatch;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class ConcurrentLinkedHashMapTest {
+ @Test
+ public void computeIfAbsent() {
+ ConcurrentLinkedHashMap m = new ConcurrentLinkedHashMap.Builder<>()
+ .maximumWeightedCapacity(3)
+ .build();
+
+ assertEquals(1, m.computeIfAbsent("a", k -> 1));
+ assertEquals(1, m.computeIfAbsent("a", k -> 2));
+
+ assertEquals(1, m.get("a"));
+
+ assertEquals(3, m.computeIfAbsent("b", k -> 3));
+ assertEquals(4, m.computeIfAbsent("c", k -> 4));
+ assertEquals(5, m.computeIfAbsent("d", k -> 5));
+ assertEquals(5, m.computeIfAbsent("d", k -> 6));
+
+ assertArrayEquals(new String[] {"b", "c", "d"}, m.keySet().toArray(new String[0]));
+ assertArrayEquals(new Integer[] {3, 4, 5}, m.values().toArray(new Integer[0]));
+ }
+
+ @Test
+ public void computeIfAbsentConcurrently() throws InterruptedException {
+ final ConcurrentLinkedHashMap m = new ConcurrentLinkedHashMap.Builder<>()
+ .maximumWeightedCapacity(3)
+ .build();
+
+ final int threadNum = 20;
+ final CountDownLatch countDownLatch = new CountDownLatch(1);
+ final CountDownLatch countDownLatch2 = new CountDownLatch(threadNum);
+
+ for (int i = 0; i < threadNum; i++) {
+ final int num = i;
+ new Thread(() -> {
+ try {
+ countDownLatch.await();
+
+ m.computeIfAbsent(num % 3, k -> num);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ countDownLatch2.countDown();
+ }
+ }).start();
+ }
+
+ countDownLatch.countDown();
+ countDownLatch2.await();
+
+ m.computeIfAbsent(0, k -> 100);
+
+ assertArrayEquals(new Integer[] {0, 1, 2}, new TreeSet(m.keySet()).toArray(new Integer[0]));
+
+ assertNotEquals(100, m.get(0));
+ assertEquals(0, (Integer) m.get(0) % 3);
+ assertEquals(1, (Integer) m.get(1) % 3);
+ assertEquals(2, (Integer) m.get(2) % 3);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/groovy/blob/ef0ac1fe/src/test/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java b/src/test/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
new file mode 100644
index 0000000..20c0897
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/EncodingGroovyMethodsTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.codehaus.groovy.runtime;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EncodingGroovyMethodsTest {
+ @Test
+ public void md5() throws Exception {
+ Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.md5("abc123"));
+ Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.md5("abc123".getBytes("UTF-8")));
+ }
+
+ @Test
+ public void digest() throws Exception {
+ Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.digest("abc123", "MD5"));
+ Assert.assertEquals("e99a18c428cb38d5f260853678922e03", EncodingGroovyMethods.digest("abc123".getBytes("UTF-8"), "MD5"));
+ }
+}