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 {
// For sharing constants between builds
Properties props = new Properties()
file("publish.properties").withInputStream { props.load(it) }
Properties constants = new Properties()
file("constants.properties").withInputStream { constants.load(it) }
// Our version: bump this on release.
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.
//
@ -22,7 +22,7 @@ buildscript {
ext.slf4j_version = '1.7.24'
ext.log4j_version = '2.7'
ext.bouncycastle_version = '1.56'
ext.guava_version = '19.0'
ext.guava_version = constants.getProperty("guavaVersion")
ext.quickcheck_version = '0.7'
ext.okhttp_version = '3.5.0'
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'
repositories {
@ -5,6 +12,5 @@ repositories {
}
dependencies {
// Cannot use ext.guava_version here :(
compile "com.google.guava:guava:20.0"
compile "com.google.guava:guava:$guava_version"
}

View File

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

View File

@ -3,11 +3,11 @@
buildscript {
// For sharing constants between builds
Properties props = new Properties()
file("../publish.properties").withInputStream { props.load(it) }
Properties constants = new Properties()
file("../constants.properties").withInputStream { constants.load(it) }
// 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 {
mavenLocal()

View File

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

View File

@ -1,5 +1,14 @@
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 net.corda.testing.node.makeTestDataSourceProperties
import org.assertj.core.api.Assertions.assertThat
@ -56,39 +65,43 @@ class JDBCHashMapTestSuite {
}
@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))
.named("test JDBCHashMap with loadOnInit=$loadOnInit")
.withFeatures(
com.google.common.collect.testing.features.CollectionSize.ANY,
com.google.common.collect.testing.features.MapFeature.ALLOWS_ANY_NULL_QUERIES,
com.google.common.collect.testing.features.MapFeature.GENERAL_PURPOSE,
com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER
CollectionSize.ANY,
MapFeature.ALLOWS_ANY_NULL_QUERIES,
MapFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionFeature.KNOWN_ORDER
)
// 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()
@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))
.named("test JDBCHashSet with loadOnInit=$loadOnInit")
.withFeatures(
com.google.common.collect.testing.features.CollectionSize.ANY,
com.google.common.collect.testing.features.SetFeature.GENERAL_PURPOSE,
com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER
CollectionSize.ANY,
SetFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionFeature.KNOWN_ORDER
)
// add/remove/retainAll(null) not supported by Kotlin MutableSet interface
.suppressing(com.google.common.collect.testing.testers.CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference"))
.suppressing(com.google.common.collect.testing.testers.CollectionAddAllTester::class.java.getMethod("testAddAll_nullUnsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionAddTester::class.java.getMethod("testAdd_nullUnsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionCreationTester::class.java.getMethod("testCreateWithNull_unsupported"))
.suppressing(com.google.common.collect.testing.testers.CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(com.google.common.collect.testing.testers.CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceEmptySubject"))
.suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference"))
.suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullUnsupported"))
.suppressing(CollectionAddTester::class.java.getMethod("testAdd_nullUnsupported"))
.suppressing(CollectionCreationTester::class.java.getMethod("testCreateWithNull_unsupported"))
.suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceEmptySubject"))
.suppressing(CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(CollectionRetainAllTester::class.java.getMethod("testRetainAll_nullCollectionReferenceEmptySubject"))
.createTestSuite()
private fun setUpDatabaseTx() {
@ -134,7 +147,7 @@ class JDBCHashMapTestSuite {
/**
* 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> {
val map = if (loadOnInit) loadOnInitTrueMap else if (constrained) memoryConstrainedMap else loadOnInitFalseMap
map.clear()
@ -176,7 +189,7 @@ class JDBCHashMapTestSuite {
/**
* 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> {
val set = if (loadOnInit) loadOnInitTrueSet else if (constrained) memoryConstrainedSet else loadOnInitFalseSet
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)
// 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> {
override fun setValue(newValue: V): V {
throw UnsupportedOperationException("Not really mutable. Implement if really required.")

View File

@ -38,7 +38,7 @@ dependencies {
compile "junit:junit:$junit_version"
// 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.
compile "com.squareup.okhttp3:okhttp:$okhttp_version"