Upgraded both guava and guava-testlib to 21.0 and made sure they share the same version variable

This commit is contained in:
Shams Asari 2017-03-24 11:22:53 +00:00
parent 558a3207e9
commit 52ea54f742
9 changed files with 58 additions and 40 deletions

View File

@ -1,11 +1,11 @@
buildscript { buildscript {
// For sharing constants between builds // For sharing constants between builds
Properties props = new Properties() Properties constants = new Properties()
file("publish.properties").withInputStream { props.load(it) } file("constants.properties").withInputStream { constants.load(it) }
// Our version: bump this on release. // Our version: bump this on release.
ext.corda_version = "0.10-SNAPSHOT" ext.corda_version = "0.10-SNAPSHOT"
ext.gradle_plugins_version = props.getProperty("gradlePluginsVersion") ext.gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
// Dependency versions. Can run 'gradle dependencyUpdates' to find new versions of things. // Dependency versions. Can run 'gradle dependencyUpdates' to find new versions of things.
// //
@ -22,7 +22,7 @@ buildscript {
ext.slf4j_version = '1.7.24' ext.slf4j_version = '1.7.24'
ext.log4j_version = '2.7' ext.log4j_version = '2.7'
ext.bouncycastle_version = '1.56' ext.bouncycastle_version = '1.56'
ext.guava_version = '19.0' ext.guava_version = constants.getProperty("guavaVersion")
ext.quickcheck_version = '0.7' ext.quickcheck_version = '0.7'
ext.okhttp_version = '3.5.0' ext.okhttp_version = '3.5.0'
ext.netty_version = '4.1.5.Final' ext.netty_version = '4.1.5.Final'

View File

@ -1,3 +1,10 @@
buildscript {
Properties constants = new Properties()
file("../constants.properties").withInputStream { constants.load(it) }
ext.guava_version = constants.getProperty("guavaVersion")
}
apply plugin: 'maven' apply plugin: 'maven'
repositories { repositories {
@ -5,6 +12,5 @@ repositories {
} }
dependencies { dependencies {
// Cannot use ext.guava_version here :( compile "com.google.guava:guava:$guava_version"
compile "com.google.guava:guava:20.0"
} }

View File

@ -1 +1,2 @@
gradlePluginsVersion=0.10.2 gradlePluginsVersion=0.10.2
guavaVersion=21.0

View File

@ -4,10 +4,7 @@ import com.google.common.collect.testing.SetTestSuiteBuilder
import com.google.common.collect.testing.TestIntegerSetGenerator import com.google.common.collect.testing.TestIntegerSetGenerator
import com.google.common.collect.testing.features.CollectionFeature import com.google.common.collect.testing.features.CollectionFeature
import com.google.common.collect.testing.features.CollectionSize import com.google.common.collect.testing.features.CollectionSize
import com.google.common.collect.testing.testers.CollectionAddAllTester import com.google.common.collect.testing.testers.*
import com.google.common.collect.testing.testers.CollectionClearTester
import com.google.common.collect.testing.testers.CollectionRemoveAllTester
import com.google.common.collect.testing.testers.CollectionRetainAllTester
import junit.framework.TestSuite import junit.framework.TestSuite
import net.corda.core.serialization.deserialize import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize import net.corda.core.serialization.serialize
@ -45,6 +42,7 @@ class NonEmptySetTest {
.suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject")) .suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(CollectionClearTester::class.java.methods.toList()) .suppressing(CollectionClearTester::class.java.methods.toList())
.suppressing(CollectionRetainAllTester::class.java.methods.toList()) .suppressing(CollectionRetainAllTester::class.java.methods.toList())
.suppressing(CollectionRemoveIfTester::class.java.getMethod("testRemoveIf_allPresent"))
.createTestSuite() .createTestSuite()
} }

View File

@ -3,11 +3,11 @@
buildscript { buildscript {
// For sharing constants between builds // For sharing constants between builds
Properties props = new Properties() Properties constants = new Properties()
file("../publish.properties").withInputStream { props.load(it) } file("../constants.properties").withInputStream { constants.load(it) }
// If you bump this version you must re-bootstrap the codebase. See the README for more information. // If you bump this version you must re-bootstrap the codebase. See the README for more information.
ext.gradle_plugins_version = props.getProperty("gradlePluginsVersion") ext.gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
repositories { repositories {
mavenLocal() mavenLocal()

View File

@ -4,11 +4,10 @@ apply plugin: 'com.jfrog.bintray'
// Used for bootstrapping project // Used for bootstrapping project
buildscript { buildscript {
// For sharing constants between builds Properties constants = new Properties()
Properties props = new Properties() file("../../constants.properties").withInputStream { constants.load(it) }
file("../../publish.properties").withInputStream { props.load(it) }
ext.gradle_plugins_version = props.getProperty("gradlePluginsVersion") ext.gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
repositories { repositories {
jcenter() jcenter()

View File

@ -1,5 +1,14 @@
package net.corda.node.utilities package net.corda.node.utilities
import com.google.common.collect.testing.MapTestSuiteBuilder
import com.google.common.collect.testing.SetTestSuiteBuilder
import com.google.common.collect.testing.TestStringMapGenerator
import com.google.common.collect.testing.TestStringSetGenerator
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 com.google.common.collect.testing.features.SetFeature
import com.google.common.collect.testing.testers.*
import junit.framework.TestSuite import junit.framework.TestSuite
import net.corda.testing.node.makeTestDataSourceProperties import net.corda.testing.node.makeTestDataSourceProperties
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
@ -56,39 +65,43 @@ class JDBCHashMapTestSuite {
} }
@JvmStatic @JvmStatic
fun createMapTestSuite(loadOnInit: Boolean, constrained: Boolean): TestSuite = com.google.common.collect.testing.MapTestSuiteBuilder fun createMapTestSuite(loadOnInit: Boolean, constrained: Boolean): TestSuite = MapTestSuiteBuilder
.using(JDBCHashMapTestGenerator(loadOnInit = loadOnInit, constrained = constrained)) .using(JDBCHashMapTestGenerator(loadOnInit = loadOnInit, constrained = constrained))
.named("test JDBCHashMap with loadOnInit=$loadOnInit") .named("test JDBCHashMap with loadOnInit=$loadOnInit")
.withFeatures( .withFeatures(
com.google.common.collect.testing.features.CollectionSize.ANY, CollectionSize.ANY,
com.google.common.collect.testing.features.MapFeature.ALLOWS_ANY_NULL_QUERIES, MapFeature.ALLOWS_ANY_NULL_QUERIES,
com.google.common.collect.testing.features.MapFeature.GENERAL_PURPOSE, MapFeature.GENERAL_PURPOSE,
com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER CollectionFeature.KNOWN_ORDER
) )
// putAll(null) not supported by Kotlin MutableMap interface // putAll(null) not supported by Kotlin MutableMap interface
.suppressing(com.google.common.collect.testing.testers.MapPutAllTester::class.java.getMethod("testPutAll_nullCollectionReference")) .suppressing(MapPutAllTester::class.java.getMethod("testPutAll_nullCollectionReference"))
// We suppress the following because of NotReallyMutableEntry
.suppressing(MapReplaceAllTester::class.java.getMethod("testReplaceAllPreservesOrder"))
.suppressing(MapReplaceAllTester::class.java.getMethod("testReplaceAllRotate"))
.suppressing(MapEntrySetTester::class.java.getMethod("testSetValue"))
.createTestSuite() .createTestSuite()
@JvmStatic @JvmStatic
fun createSetTestSuite(loadOnInit: Boolean, constrained: Boolean): TestSuite = com.google.common.collect.testing.SetTestSuiteBuilder fun createSetTestSuite(loadOnInit: Boolean, constrained: Boolean): TestSuite = SetTestSuiteBuilder
.using(JDBCHashSetTestGenerator(loadOnInit = loadOnInit, constrained = constrained)) .using(JDBCHashSetTestGenerator(loadOnInit = loadOnInit, constrained = constrained))
.named("test JDBCHashSet with loadOnInit=$loadOnInit") .named("test JDBCHashSet with loadOnInit=$loadOnInit")
.withFeatures( .withFeatures(
com.google.common.collect.testing.features.CollectionSize.ANY, CollectionSize.ANY,
com.google.common.collect.testing.features.SetFeature.GENERAL_PURPOSE, SetFeature.GENERAL_PURPOSE,
com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER CollectionFeature.KNOWN_ORDER
) )
// add/remove/retainAll(null) not supported by Kotlin MutableSet interface // add/remove/retainAll(null) not supported by Kotlin MutableSet interface
.suppressing(com.google.common.collect.testing.testers.CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference")) .suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference"))
.suppressing(com.google.common.collect.testing.testers.CollectionAddAllTester::class.java.getMethod("testAddAll_nullUnsupported")) .suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullUnsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionAddTester::class.java.getMethod("testAdd_nullUnsupported")) .suppressing(CollectionAddTester::class.java.getMethod("testAdd_nullUnsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionCreationTester::class.java.getMethod("testCreateWithNull_unsupported")) .suppressing(CollectionCreationTester::class.java.getMethod("testCreateWithNull_unsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject")) .suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceEmptySubject")) .suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceNonEmptySubject")) .suppressing(CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceEmptySubject")) .suppressing(CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceEmptySubject"))
.createTestSuite() .createTestSuite()
private fun setUpDatabaseTx() { private fun setUpDatabaseTx() {
@ -134,7 +147,7 @@ class JDBCHashMapTestSuite {
/** /**
* Generator of map instances needed for testing. * Generator of map instances needed for testing.
*/ */
class JDBCHashMapTestGenerator(val loadOnInit: Boolean, val constrained: Boolean) : com.google.common.collect.testing.TestStringMapGenerator() { class JDBCHashMapTestGenerator(val loadOnInit: Boolean, val constrained: Boolean) : TestStringMapGenerator() {
override fun create(elements: Array<Map.Entry<String, String>>): Map<String, String> { override fun create(elements: Array<Map.Entry<String, String>>): Map<String, String> {
val map = if (loadOnInit) loadOnInitTrueMap else if (constrained) memoryConstrainedMap else loadOnInitFalseMap val map = if (loadOnInit) loadOnInitTrueMap else if (constrained) memoryConstrainedMap else loadOnInitFalseMap
map.clear() map.clear()
@ -176,7 +189,7 @@ class JDBCHashMapTestSuite {
/** /**
* Generator of set instances needed for testing. * Generator of set instances needed for testing.
*/ */
class JDBCHashSetTestGenerator(val loadOnInit: Boolean, val constrained: Boolean) : com.google.common.collect.testing.TestStringSetGenerator() { class JDBCHashSetTestGenerator(val loadOnInit: Boolean, val constrained: Boolean) : TestStringSetGenerator() {
override fun create(elements: Array<String>): Set<String> { override fun create(elements: Array<String>): Set<String> {
val set = if (loadOnInit) loadOnInitTrueSet else if (constrained) memoryConstrainedSet else loadOnInitFalseSet val set = if (loadOnInit) loadOnInitTrueSet else if (constrained) memoryConstrainedSet else loadOnInitFalseSet
set.clear() set.clear()

View File

@ -272,6 +272,7 @@ abstract class AbstractJDBCHashMap<K : Any, V : Any, out T : JDBCHashedTable>(va
override fun containsKey(key: K): Boolean = (get(key) != null) override fun containsKey(key: K): Boolean = (get(key) != null)
// We haven't implemented setValue. We could implement if necessary. // We haven't implemented setValue. We could implement if necessary.
// Make sure to remove the relevant suppressed tests in JDBCHashMapTestSuite.createMapTestSuite if this is implemented.
private class NotReallyMutableEntry<K, V>(key: K, value: V, val seqNo: Int) : AbstractMap.SimpleImmutableEntry<K, V>(key, value), MutableMap.MutableEntry<K, V> { private class NotReallyMutableEntry<K, V>(key: K, value: V, val seqNo: Int) : AbstractMap.SimpleImmutableEntry<K, V>(key, value), MutableMap.MutableEntry<K, V> {
override fun setValue(newValue: V): V { override fun setValue(newValue: V): V {
throw UnsupportedOperationException("Not really mutable. Implement if really required.") throw UnsupportedOperationException("Not really mutable. Implement if really required.")

View File

@ -38,7 +38,7 @@ dependencies {
compile "junit:junit:$junit_version" compile "junit:junit:$junit_version"
// Guava: Google test library (collections test suite) // Guava: Google test library (collections test suite)
compile "com.google.guava:guava-testlib:19.0" compile "com.google.guava:guava-testlib:$guava_version"
// OkHTTP: Simple HTTP library. // OkHTTP: Simple HTTP library.
compile "com.squareup.okhttp3:okhttp:$okhttp_version" compile "com.squareup.okhttp3:okhttp:$okhttp_version"