You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/04/26 10:40:55 UTC
[GitHub] [commons-collections] kinow opened a new pull request, #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
kinow opened a new pull request, #301:
URL: https://github.com/apache/commons-collections/pull/301
Adding the test class from @ben-manes, pending merge of #300
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] codecov-commenter commented on pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #301:
URL: https://github.com/apache/commons-collections/pull/301#issuecomment-1114144824
# [Codecov](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#301](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (919b449) into [master](https://codecov.io/gh/apache/commons-collections/commit/1677daceab74895fdf5056c9a48aa94f9e709fb9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1677dac) will **increase** coverage by `0.10%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #301 +/- ##
============================================
+ Coverage 85.87% 85.97% +0.10%
- Complexity 4676 4678 +2
============================================
Files 292 292
Lines 13469 13469
Branches 1955 1955
============================================
+ Hits 11566 11580 +14
+ Misses 1326 1321 -5
+ Partials 577 568 -9
```
| [Impacted Files](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...he/commons/collections4/map/AbstractHashedMap.java](https://codecov.io/gh/apache/commons-collections/pull/301/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29sbGVjdGlvbnM0L21hcC9BYnN0cmFjdEhhc2hlZE1hcC5qYXZh) | `93.82% <0.00%> (+0.98%)` | :arrow_up: |
| [...commons/collections4/map/AbstractReferenceMap.java](https://codecov.io/gh/apache/commons-collections/pull/301/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29sbGVjdGlvbnM0L21hcC9BYnN0cmFjdFJlZmVyZW5jZU1hcC5qYXZh) | `91.48% <0.00%> (+1.11%)` | :arrow_up: |
| [...org/apache/commons/collections4/list/TreeList.java](https://codecov.io/gh/apache/commons-collections/pull/301/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29sbGVjdGlvbnM0L2xpc3QvVHJlZUxpc3QuamF2YQ==) | `93.56% <0.00%> (+1.87%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [1677dac...919b449](https://codecov.io/gh/apache/commons-collections/pull/301?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r890569602
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.list.TreeList;
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.ListTestSuiteBuilder;
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringListGenerator;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.Feature;
+import com.google.common.collect.testing.features.ListFeature;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
Review Comment:
Done @garydgregory ! Thanks
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.list.TreeList;
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.ListTestSuiteBuilder;
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringListGenerator;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.Feature;
+import com.google.common.collect.testing.features.ListFeature;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
Review Comment:
Done @garydgregory, and rebased! Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] ben-manes commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
ben-manes commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r861137680
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
The collection tests are JUnit3-based, and JUnit 4/5 have runners for supporting their older versions. Since those versions are not backwards compatible otherwise, it's a framework limitation. I think it is unlikely for Guava to revise the tests as it works well enough, even if old code.
FYI there are more test cases you could add (List, Set, etc) and I only did a quick check for Maps. (I also [borrowed](https://github.com/ben-manes/caffeine/tree/master/caffeine/src/test/java/com/github/benmanes/caffeine) your tests for my implementation as another sanity check)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] ben-manes commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
ben-manes commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r890338589
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.list.TreeList;
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.ListTestSuiteBuilder;
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringListGenerator;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.Feature;
+import com.google.common.collect.testing.features.ListFeature;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
Review Comment:
I am fine having it removed and appreciate the thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r862427902
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
Yeah, same for me with your code. I'm updating the PR now with the `suiteMap` and `suiteTest` methods, but leaving only `TreeList` tests enabled for now. I left a `TODO` marker so we can revisit it later.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on PR #301:
URL: https://github.com/apache/commons-collections/pull/301#issuecomment-1112054324
Rebased. Confirmed the license is compatible (AL as well). Waiting for CI, and will update `changes.xml` in the meantime. Then it should be ready for review :+1:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] ben-manes commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
ben-manes commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r862423560
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
I can get a little further using the following, where `TreeList` passes but the others don't. The remaining failures look like actual mistakes.
```java
public static Test suite() {
TestSuite test = new TestSuite();
test.addTest(suiteList("TreeList", TreeList::new));
test.addTest(suiteList("GrowthList", GrowthList::new, CollectionFeature.SERIALIZABLE));
test.addTest(suiteList("CursorableLinkedList", CursorableLinkedList::new, CollectionFeature.SERIALIZABLE));
return test;
}
public static Test suiteList(String name, Supplier<List<String>> factory, Feature<?>... features) {
var suite = ListTestSuiteBuilder.using(new TestStringListGenerator() {
@Override
protected List<String> create(String[] elements) {
List<String> list = factory.get();
for (String element : elements) {
list.add(element);
}
return list;
}
}).named(name)
.withFeatures(CollectionSize.ANY,
ListFeature.GENERAL_PURPOSE,
ListFeature.REMOVE_OPERATIONS,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.DESCENDING_VIEW,
CollectionFeature.SUBSET_VIEW);
suite.withFeatures(features);
return suite.createTestSuite();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] ben-manes commented on pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
ben-manes commented on PR #301:
URL: https://github.com/apache/commons-collections/pull/301#issuecomment-1111598917
/cc @kevinb9n 🙂
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r860855659
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
I thought about that too, but I don't know how to translate the test suite created programmatically to JUnit 5 :disappointed_relieved: ping @ben-manes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] garydgregory commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
garydgregory commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r860754312
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
Can this be done in the JUnit 4 or 5 style?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on PR #301:
URL: https://github.com/apache/commons-collections/pull/301#issuecomment-1114077324
Rebased.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r862407940
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
Thanks @ben-manes !
I will leave the List, Set, etc., for follow-up issues. I had some 5 minutes to test it, and managed to write some tests for Lists, but these tests found issues in some of the Lists. I'd have to confirm if the features I selected are actually pertinent to the List implementations I used, or if we have other bugs :slightly_smiling_face:
So it's definitely useful, but I prefer to get this merged first for Maps, and later add other Map, List, Set implementations too :+1:
Here's the diff of what I had FWIW, thanks!!!
Bruno
```diff
diff --git a/src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java b/src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java
index 88108c6a..7d068e17 100644
--- a/src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java
+++ b/src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java
@@ -17,18 +17,25 @@
package org.apache.commons.collections4;
+import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.commons.collections4.list.CursorableLinkedList;
+import org.apache.commons.collections4.list.GrowthList;
+import org.apache.commons.collections4.list.TreeList;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.collections4.map.LRUMap;
import org.apache.commons.collections4.map.LinkedMap;
import org.apache.commons.collections4.map.ReferenceMap;
+import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringListGenerator;
import com.google.common.collect.testing.TestStringMapGenerator;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.ListFeature;
import com.google.common.collect.testing.features.MapFeature;
import junit.framework.Test;
@@ -49,14 +56,17 @@ public final class GuavaTestlibTest extends TestCase {
public static Test suite() {
TestSuite test = new TestSuite();
- test.addTest(suite("HashedMap", HashedMap::new));
- test.addTest(suite("LinkedMap", LinkedMap::new));
- test.addTest(suite("LRUMap", LRUMap::new));
- test.addTest(suite("ReferenceMap", ReferenceMap::new));
+ test.addTest(suiteMap("HashedMap", HashedMap::new));
+ test.addTest(suiteMap("LinkedMap", LinkedMap::new));
+ test.addTest(suiteMap("LRUMap", LRUMap::new));
+ test.addTest(suiteMap("ReferenceMap", ReferenceMap::new));
+ test.addTest(suiteList("List", TreeList::new));
+ test.addTest(suiteList("GrowthList", GrowthList::new));
+ test.addTest(suiteList("CursorableLinkedList", CursorableLinkedList::new));
return test;
}
- public static Test suite(String name, Supplier<Map<String, String>> factory) {
+ public static Test suiteMap(String name, Supplier<Map<String, String>> factory) {
return MapTestSuiteBuilder.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Map.Entry<String, String>[] entries) {
@@ -73,4 +83,23 @@ public final class GuavaTestlibTest extends TestCase {
MapFeature.ALLOWS_ANY_NULL_QUERIES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
.createTestSuite();
}
+
+ public static Test suiteList(String name, Supplier<List<String>> factory) {
+ return ListTestSuiteBuilder.using(new TestStringListGenerator() {
+ @Override
+ protected List<String> create(String[] elements) {
+ List<String> list = factory.get();
+ for (String element : elements) {
+ list.add(element);
+ }
+ return list;
+ }
+ })
+ .named(name)
+ .withFeatures(
+ CollectionSize.ANY, ListFeature.GENERAL_PURPOSE,
+ ListFeature.REMOVE_OPERATIONS, ListFeature.SUPPORTS_REMOVE_WITH_INDEX,
+ CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
+ .createTestSuite();
+ }
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] ben-manes commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
ben-manes commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r862521177
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
+ *
+ * @since 4.5.0
+ * @see <a href="https://github.com/google/guava/tree/master/guava-testlib">https://github.com/google/guava/tree/master/guava-testlib</a>
+ * @see <a href="https://issues.apache.org/jira/browse/COLLECTIONS-802">https://issues.apache.org/jira/browse/COLLECTIONS-802</a>
+ */
+public final class GuavaTestlibTest extends TestCase {
+
+ public static Test suite() {
Review Comment:
At least in the case of `GrowthList` some of the failures are expected since it modified the `List` contract,
```java
* Decorates another <code>List</code> to make it seamlessly grow when
* indices larger than the list size are used on add and set,
* avoiding most IndexOutOfBoundsExceptions.
```
Technically a violation of the contract, but expected.
```java
* @throws IndexOutOfBoundsException if the index is out of range
* ({@code index < 0 || index > size()})
*/
void add(int index, E element);
```
You can use `.suppressing(Method...)` to disable those cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] kinow commented on pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
kinow commented on PR #301:
URL: https://github.com/apache/commons-collections/pull/301#issuecomment-1112055774
And didn't notice a difference in build time. Executed a few times locally as well, and can confirm it doesn't bring any brittleness to our tests. Looks like a good addition to our test code. Thanks for showing us this @ben-manes !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] garydgregory merged pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
garydgregory merged PR #301:
URL: https://github.com/apache/commons-collections/pull/301
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] garydgregory commented on a diff in pull request #301: [COLLECTIONS-811] Integrate Guava Testlib tests for Apache Commons Collections
Posted by GitBox <gi...@apache.org>.
garydgregory commented on code in PR #301:
URL: https://github.com/apache/commons-collections/pull/301#discussion_r890210693
##########
src/test/java/org/apache/commons/collections4/GuavaTestlibTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.commons.collections4;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.apache.commons.collections4.list.TreeList;
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.collections4.map.LRUMap;
+import org.apache.commons.collections4.map.LinkedMap;
+import org.apache.commons.collections4.map.ReferenceMap;
+
+import com.google.common.collect.testing.ListTestSuiteBuilder;
+import com.google.common.collect.testing.MapTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringListGenerator;
+import com.google.common.collect.testing.TestStringMapGenerator;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+import com.google.common.collect.testing.features.Feature;
+import com.google.common.collect.testing.features.ListFeature;
+import com.google.common.collect.testing.features.MapFeature;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * This test uses Google's Guava Testlib testing libraries to validate the
+ * contract of collection classes in Commons Collections. This was introduced
+ * after COLLECTIONS-802, where the issue reported was found with Testlib,
+ * with thanks to Ben Manes.
Review Comment:
We don't use `@author` tags, so would you please move attribution to `changes.xml` and/or `pom.xml`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org