From e5da332a002b0cf8aa8df4e19f377f293d2f4156 Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Fri, 20 Feb 2015 14:44:35 +0100 Subject: [PATCH 01/19] Add a module for finagle bijections. --- .../twitter_finagle/MySqlConversions.scala | 95 +++++++++++++++++++ .../twitter_finagle/MySqlConversionLaws.scala | 89 +++++++++++++++++ project/Build.scala | 6 ++ 3 files changed, 190 insertions(+) create mode 100644 bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala create mode 100644 bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala diff --git a/bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala b/bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala new file mode 100644 index 000000000..1c4e6d399 --- /dev/null +++ b/bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala @@ -0,0 +1,95 @@ +/* +Copyright 2012 Twitter, 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.twitter.bijection.twitter_finagle + +import com.twitter.finagle.exp.mysql._ +import com.twitter.bijection._ +import scala.util.Try +import java.sql.Timestamp + +/** + * Bijections and injections for mapping twitter-finagle's MySql datatypes to Scala datatypes + * other types. + * + * @author George Leontiev + */ + +trait MySqlBijections { + implicit val byte: Bijection[ByteValue, Byte] = new AbstractBijection[ByteValue, Byte] { + def apply(v: ByteValue) = v.b + override def invert(b: Byte) = ByteValue(b) + } + + implicit val short: Bijection[ShortValue, Short] = new AbstractBijection[ShortValue, Short] { + def apply(s: ShortValue) = s.s + override def invert(s: Short) = ShortValue(s) + } + + implicit val int: Bijection[IntValue, Int] = new AbstractBijection[IntValue, Int] { + def apply(i: IntValue) = i.i + override def invert(i: Int) = IntValue(i) + } + + implicit val long: Bijection[LongValue, Long] = new AbstractBijection[LongValue, Long] { + def apply(l: LongValue) = l.l + override def invert(l: Long) = LongValue(l) + } + + implicit val float: Bijection[FloatValue, Float] = new AbstractBijection[FloatValue, Float] { + def apply(f: FloatValue) = f.f + override def invert(f: Float) = FloatValue(f) + } + + implicit val double: Bijection[DoubleValue, Double] = new AbstractBijection[DoubleValue, Double] { + def apply(d: DoubleValue) = d.d + override def invert(d: Double) = DoubleValue(d) + } + + implicit val string: Bijection[StringValue, String] = new AbstractBijection[StringValue, String] { + def apply(s: StringValue) = s.s + override def invert(s: String) = StringValue(s) + } + + implicit val boolean: Bijection[ByteValue, Boolean] = new AbstractBijection[ByteValue, Boolean] { + def apply(t: ByteValue) = t.b == 1 + override def invert(b: Boolean) = ByteValue(if (b) 1 else 0) + } +} + +trait MySqlInjections { + implicit val timestamp: Injection[Timestamp, Value] = + new AbstractInjection[Timestamp, Value] { + private val UTC = java.util.TimeZone.getTimeZone("UTC") + private val timestampValue = new TimestampValue(UTC, UTC) + def apply(t: Timestamp) = timestampValue(t) + override def invert(v: Value) = Try(timestampValue.unapply(v).get) + } + + implicit def nullValue[A]: Injection[NullValue.type, Option[A]] = + new AbstractInjection[NullValue.type, Option[A]] { + def apply(n: NullValue.type) = None + override def invert(n: Option[A]) = Try(n.map(_ => NullValue).get) + } + + implicit def emptyValue[A]: Injection[EmptyValue.type, Option[A]] = + new AbstractInjection[EmptyValue.type, Option[A]] { + def apply(n: EmptyValue.type) = None + override def invert(n: Option[A]) = Try(n.map(_ => EmptyValue).get) + } +} + +object MySqlConversions extends MySqlBijections with MySqlInjections diff --git a/bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala b/bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala new file mode 100644 index 000000000..d6ba58d0f --- /dev/null +++ b/bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala @@ -0,0 +1,89 @@ +/* +Copyright 2012 Twitter, 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.twitter.bijection.twitter_finagle + +import com.twitter.bijection.{ BaseProperties, Bijection } +import org.scalacheck.Arbitrary +import org.scalatest.{ PropSpec, MustMatchers } +import org.scalatest.prop.PropertyChecks +import com.twitter.finagle.exp.mysql._ +import java.sql.Timestamp +import java.util.Date + +import org.scalacheck.Prop.forAll +import org.scalacheck.Gen +import org.scalacheck.Arbitrary +import org.scalacheck.Arbitrary.arbitrary + +class MySqlConversionLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { + import MySqlConversions._ + + implicit val byteValueArb = Arbitrary(arbitrary[Byte].map(ByteValue.apply)) + implicit val shortValueArb = Arbitrary(arbitrary[Short].map(ShortValue.apply)) + implicit val intValueArb = Arbitrary(arbitrary[Int].map(IntValue.apply)) + implicit val longValueArb = Arbitrary(arbitrary[Long].map(LongValue.apply)) + implicit val floatValueArb = Arbitrary(arbitrary[Float].map(FloatValue.apply)) + implicit val doubleValueArb = Arbitrary(arbitrary[Double].map(DoubleValue.apply)) + implicit val stringValueArb = Arbitrary(arbitrary[String].map(StringValue.apply)) + implicit val timestampValueArb = Arbitrary(arbitrary[Date].map(d => new Timestamp(d.getTime))) + implicit val nullValueArb = Arbitrary(Gen.const(NullValue)) + implicit val emptyValueArb = Arbitrary(Gen.const(EmptyValue)) + implicit val valueArb: Arbitrary[Value] = Arbitrary(Gen.oneOf(arbitrary[ByteValue], + arbitrary[NullValue.type], + arbitrary[EmptyValue.type], + arbitrary[ShortValue], + arbitrary[IntValue], + arbitrary[LongValue], + arbitrary[FloatValue], + arbitrary[DoubleValue], + arbitrary[StringValue])) + + property("Byte") { + isBijection[ByteValue, Byte] + } + property("Short") { + isBijection[ShortValue, Short] + } + property("Int") { + isBijection[IntValue, Int] + } + property("Long") { + isBijection[LongValue, Long] + } + property("Float") { + isBijection[FloatValue, Float] + } + property("Double") { + isBijection[DoubleValue, Double] + } + property("String") { + isBijection[StringValue, String] + } + property("Boolean") { + isBijection[ByteValue, Boolean] + } + + property("Timestamp") { + isInjection[Timestamp, Value] + } + property("Empty") { + isInjection[EmptyValue.type, Option[Int]] + } + property("Null") { + isInjection[NullValue.type, Option[String]] + } +} diff --git a/project/Build.scala b/project/Build.scala index 2a3231b0d..c7066322f 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -143,6 +143,7 @@ object BijectionBuild extends Build { bijectionScrooge, bijectionJson, bijectionUtil, + bijectionFinagle, bijectionClojure, bijectionNetty, bijectionAvro, @@ -237,6 +238,11 @@ object BijectionBuild extends Build { libraryDependencies += "com.twitter" %% "util-core" % "6.20.0" ).dependsOn(bijectionCore % "test->test;compile->compile") + lazy val bijectionFinagle = module("finagle").settings( + osgiExportAll("com.twitter.bijection.twitter_finagle"), + libraryDependencies += "com.twitter" %% "finagle-mysql" % "6.24.0" + ).dependsOn(bijectionCore % "test->test;compile->compile") + lazy val bijectionClojure = module("clojure").settings( osgiExportAll("com.twitter.bijection.clojure"), libraryDependencies += "org.clojure" % "clojure" % "1.5.1" From e97acbea8ab76852181f8fc41396d4686c1d5185 Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Sat, 14 Feb 2015 18:18:02 +0100 Subject: [PATCH 02/19] build bijection-scrooge for scala 2.11 --- project/Build.scala | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 2a3231b0d..7a91e351c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -209,22 +209,13 @@ object BijectionBuild extends Build { ) ).dependsOn(bijectionCore % "test->test;compile->compile") - def scroogeBuildDeps(scalaVersion: String): Seq[sbt.ModuleID] = isScala210x(scalaVersion) match { - case false => Seq() - case true => Seq( - "com.twitter" %% "scrooge-serializer" % "3.6.0" - ) - } - lazy val bijectionScrooge = module("scrooge").settings( - skip in compile := !isScala210x(scalaVersion.value), - skip in test := !isScala210x(scalaVersion.value), - publishArtifact := isScala210x(scalaVersion.value), - osgiExportAll("com.twitter.bijection.scrooge"), libraryDependencies ++= Seq( - "org.apache.thrift" % "libthrift" % "0.6.1" exclude("junit", "junit") - ) ++ scroogeBuildDeps(scalaVersion.value) + "org.apache.thrift" % "libthrift" % "0.6.1" exclude("junit", "junit"), + "com.twitter" %% "scrooge-serializer" % "3.17.0", + "com.twitter" %% "finagle-core" % "6.24.0" % "test" + ) ).dependsOn(bijectionCore % "test->test;compile->compile") lazy val bijectionJson = module("json").settings( From ab2aa0644516b096656326d3ff9dbcddc38266c1 Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Fri, 20 Feb 2015 17:15:49 -0800 Subject: [PATCH 03/19] make tests work again --- .../bijection/avro/GenericAvroCodecLaws.scala | 10 +--- .../avro/GenericAvroCodecsSpecification.scala | 2 +- .../avro/SpecificAvroCodecLaws.scala | 8 +-- .../SpecificAvroCodecsSpecification.scala | 2 +- .../bijection/BinaryBijectionLaws.scala | 2 +- .../twitter/bijection/BufferableLaws.scala | 24 +++----- .../twitter/bijection/CheckProperties.scala | 13 +++++ .../twitter/bijection/CollectionLaws.scala | 11 +--- .../twitter/bijection/EnglishIntLaws.scala | 2 +- .../bijection/StringBijectionLaws.scala | 18 ++---- .../bijection/TupleBijectionLaws.scala | 3 +- .../bijection/guava/GuavaBijectionLaws.scala | 26 +++------ .../guava/GuavaBinaryBijectionsLaws.scala | 4 +- .../bijection/hbase/HBaseBijectionsLaws.scala | 5 +- .../hbase/HBaseBijectionsSpecifications.scala | 2 +- .../jodatime/DateBijectionLaws.scala | 2 +- .../bijection/json/JsonInjectionLaws.scala | 10 ++-- .../json4s/Json4sInjectionLaws.scala | 4 +- .../bijection/macros/MacroAnnotations.scala | 2 + .../bijection/macros/MacroPropTests.scala | 57 +++++++++---------- .../protobuf/ProtobufCodecLaws.scala | 11 ++-- .../bijection/scrooge/ScroogeCodecLaws.scala | 4 +- .../bijection/thrift/ThriftCodecLaws.scala | 12 ++-- .../twitter_util/UtilBijectionLaws.scala | 4 +- 24 files changed, 103 insertions(+), 135 deletions(-) create mode 100644 bijection-core/src/test/scala/com/twitter/bijection/CheckProperties.scala diff --git a/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecLaws.scala b/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecLaws.scala index 1985abb6c..cf955d48d 100644 --- a/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecLaws.scala +++ b/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecLaws.scala @@ -13,19 +13,15 @@ limitations under the License. */ package com.twitter.bijection.avro -import com.twitter.bijection.{ BaseProperties, Injection } - -import org.scalatest.PropSpec -import org.scalatest.prop.PropertyChecks - -import org.apache.avro.generic.{ GenericRecord, GenericData } +import com.twitter.bijection.{ BaseProperties, CheckProperties, Injection } import org.apache.avro.Schema +import org.apache.avro.generic.{ GenericData, GenericRecord } /** * @author Muhammad Ashraf * @since 7/5/13 */ -class GenericAvroCodecLaws extends PropSpec with PropertyChecks with BaseProperties { +class GenericAvroCodecLaws extends CheckProperties with BaseProperties { val testSchema = new Schema.Parser().parse("""{ "type":"record", "name":"FiscalRecord", diff --git a/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecsSpecification.scala b/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecsSpecification.scala index 4740e86e3..bc9a839b9 100644 --- a/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecsSpecification.scala +++ b/bijection-avro/src/test/scala/com/twitter/bijection/avro/GenericAvroCodecsSpecification.scala @@ -24,7 +24,7 @@ import org.apache.avro.generic.{ GenericData, GenericRecord } * @author Muhammad Ashraf * @since 7/6/13 */ -object GenericAvroCodecsSpecification extends WordSpec with Matchers with BaseProperties { +class GenericAvroCodecsSpecification extends WordSpec with Matchers with BaseProperties { val testSchema = new Schema.Parser().parse("""{ "type":"record", "name":"FiscalRecord", diff --git a/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecLaws.scala b/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecLaws.scala index 1dbbcea61..1fee8d14a 100644 --- a/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecLaws.scala +++ b/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecLaws.scala @@ -1,16 +1,14 @@ package com.twitter.bijection.avro -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks -import com.twitter.bijection.{ Injection, BaseProperties } -import org.apache.avro.Schema import avro.FiscalRecord +import com.twitter.bijection.{ BaseProperties, CheckProperties, Injection } +import org.apache.avro.Schema /** * @author Muhammad Ashraf * @since 10/5/13 */ -class SpecificAvroCodecLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class SpecificAvroCodecLaws extends CheckProperties with BaseProperties { val testSchema = new Schema.Parser().parse("""{ "type":"record", "name":"FiscalRecord", diff --git a/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecsSpecification.scala b/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecsSpecification.scala index 6b027b568..181310c4c 100644 --- a/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecsSpecification.scala +++ b/bijection-avro/src/test/scala/com/twitter/bijection/avro/SpecificAvroCodecsSpecification.scala @@ -9,7 +9,7 @@ import avro.FiscalRecord * @author Muhammad Ashraf * @since 10/5/13 */ -object SpecificAvroCodecsSpecification extends WordSpec with Matchers with BaseProperties { +class SpecificAvroCodecsSpecification extends WordSpec with Matchers with BaseProperties { val testSchema = new Schema.Parser().parse("""{ "type":"record", "name":"FiscalRecord", diff --git a/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala index 223fc100a..a32d3275c 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala @@ -22,7 +22,7 @@ import org.scalatest.prop.PropertyChecks import org.scalacheck.Prop._ -class BinaryBijectionLaws extends PropSpec with PropertyChecks with MustMatchers +class BinaryBijectionLaws extends CheckProperties with MustMatchers with BaseProperties { implicit val arbBB = arbitraryViaFn[Array[Byte], ByteBuffer] { ByteBuffer.wrap(_) } diff --git a/bijection-core/src/test/scala/com/twitter/bijection/BufferableLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/BufferableLaws.scala index 6b8cf4be0..7b4c4f4c2 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/BufferableLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/BufferableLaws.scala @@ -16,20 +16,9 @@ limitations under the License. package com.twitter.bijection -import java.lang.{ - Short => JShort, - Integer => JInt, - Long => JLong, - Float => JFloat, - Double => JDouble, - Byte => JByte -} - +import java.lang.{ Byte => JByte, Double => JDouble, Float => JFloat, Integer => JInt, Long => JLong, Short => JShort } import java.nio.ByteBuffer -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks - import org.scalacheck.Arbitrary import org.scalacheck.Prop.forAll @@ -51,15 +40,16 @@ trait BaseBufferable { } } -class BufferableLaws extends PropSpec with PropertyChecks with MustMatchers with BaseBufferable { +class BufferableLaws extends CheckProperties with BaseBufferable { + property("Reallocate works properly") { forAll { (bytes: Array[Byte]) => val bb = ByteBuffer.wrap(bytes) bb.position(bytes.size) val newBb = Bufferable.reallocate(bb) - assert(Bufferable.getBytes(bb).toList == Bufferable.getBytes(newBb).toList) - assert(newBb.capacity > bb.capacity) - assert(newBb.position == bb.position) + Bufferable.getBytes(bb).toList == Bufferable.getBytes(newBb).toList && + newBb.capacity > bb.capacity && + newBb.position == bb.position } } @@ -67,7 +57,7 @@ class BufferableLaws extends PropSpec with PropertyChecks with MustMatchers with forAll { (bytes: Array[Byte]) => val bb = ByteBuffer.wrap(bytes) bb.position(bytes.size) - assert(Bufferable.getBytes(bb).toList == bytes.toList) + Bufferable.getBytes(bb).toList == bytes.toList } } diff --git a/bijection-core/src/test/scala/com/twitter/bijection/CheckProperties.scala b/bijection-core/src/test/scala/com/twitter/bijection/CheckProperties.scala new file mode 100644 index 000000000..92cf0d2be --- /dev/null +++ b/bijection-core/src/test/scala/com/twitter/bijection/CheckProperties.scala @@ -0,0 +1,13 @@ +package com.twitter.bijection + +import org.scalatest.PropSpec +import org.scalatest.prop.Checkers + +/** + * @author Mansur Ashraf. + */ +trait CheckProperties extends PropSpec with Checkers { + + def property(testName: scala.Predef.String, testTags: org.scalatest.Tag*)(testFun: org.scalacheck.Prop): scala.Unit = + super.property(testName, testTags: _*) { check { testFun } } +} diff --git a/bijection-core/src/test/scala/com/twitter/bijection/CollectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/CollectionLaws.scala index 4e2e4fef2..eb5c5ad1c 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/CollectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/CollectionLaws.scala @@ -16,16 +16,11 @@ limitations under the License. package com.twitter.bijection -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks - -import org.scalacheck.Gen._ import org.scalacheck.Arbitrary -import org.scalacheck.Prop._ +import org.scalatest.MustMatchers -class CollectionLaws extends PropSpec with PropertyChecks with MustMatchers - with BaseProperties { - import StringArbs._ +class CollectionLaws extends CheckProperties with BaseProperties { + import com.twitter.bijection.StringArbs._ implicit def vectorArb[A](implicit la: Arbitrary[List[A]]) = arbitraryViaFn { (l: List[A]) => Vector(l: _*) } diff --git a/bijection-core/src/test/scala/com/twitter/bijection/EnglishIntLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/EnglishIntLaws.scala index 5ea68e37b..390c0cb59 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/EnglishIntLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/EnglishIntLaws.scala @@ -23,7 +23,7 @@ import org.scalatest.prop.PropertyChecks import Conversion.asMethod // get the .as syntax -class EnglishIntLaws extends PropSpec with PropertyChecks with MustMatchers +class EnglishIntLaws extends CheckProperties with MustMatchers with BaseProperties { var ct = 0 diff --git a/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala index a27ba23a9..5375c246f 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala @@ -16,18 +16,14 @@ limitations under the License. package com.twitter.bijection -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks +import java.net.URL +import java.util.UUID -import org.scalacheck.Gen._ import org.scalacheck.Arbitrary +import org.scalacheck.Gen._ import org.scalacheck.Prop._ -import java.util.UUID -import java.net.URL - object StringArbs extends BaseProperties { - import Rep._ implicit val strByte = arbitraryViaBijection[Byte, String @@ Rep[Byte]] implicit val strShort = arbitraryViaBijection[Short, String @@ Rep[Short]] @@ -37,9 +33,7 @@ object StringArbs extends BaseProperties { implicit val strDouble = arbitraryViaBijection[Double, String @@ Rep[Double]] } -class StringBijectionLaws extends PropSpec with PropertyChecks with MustMatchers - with BaseProperties { - import StringArbs._ +class StringBijectionLaws extends CheckProperties with BaseProperties { property("round trips string -> Array[String]") { isLooseInjection[String, Array[Byte]] @@ -86,9 +80,7 @@ class StringBijectionLaws extends PropSpec with PropertyChecks with MustMatchers forAll { (sep: String, xs: List[String]) => val sjBij = StringJoinBijection(sep) val iter = xs.toIterable - whenever(!iter.exists(_.contains(sep))) { - assert(iter == rt(iter)(sjBij)) - } + (!iter.exists(_.contains(sep))) ==> (iter == rt(iter)(sjBij)) } } diff --git a/bijection-core/src/test/scala/com/twitter/bijection/TupleBijectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/TupleBijectionLaws.scala index e729368de..f8344d278 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/TupleBijectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/TupleBijectionLaws.scala @@ -28,8 +28,7 @@ import java.lang.{ import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks -class TupleBijectionLaws extends PropSpec with PropertyChecks with MustMatchers - with BaseProperties { +class TupleBijectionLaws extends CheckProperties with BaseProperties { import StringArbs._ property("round trips (Int,Long) -> (String,String)") { diff --git a/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBijectionLaws.scala b/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBijectionLaws.scala index a3819e99f..52eeca659 100644 --- a/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBijectionLaws.scala +++ b/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBijectionLaws.scala @@ -16,24 +16,16 @@ package com.twitter.bijection.guava -import com.google.common.base.Optional -import com.google.common.base.{ Function => GFn, Predicate, Supplier } -import com.twitter.bijection.{ @@, BaseProperties, Bijection, Rep, Conversion } -import com.twitter.bijection.Rep._ +import java.lang.{ Long => JLong } +import com.google.common.base.{ Function => GFn, Optional, Predicate, Supplier } +import com.twitter.bijection.Conversion.asMethod +import com.twitter.bijection._ import org.scalacheck.Arbitrary -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks - import org.scalacheck.Prop.forAll -import java.lang.{ Long => JLong } - -import Bijection.connect -import Conversion.asMethod - -class GuavaBijectionLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { - import GuavaBijections._ +class GuavaBijectionLaws extends CheckProperties with BaseProperties { + import com.twitter.bijection.guava.GuavaBijections._ implicit def arbOptional[T: Arbitrary] = arbitraryViaFn[T, Optional[T]] { Optional.of(_) } @@ -48,7 +40,7 @@ class GuavaBijectionLaws extends PropSpec with PropertyChecks with MustMatchers def roundTripsFn[A, B](fn: A => B)(implicit arb: Arbitrary[A], bij: Bijection[A => B, GFn[A, B]], eqb: Equiv[B]) = { val rtFn = bij(fn) - forAll { a: A => assert(eqb.equiv(fn(a), rtFn.apply(a))) } + forAll { a: A => eqb.equiv(fn(a), rtFn.apply(a)) } } property("round trips Int => Long -> GuavaFn[Int, Long]") { @@ -58,14 +50,14 @@ class GuavaBijectionLaws extends PropSpec with PropertyChecks with MustMatchers property("round trips () => Long -> Supplier[JLong]") { forAll { l: Long => val fn = { () => l } - assert(fn() == fn.as[Supplier[JLong]].get.as[Long]) + fn() == fn.as[Supplier[JLong]].get.as[Long] } } property("round trips Long => Boolean -> Predicate[JLong]") { forAll { l: Long => val isEven = { l: Long => l % 2 == 0 } - assert(isEven(l) == isEven.as[Predicate[JLong]].apply(l.as[JLong])) + isEven(l) == isEven.as[Predicate[JLong]].apply(l.as[JLong]) } } } diff --git a/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBinaryBijectionsLaws.scala b/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBinaryBijectionsLaws.scala index 6944ce85b..d90167386 100644 --- a/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBinaryBijectionsLaws.scala +++ b/bijection-guava/src/test/scala/com/twitter/bijection/guava/GuavaBinaryBijectionsLaws.scala @@ -14,7 +14,7 @@ package com.twitter.bijection.guava -import com.twitter.bijection.BaseProperties +import com.twitter.bijection.{ CheckProperties, BaseProperties } import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks @@ -26,7 +26,7 @@ import com.twitter.bijection.guava.GuavaBinaryBijections.Base64URLString * @author Muhammad Ashraf * @since 7/7/13 */ -class GuavaBinaryBijectionsLaws extends PropSpec with PropertyChecks with MustMatchers +class GuavaBinaryBijectionsLaws extends CheckProperties with BaseProperties { property("rts Array[Byte] -> Base64String") { diff --git a/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsLaws.scala b/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsLaws.scala index 79b772579..a1f7c8a13 100644 --- a/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsLaws.scala +++ b/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsLaws.scala @@ -3,7 +3,7 @@ package com.twitter.bijection.hbase import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks -import com.twitter.bijection.BaseProperties +import com.twitter.bijection.{ CheckProperties, BaseProperties } import HBaseBijections._ import org.apache.hadoop.hbase.io.ImmutableBytesWritable import org.apache.hadoop.hbase.util.Bytes @@ -12,8 +12,7 @@ import org.apache.hadoop.hbase.util.Bytes * @author Muhammad Ashraf * @since 7/10/13 */ -class HBaseBijectionsLaws extends PropSpec with PropertyChecks with MustMatchers - with BaseProperties { +class HBaseBijectionsLaws extends CheckProperties with BaseProperties { property("String <=> StringBytes") { isInjective[String, StringBytes] diff --git a/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsSpecifications.scala b/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsSpecifications.scala index 083ed1632..93e2ed38c 100644 --- a/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsSpecifications.scala +++ b/bijection-hbase/src/test/scala/com/twitter/bijection/hbase/HBaseBijectionsSpecifications.scala @@ -23,7 +23,7 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable * @author Muhammad Ashraf * @since 7/10/13 */ -object HBaseBijectionsSpecifications extends WordSpec with Matchers with BaseProperties { +class HBaseBijectionsSpecifications extends WordSpec with Matchers with BaseProperties { "HBaseBijections" should { "round trip String -> Array[Byte]" in { diff --git a/bijection-jodatime/src/test/scala/com/twitter/bijection/jodatime/DateBijectionLaws.scala b/bijection-jodatime/src/test/scala/com/twitter/bijection/jodatime/DateBijectionLaws.scala index 66b22508f..050cc4e89 100644 --- a/bijection-jodatime/src/test/scala/com/twitter/bijection/jodatime/DateBijectionLaws.scala +++ b/bijection-jodatime/src/test/scala/com/twitter/bijection/jodatime/DateBijectionLaws.scala @@ -11,7 +11,7 @@ import java.util.Date import org.joda.time.{ DateTime, LocalDate, LocalTime, YearMonth, MonthDay } import com.twitter.bijection._ -class DateBijectionsLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties with DateBijections with DateInjections { +class DateBijectionsLaws extends CheckProperties with BaseProperties with DateBijections with DateInjections { import Rep._ diff --git a/bijection-json/src/test/scala/com/twitter/bijection/json/JsonInjectionLaws.scala b/bijection-json/src/test/scala/com/twitter/bijection/json/JsonInjectionLaws.scala index d46c3d91a..178a27eaf 100644 --- a/bijection-json/src/test/scala/com/twitter/bijection/json/JsonInjectionLaws.scala +++ b/bijection-json/src/test/scala/com/twitter/bijection/json/JsonInjectionLaws.scala @@ -18,7 +18,7 @@ package com.twitter.bijection.json import com.twitter.bijection.Conversion.asMethod -import com.twitter.bijection.{ BaseProperties, Bijection, Injection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection, Injection } import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks @@ -29,7 +29,7 @@ import org.codehaus.jackson.JsonNode import com.twitter.bijection.json.JsonNodeInjection.{ fromJsonNode, toJsonNode } import scala.util.Try -class JsonInjectionLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class JsonInjectionLaws extends CheckProperties with BaseProperties { // Needed from some recursive injections (like tuples) import JsonNodeInjection._ @@ -152,12 +152,12 @@ class JsonInjectionLaws extends PropSpec with PropertyChecks with MustMatchers w val jsonMixed = mixedMap.as[UnparsedJson] - jsonMixed.as[Try[Map[String, JsonNode]]].get.foreach { kup: (String, JsonNode) => + jsonMixed.as[Try[Map[String, JsonNode]]].get.forall{ kup: (String, JsonNode) => val (k, up) = kup if (k.endsWith("i")) { - assert(fromJsonNode[Int](up).get == fromJsonNode[Int](mixedMap(k)).get) + fromJsonNode[Int](up).get == fromJsonNode[Int](mixedMap(k)).get } else { - assert(fromJsonNode[List[String]](up).get == fromJsonNode[List[String]](mixedMap(k)).get) + fromJsonNode[List[String]](up).get == fromJsonNode[List[String]](mixedMap(k)).get } } } diff --git a/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala b/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala index f925c7f3b..297fcb3c0 100644 --- a/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala +++ b/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala @@ -16,7 +16,7 @@ package com.twitter.bijection.json4s import org.scalatest.PropSpec import org.scalatest.prop.PropertyChecks -import com.twitter.bijection.{ Injection, BaseProperties } +import com.twitter.bijection.{ CheckProperties, Injection, BaseProperties } import org.json4s.JsonAST._ import org.json4s.JsonAST.JString @@ -28,7 +28,7 @@ import scala.reflect.ClassTag * @author Mansur Ashraf * @since 1/10/14 */ -class Json4sInjectionLaws extends PropSpec with PropertyChecks +class Json4sInjectionLaws extends CheckProperties with BaseProperties { case class Twit(name: String, id: Int, id_str: String, indices: List[Int], screen_name: String) diff --git a/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala b/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala index b0cdf6260..e6f3f0d28 100644 --- a/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala +++ b/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala @@ -16,3 +16,5 @@ trait IsCaseClass[T] * This is a tag trait to allow macros to signal, in a uniform way, that a piece of code was generated. */ trait MacroGenerated + +trait Blah \ No newline at end of file diff --git a/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala b/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala index e75dbaed0..550ffd9e7 100644 --- a/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala +++ b/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala @@ -1,18 +1,15 @@ package com.twitter.bijection.macros -import scala.util.Success - +import com.twitter.bijection._ import org.scalacheck.Arbitrary +import org.scalatest.prop.{ Checkers, PropertyChecks } import org.scalatest.{ Matchers, PropSpec } -import org.scalatest.prop.PropertyChecks -import com.twitter.bijection._ -import com.twitter.bijection.macros._ -import com.twitter.chill.Externalizer +import scala.util.Success +import org.scalacheck.Prop.forAll -trait MacroPropTests extends PropSpec with PropertyChecks with Matchers with MacroTestHelper { - import MacroImplicits._ - import MacroCaseClasses._ +trait MacroPropTests extends PropSpec with Checkers with Matchers with MacroTestHelper { + import com.twitter.bijection.macros.MacroCaseClasses._ //TODO make a macro to autogenerate arbitraries for case classes implicit def arbA: Arbitrary[SampleClassA] = Arbitrary[SampleClassA] { @@ -42,21 +39,20 @@ trait MacroPropTests extends PropSpec with PropertyChecks with Matchers with Mac } trait CaseClassToTuplePropTests extends MacroPropTests { - def shouldRoundTrip[A, B <: Product](t: A)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) { - bij shouldBe a[MacroGenerated] - t shouldBe bij.invert(bij(t)) + def shouldRoundTrip[A, B <: Product](t: A)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) = { + bij === a[MacroGenerated] && + t === bij.invert(bij(t)) } - def shouldRoundTrip[A, B <: Product](t: B)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) { - bij shouldBe a[MacroGenerated] - t shouldBe bij(bij.invert(t)) + def shouldRoundTrip[A, B <: Product](t: B)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) = { + bij === a[MacroGenerated] && + t === bij(bij.invert(t)) } } class CaseClassToTupleRecurisvelyAppliedPropTests extends CaseClassToTuplePropTests { - import MacroImplicits._ - import MacroImplicits._ - import MacroCaseClasses._ + import com.twitter.bijection.macros.MacroCaseClasses._ + import com.twitter.bijection.macros.MacroImplicits._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA, Atup](v) } @@ -84,8 +80,8 @@ class CaseClassToTupleRecurisvelyAppliedPropTests extends CaseClassToTuplePropTe } class CaseClassToTupleNonRecursivelyAppliedPropTests extends CaseClassToTuplePropTests { - import MacroImplicits._ - import MacroCaseClasses._ + import com.twitter.bijection.macros.MacroCaseClasses._ + import com.twitter.bijection.macros.MacroImplicits._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA, Atupnr](v) } @@ -113,22 +109,21 @@ class CaseClassToTupleNonRecursivelyAppliedPropTests extends CaseClassToTuplePro } trait CaseClassToMapPropTests extends MacroPropTests { - def shouldRoundTrip[A](t: A)(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) { - inj shouldBe a[MacroGenerated] - Success(t) shouldEqual inj.invert(inj(t)) + def shouldRoundTrip[A](t: A)(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) = { + inj === a[MacroGenerated] && + Success(t) === inj.invert(inj(t)) } - def shouldRoundTrip[A](t: Map[String, Any])(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) { - inj shouldBe a[MacroGenerated] + def shouldRoundTrip[A](t: Map[String, Any])(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) = { inj.invert(t).get - Success(t) shouldEqual inj.invert(t).map { inj(_) } + inj === a[MacroGenerated] && + Success(t) === inj.invert(t).map { inj(_) } } } class CaseClassToMapRecursivelyAppliedPropTests extends CaseClassToMapPropTests { - import MacroImplicits._ - import MacroImplicits._ - import MacroCaseClasses._ + import com.twitter.bijection.macros.MacroCaseClasses._ + import com.twitter.bijection.macros.MacroImplicits._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA](v) } @@ -179,8 +174,8 @@ class CaseClassToMapRecursivelyAppliedPropTests extends CaseClassToMapPropTests } class CaseClassToMapNonRecursivelyAppliedPropTests extends CaseClassToMapPropTests { - import MacroImplicits._ - import MacroCaseClasses._ + import com.twitter.bijection.macros.MacroCaseClasses._ + import com.twitter.bijection.macros.MacroImplicits._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA](v) } diff --git a/bijection-protobuf/src/test/scala/com/twitter/bijection/protobuf/ProtobufCodecLaws.scala b/bijection-protobuf/src/test/scala/com/twitter/bijection/protobuf/ProtobufCodecLaws.scala index e385be9b1..d55b65775 100644 --- a/bijection-protobuf/src/test/scala/com/twitter/bijection/protobuf/ProtobufCodecLaws.scala +++ b/bijection-protobuf/src/test/scala/com/twitter/bijection/protobuf/ProtobufCodecLaws.scala @@ -16,7 +16,7 @@ package com.twitter.bijection.protobuf -import com.twitter.bijection.{ BaseProperties, Bijection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection } import com.twitter.bijection.protobuf.TestMessages.{ FatigueCount, Gender } import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks @@ -24,7 +24,7 @@ import org.scalatest.prop.PropertyChecks import org.scalacheck.Arbitrary import org.scalatest._ -class ProtobufCodecLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class ProtobufCodecLaws extends CheckProperties with BaseProperties { def buildFatigueCount(tuple: (Long, Long, Int)) = FatigueCount.newBuilder() .setTargetId(tuple._1) @@ -45,11 +45,10 @@ class ProtobufEnumTest extends WordSpec with Matchers with BaseProperties { "ProtocolMessageEnum should roundtrip through ProtobufCodec" in { implicit val b = ProtobufEnumCodec[Gender] val male = Gender.valueOf(0) - assert(male == rt(male)) - val female = Gender.valueOf(1) - assert(female == rt(female)) - assert(b.invert(2).isFailure == true) + male == rt(male) && + female == rt(female) && + b.invert(2).isFailure } } diff --git a/bijection-scrooge/src/test/scala/com/twitter/bijection/scrooge/ScroogeCodecLaws.scala b/bijection-scrooge/src/test/scala/com/twitter/bijection/scrooge/ScroogeCodecLaws.scala index 84f66bf59..ed803f540 100644 --- a/bijection-scrooge/src/test/scala/com/twitter/bijection/scrooge/ScroogeCodecLaws.scala +++ b/bijection-scrooge/src/test/scala/com/twitter/bijection/scrooge/ScroogeCodecLaws.scala @@ -16,14 +16,14 @@ package com.twitter.bijection.scrooge -import com.twitter.bijection.{ BaseProperties, Bijection, Injection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection, Injection } import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks import org.scalacheck.Arbitrary -class ScroogeCodecLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class ScroogeCodecLaws extends CheckProperties with BaseProperties { def buildScrooge(i: (Int, String)) = TestStruct(i._1, Some(i._2)) diff --git a/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala b/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala index 9f3ad783e..7a40d006d 100644 --- a/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala +++ b/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala @@ -16,14 +16,14 @@ package com.twitter.bijection.thrift -import com.twitter.bijection.{ BaseProperties, Bijection, Injection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection, Injection } import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks import org.scalacheck.Arbitrary import org.scalatest._ -class ThriftCodecLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class ThriftCodecLaws extends CheckProperties with BaseProperties { def buildThrift(i: (Int, String)) = new TestThriftStructure().setANumber(i._1).setAString(i._2) @@ -52,11 +52,9 @@ class TEnumTest extends WordSpec with Matchers with BaseProperties { "TEnum should roundtrip through TEnumCodec" in { implicit val b = TEnumCodec[Gender] val male = Gender.findByValue(0) - assert(male == rt(male)) - val female = Gender.findByValue(1) - assert(female == rt(female)) - - assert(b.invert(2).isFailure == true) + male == rt(male) && + female == rt(female) && + b.invert(2).isFailure } } diff --git a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala index 63f8ed52a..87d65b1df 100644 --- a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala +++ b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala @@ -16,7 +16,7 @@ limitations under the License. package com.twitter.bijection.twitter_util -import com.twitter.bijection.{ BaseProperties, Bijection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection } import com.twitter.util.{ Future => TwitterFuture, Try => TwitterTry, Await => TwitterAwait } import java.lang.{ Integer => JInt, Long => JLong } import org.scalacheck.Arbitrary @@ -30,7 +30,7 @@ import scala.util.{ Try => ScalaTry } import scala.concurrent.future import scala.concurrent.ExecutionContext.Implicits.global -class UtilBijectionLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class UtilBijectionLaws extends CheckProperties with BaseProperties { import UtilBijections._ protected def toOption[T](f: TwitterFuture[T]): Option[T] = TwitterTry(TwitterAwait.result(f)).toOption From 1c7e876447bfe1b523caacf9be18f2c6a7cde3ac Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Fri, 20 Feb 2015 17:18:13 -0800 Subject: [PATCH 04/19] removed --- .../scala/com/twitter/bijection/macros/MacroAnnotations.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala b/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala index e6f3f0d28..78bf05c11 100644 --- a/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala +++ b/bijection-macros/src/main/scala/com/twitter/bijection/macros/MacroAnnotations.scala @@ -17,4 +17,3 @@ trait IsCaseClass[T] */ trait MacroGenerated -trait Blah \ No newline at end of file From 753cff5744aead46e8d8f54d56c356fe8b46f9b9 Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Fri, 20 Feb 2015 17:23:28 -0800 Subject: [PATCH 05/19] reverted changes to macro tests --- .../bijection/macros/MacroPropTests.scala | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala b/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala index 550ffd9e7..e75dbaed0 100644 --- a/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala +++ b/bijection-macros/src/test/scala/com/twitter/bijection/macros/MacroPropTests.scala @@ -1,15 +1,18 @@ package com.twitter.bijection.macros -import com.twitter.bijection._ +import scala.util.Success + import org.scalacheck.Arbitrary -import org.scalatest.prop.{ Checkers, PropertyChecks } import org.scalatest.{ Matchers, PropSpec } +import org.scalatest.prop.PropertyChecks -import scala.util.Success -import org.scalacheck.Prop.forAll +import com.twitter.bijection._ +import com.twitter.bijection.macros._ +import com.twitter.chill.Externalizer -trait MacroPropTests extends PropSpec with Checkers with Matchers with MacroTestHelper { - import com.twitter.bijection.macros.MacroCaseClasses._ +trait MacroPropTests extends PropSpec with PropertyChecks with Matchers with MacroTestHelper { + import MacroImplicits._ + import MacroCaseClasses._ //TODO make a macro to autogenerate arbitraries for case classes implicit def arbA: Arbitrary[SampleClassA] = Arbitrary[SampleClassA] { @@ -39,20 +42,21 @@ trait MacroPropTests extends PropSpec with Checkers with Matchers with MacroTest } trait CaseClassToTuplePropTests extends MacroPropTests { - def shouldRoundTrip[A, B <: Product](t: A)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) = { - bij === a[MacroGenerated] && - t === bij.invert(bij(t)) + def shouldRoundTrip[A, B <: Product](t: A)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) { + bij shouldBe a[MacroGenerated] + t shouldBe bij.invert(bij(t)) } - def shouldRoundTrip[A, B <: Product](t: B)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) = { - bij === a[MacroGenerated] && - t === bij(bij.invert(t)) + def shouldRoundTrip[A, B <: Product](t: B)(implicit proof: IsCaseClass[A], bij: Bijection[A, B]) { + bij shouldBe a[MacroGenerated] + t shouldBe bij(bij.invert(t)) } } class CaseClassToTupleRecurisvelyAppliedPropTests extends CaseClassToTuplePropTests { - import com.twitter.bijection.macros.MacroCaseClasses._ - import com.twitter.bijection.macros.MacroImplicits._ + import MacroImplicits._ + import MacroImplicits._ + import MacroCaseClasses._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA, Atup](v) } @@ -80,8 +84,8 @@ class CaseClassToTupleRecurisvelyAppliedPropTests extends CaseClassToTuplePropTe } class CaseClassToTupleNonRecursivelyAppliedPropTests extends CaseClassToTuplePropTests { - import com.twitter.bijection.macros.MacroCaseClasses._ - import com.twitter.bijection.macros.MacroImplicits._ + import MacroImplicits._ + import MacroCaseClasses._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA, Atupnr](v) } @@ -109,21 +113,22 @@ class CaseClassToTupleNonRecursivelyAppliedPropTests extends CaseClassToTuplePro } trait CaseClassToMapPropTests extends MacroPropTests { - def shouldRoundTrip[A](t: A)(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) = { - inj === a[MacroGenerated] && - Success(t) === inj.invert(inj(t)) + def shouldRoundTrip[A](t: A)(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) { + inj shouldBe a[MacroGenerated] + Success(t) shouldEqual inj.invert(inj(t)) } - def shouldRoundTrip[A](t: Map[String, Any])(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) = { + def shouldRoundTrip[A](t: Map[String, Any])(implicit proof: IsCaseClass[A], inj: Injection[A, Map[String, Any]]) { + inj shouldBe a[MacroGenerated] inj.invert(t).get - inj === a[MacroGenerated] && - Success(t) === inj.invert(t).map { inj(_) } + Success(t) shouldEqual inj.invert(t).map { inj(_) } } } class CaseClassToMapRecursivelyAppliedPropTests extends CaseClassToMapPropTests { - import com.twitter.bijection.macros.MacroCaseClasses._ - import com.twitter.bijection.macros.MacroImplicits._ + import MacroImplicits._ + import MacroImplicits._ + import MacroCaseClasses._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA](v) } @@ -174,8 +179,8 @@ class CaseClassToMapRecursivelyAppliedPropTests extends CaseClassToMapPropTests } class CaseClassToMapNonRecursivelyAppliedPropTests extends CaseClassToMapPropTests { - import com.twitter.bijection.macros.MacroCaseClasses._ - import com.twitter.bijection.macros.MacroImplicits._ + import MacroImplicits._ + import MacroCaseClasses._ property("case class A(Int, String) should round trip") { forAll { v: SampleClassA => shouldRoundTrip[SampleClassA](v) } From d5db88b7745a064b19289d60b6916ea0a34ad45b Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Mon, 23 Feb 2015 11:05:47 -0800 Subject: [PATCH 06/19] fixed json4s tests --- .../json4s/Json4sInjectionLaws.scala | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala b/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala index 297fcb3c0..fe098f7b9 100644 --- a/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala +++ b/bijection-json4s/src/test/scala/com/twitter/bijection/json4s/Json4sInjectionLaws.scala @@ -14,15 +14,11 @@ package com.twitter.bijection.json4s -import org.scalatest.PropSpec -import org.scalatest.prop.PropertyChecks -import com.twitter.bijection.{ CheckProperties, Injection, BaseProperties } +import com.twitter.bijection.{ BaseProperties, CheckProperties, Injection } +import org.json4s.JsonAST.{ JString, _ } -import org.json4s.JsonAST._ -import org.json4s.JsonAST.JString - -import scala.reflect.runtime.universe.TypeTag import scala.reflect.ClassTag +import scala.reflect.runtime.universe.TypeTag /** * @author Mansur Ashraf @@ -30,7 +26,6 @@ import scala.reflect.ClassTag */ class Json4sInjectionLaws extends CheckProperties with BaseProperties { - case class Twit(name: String, id: Int, id_str: String, indices: List[Int], screen_name: String) def createTwit(i: (String, Int, String, List[Int], String)): Twit = Twit(i._1, i._2, i._3, i._4, i._5) @@ -56,15 +51,17 @@ class Json4sInjectionLaws extends CheckProperties def roundTripJValueToString(implicit inj: Injection[JValue, String]) = isLooseInjection[JValue, String] property("round trip Case Class to Json") { - import Json4sInjections.caseClass2Json + import com.twitter.bijection.json4s.Json4sInjections.caseClass2Json roundTripCaseClassToJson } property("round trip Case Class to JValue") { - import Json4sInjections.caseClass2JValue + import com.twitter.bijection.json4s.Json4sInjections.caseClass2JValue roundTripCaseClassToJValue } property("round trip JValue to String") { - import Json4sInjections.jvalue2Json + import com.twitter.bijection.json4s.Json4sInjections.jvalue2Json roundTripJValueToString } } + +case class Twit(name: String, id: Int, id_str: String, indices: List[Int], screen_name: String) From 547585aa47392764d88c32da48054105d7f50abb Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Mon, 23 Feb 2015 20:24:27 +0100 Subject: [PATCH 07/19] Address the review. --- .../bijection/finagle_mysql}/MySqlConversions.scala | 11 +++++------ .../finagle_mysql}/MySqlConversionLaws.scala | 4 ++-- project/Build.scala | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) rename {bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle => bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql}/MySqlConversions.scala (89%) rename {bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle => bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql}/MySqlConversionLaws.scala (97%) diff --git a/bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala b/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala similarity index 89% rename from bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala rename to bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala index 1c4e6d399..81c64aeb6 100644 --- a/bijection-finagle/src/main/scala/com/twitter/bijection/twitter_finagle/MySqlConversions.scala +++ b/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala @@ -1,5 +1,5 @@ /* -Copyright 2012 Twitter, Inc. +Copyright 2015 Twitter, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,11 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.twitter.bijection.twitter_finagle +package com.twitter.bijection.finagle_mysql import com.twitter.finagle.exp.mysql._ import com.twitter.bijection._ -import scala.util.Try import java.sql.Timestamp /** @@ -76,19 +75,19 @@ trait MySqlInjections { private val UTC = java.util.TimeZone.getTimeZone("UTC") private val timestampValue = new TimestampValue(UTC, UTC) def apply(t: Timestamp) = timestampValue(t) - override def invert(v: Value) = Try(timestampValue.unapply(v).get) + override def invert(v: Value) = Inversion.attempt(v) { v => timestampValue.unapply(v).get } } implicit def nullValue[A]: Injection[NullValue.type, Option[A]] = new AbstractInjection[NullValue.type, Option[A]] { def apply(n: NullValue.type) = None - override def invert(n: Option[A]) = Try(n.map(_ => NullValue).get) + override def invert(n: Option[A]) = Inversion.attempt(n){ n => n.map(_ => NullValue).get } } implicit def emptyValue[A]: Injection[EmptyValue.type, Option[A]] = new AbstractInjection[EmptyValue.type, Option[A]] { def apply(n: EmptyValue.type) = None - override def invert(n: Option[A]) = Try(n.map(_ => EmptyValue).get) + override def invert(n: Option[A]) = Inversion.attempt(n){ n => n.map(_ => EmptyValue).get } } } diff --git a/bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala similarity index 97% rename from bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala rename to bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala index d6ba58d0f..76631b8e3 100644 --- a/bijection-finagle/src/test/scala/com/twitter/bijection/twitter_finagle/MySqlConversionLaws.scala +++ b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala @@ -1,5 +1,5 @@ /* -Copyright 2012 Twitter, Inc. +Copyright 2015 Twitter, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.twitter.bijection.twitter_finagle +package com.twitter.bijection.finagle_mysql import com.twitter.bijection.{ BaseProperties, Bijection } import org.scalacheck.Arbitrary diff --git a/project/Build.scala b/project/Build.scala index c7066322f..2b8690185 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -143,7 +143,7 @@ object BijectionBuild extends Build { bijectionScrooge, bijectionJson, bijectionUtil, - bijectionFinagle, + bijectionFinagleMySql, bijectionClojure, bijectionNetty, bijectionAvro, @@ -238,8 +238,8 @@ object BijectionBuild extends Build { libraryDependencies += "com.twitter" %% "util-core" % "6.20.0" ).dependsOn(bijectionCore % "test->test;compile->compile") - lazy val bijectionFinagle = module("finagle").settings( - osgiExportAll("com.twitter.bijection.twitter_finagle"), + lazy val bijectionFinagleMySql = module("finagle-mysql").settings( + osgiExportAll("com.twitter.bijection.finagle_mysql"), libraryDependencies += "com.twitter" %% "finagle-mysql" % "6.24.0" ).dependsOn(bijectionCore % "test->test;compile->compile") From 1b6fa1a56f69108056c361ac7a192356c0b78215 Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Mon, 23 Feb 2015 12:25:09 -0800 Subject: [PATCH 08/19] switched to new testing style --- .../twitter/bijection/finagle_mysql/MySqlConversionLaws.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala index 76631b8e3..7328abd9d 100644 --- a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala +++ b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala @@ -16,7 +16,7 @@ limitations under the License. package com.twitter.bijection.finagle_mysql -import com.twitter.bijection.{ BaseProperties, Bijection } +import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection } import org.scalacheck.Arbitrary import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks From 2950aa1b1438984ef0b43c2efd2853c55156e21b Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Mon, 23 Feb 2015 14:02:50 -0800 Subject: [PATCH 09/19] fixed url tests --- .../twitter/bijection/StringBijectionLaws.scala | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala index 5375c246f..095e9e7f4 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/StringBijectionLaws.scala @@ -23,6 +23,8 @@ import org.scalacheck.Arbitrary import org.scalacheck.Gen._ import org.scalacheck.Prop._ +import scala.util.Try + object StringArbs extends BaseProperties { implicit val strByte = arbitraryViaBijection[Byte, String @@ Rep[Byte]] @@ -59,17 +61,10 @@ class StringBijectionLaws extends CheckProperties with BaseProperties { // isBijection[UUID, String @@ Rep[UUID]]() // } - def toUrl(s: String): Option[URL] = - try { Some(new URL("http://" + s + ".com")) } - catch { case _: Throwable => None } + def toUrl(s: String): Try[URL] = Try(new URL("http://" + s + ".com")) - implicit val urlArb = Arbitrary { - implicitly[Arbitrary[String]] - .arbitrary - .map { toUrl(_) } - .filter { _.isDefined } - .map { _.get } - } + implicit val urlArb: Arbitrary[URL] = + Arbitrary { Arbitrary.arbitrary[String] map (toUrl(_)) suchThat (_.isSuccess) map (_.get) } // This is trivially a bijection if it injective property("URL -> String") { From 4cc105ebae513699bb35930451f44d15e12fbaab Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Mon, 23 Feb 2015 15:51:01 -0800 Subject: [PATCH 10/19] added a more restrictive thrift json test --- .../twitter/bijection/thrift/ThriftCodecLaws.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala b/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala index 7a40d006d..2403aa57a 100644 --- a/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala +++ b/bijection-thrift/src/test/scala/com/twitter/bijection/thrift/ThriftCodecLaws.scala @@ -20,14 +20,21 @@ import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection, Injec import org.scalatest.{ PropSpec, MustMatchers } import org.scalatest.prop.PropertyChecks -import org.scalacheck.Arbitrary +import org.scalacheck.{ Gen, Arbitrary } import org.scalatest._ class ThriftCodecLaws extends CheckProperties with BaseProperties { def buildThrift(i: (Int, String)) = new TestThriftStructure().setANumber(i._1).setAString(i._2) - implicit val testThrift = arbitraryViaFn { is: (Int, String) => buildThrift(is) } + implicit val testThrift: Arbitrary[TestThriftStructure] = Arbitrary { + for { + l <- Gen.oneOf('a' to 'z') + u <- Gen.oneOf('A' to 'Z') + s <- Gen.listOf(Gen.oneOf(l, u, Gen.numChar)).map(_.mkString) + i <- Arbitrary.arbitrary[Int] + } yield buildThrift(i, s) + } // Code generator for thrift instances. def roundTripsThrift(implicit injection: Injection[TestThriftStructure, Array[Byte]]) = { From 98f0cb61bb0ea6ca45414ab64c5ab61431a84439 Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Thu, 26 Feb 2015 17:48:17 +0100 Subject: [PATCH 11/19] Fix tests for finagle-mysql subproject. --- .../finagle_mysql/MySqlConversions.scala | 30 +++++++++--- .../finagle_mysql/MySqlConversionLaws.scala | 49 ++++++++++++------- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala b/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala index 81c64aeb6..506ba3a24 100644 --- a/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala +++ b/bijection-finagle-mysql/src/main/scala/com/twitter/bijection/finagle_mysql/MySqlConversions.scala @@ -19,6 +19,7 @@ package com.twitter.bijection.finagle_mysql import com.twitter.finagle.exp.mysql._ import com.twitter.bijection._ import java.sql.Timestamp +import scala.util.{ Try, Success, Failure } /** * Bijections and injections for mapping twitter-finagle's MySql datatypes to Scala datatypes @@ -62,32 +63,45 @@ trait MySqlBijections { def apply(s: StringValue) = s.s override def invert(s: String) = StringValue(s) } - - implicit val boolean: Bijection[ByteValue, Boolean] = new AbstractBijection[ByteValue, Boolean] { - def apply(t: ByteValue) = t.b == 1 - override def invert(b: Boolean) = ByteValue(if (b) 1 else 0) - } } trait MySqlInjections { + implicit val boolean: Injection[Boolean, ByteValue] = new AbstractInjection[Boolean, ByteValue] { + def apply(b: Boolean) = ByteValue(if (b) 1 else 0) + override def invert(t: ByteValue) = t match { + case ByteValue(0) => Success(false) + case ByteValue(1) => Success(true) + case ByteValue(x) => Failure(new RuntimeException(s"Cannot cast ByteValue holding $x to Boolean")) + } + } + implicit val timestamp: Injection[Timestamp, Value] = new AbstractInjection[Timestamp, Value] { private val UTC = java.util.TimeZone.getTimeZone("UTC") private val timestampValue = new TimestampValue(UTC, UTC) def apply(t: Timestamp) = timestampValue(t) - override def invert(v: Value) = Inversion.attempt(v) { v => timestampValue.unapply(v).get } + override def invert(v: Value) = + Inversion.attempt(v) { v => + timestampValue.unapply(v).get + } } implicit def nullValue[A]: Injection[NullValue.type, Option[A]] = new AbstractInjection[NullValue.type, Option[A]] { def apply(n: NullValue.type) = None - override def invert(n: Option[A]) = Inversion.attempt(n){ n => n.map(_ => NullValue).get } + override def invert(n: Option[A]) = n match { + case Some(_) => Failure(new RuntimeException("Cannot convert non-empty option to NullValue")) + case None => Success(NullValue) + } } implicit def emptyValue[A]: Injection[EmptyValue.type, Option[A]] = new AbstractInjection[EmptyValue.type, Option[A]] { def apply(n: EmptyValue.type) = None - override def invert(n: Option[A]) = Inversion.attempt(n){ n => n.map(_ => EmptyValue).get } + override def invert(n: Option[A]) = n match { + case Some(_) => Failure(new RuntimeException("Cannot convert non-empty option to EmptyValue")) + case None => Success(EmptyValue) + } } } diff --git a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala index 7328abd9d..99bcb0ddc 100644 --- a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala +++ b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala @@ -18,8 +18,6 @@ package com.twitter.bijection.finagle_mysql import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection } import org.scalacheck.Arbitrary -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks import com.twitter.finagle.exp.mysql._ import java.sql.Timestamp import java.util.Date @@ -29,7 +27,7 @@ import org.scalacheck.Gen import org.scalacheck.Arbitrary import org.scalacheck.Arbitrary.arbitrary -class MySqlConversionLaws extends PropSpec with PropertyChecks with MustMatchers with BaseProperties { +class MySqlConversionLaws extends CheckProperties with BaseProperties { import MySqlConversions._ implicit val byteValueArb = Arbitrary(arbitrary[Byte].map(ByteValue.apply)) @@ -39,18 +37,23 @@ class MySqlConversionLaws extends PropSpec with PropertyChecks with MustMatchers implicit val floatValueArb = Arbitrary(arbitrary[Float].map(FloatValue.apply)) implicit val doubleValueArb = Arbitrary(arbitrary[Double].map(DoubleValue.apply)) implicit val stringValueArb = Arbitrary(arbitrary[String].map(StringValue.apply)) - implicit val timestampValueArb = Arbitrary(arbitrary[Date].map(d => new Timestamp(d.getTime))) implicit val nullValueArb = Arbitrary(Gen.const(NullValue)) implicit val emptyValueArb = Arbitrary(Gen.const(EmptyValue)) - implicit val valueArb: Arbitrary[Value] = Arbitrary(Gen.oneOf(arbitrary[ByteValue], - arbitrary[NullValue.type], - arbitrary[EmptyValue.type], - arbitrary[ShortValue], - arbitrary[IntValue], - arbitrary[LongValue], - arbitrary[FloatValue], - arbitrary[DoubleValue], - arbitrary[StringValue])) + + val timeGenerator = Gen.choose(1L, 253375661380264L) // until year 9999 + implicit val timestampValueArb = Arbitrary { + val UTC = java.util.TimeZone.getTimeZone("UTC") + val timestampValue = new TimestampValue(UTC, UTC) + for { + x <- timeGenerator + } yield timestampValue(new Timestamp(x)) + } + + implicit val timestampArb = Arbitrary { + for { + x <- timeGenerator + } yield new Timestamp(x) + } property("Byte") { isBijection[ByteValue, Byte] @@ -73,12 +76,9 @@ class MySqlConversionLaws extends PropSpec with PropertyChecks with MustMatchers property("String") { isBijection[StringValue, String] } - property("Boolean") { - isBijection[ByteValue, Boolean] - } - property("Timestamp") { - isInjection[Timestamp, Value] + property("Boolean") { + isInjection[Boolean, ByteValue] } property("Empty") { isInjection[EmptyValue.type, Option[Int]] @@ -86,4 +86,17 @@ class MySqlConversionLaws extends PropSpec with PropertyChecks with MustMatchers property("Null") { isInjection[NullValue.type, Option[String]] } + property("Timestamp") { + // Custom equivalence typeclass for RawValue + implicit val valueEquiv = new scala.math.Equiv[Value] { + override def equiv(a: Value, b: Value) = (a, b) match { + case (RawValue(Type.Timestamp, Charset.Binary, true, bytes1), + RawValue(Type.Timestamp, Charset.Binary, true, bytes2)) => + bytes1.toList == bytes2.toList + case _ => false + } + } + + isInjection[Timestamp, Value] + } } From edda8639b63866c29e95b8cae75f7acc1ffd62fb Mon Sep 17 00:00:00 2001 From: George Leontiev Date: Fri, 27 Feb 2015 14:04:33 +0100 Subject: [PATCH 12/19] Address the review. --- .../finagle_mysql/MySqlConversionLaws.scala | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala index 99bcb0ddc..0199f7344 100644 --- a/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala +++ b/bijection-finagle-mysql/src/test/scala/com/twitter/bijection/finagle_mysql/MySqlConversionLaws.scala @@ -30,18 +30,28 @@ import org.scalacheck.Arbitrary.arbitrary class MySqlConversionLaws extends CheckProperties with BaseProperties { import MySqlConversions._ - implicit val byteValueArb = Arbitrary(arbitrary[Byte].map(ByteValue.apply)) - implicit val shortValueArb = Arbitrary(arbitrary[Short].map(ShortValue.apply)) - implicit val intValueArb = Arbitrary(arbitrary[Int].map(IntValue.apply)) - implicit val longValueArb = Arbitrary(arbitrary[Long].map(LongValue.apply)) - implicit val floatValueArb = Arbitrary(arbitrary[Float].map(FloatValue.apply)) - implicit val doubleValueArb = Arbitrary(arbitrary[Double].map(DoubleValue.apply)) - implicit val stringValueArb = Arbitrary(arbitrary[String].map(StringValue.apply)) - implicit val nullValueArb = Arbitrary(Gen.const(NullValue)) - implicit val emptyValueArb = Arbitrary(Gen.const(EmptyValue)) + implicit val byteValueArb: Arbitrary[ByteValue] = + Arbitrary(arbitrary[Byte].map(ByteValue.apply)) + implicit val shortValueArb: Arbitrary[ShortValue] = + Arbitrary(arbitrary[Short].map(ShortValue.apply)) + implicit val intValueArb: Arbitrary[IntValue] = + Arbitrary(arbitrary[Int].map(IntValue.apply)) + implicit val longValueArb: Arbitrary[LongValue] = + Arbitrary(arbitrary[Long].map(LongValue.apply)) + implicit val floatValueArb: Arbitrary[FloatValue] = + Arbitrary(arbitrary[Float].map(FloatValue.apply)) + implicit val doubleValueArb: Arbitrary[DoubleValue] = + Arbitrary(arbitrary[Double].map(DoubleValue.apply)) + implicit val stringValueArb: Arbitrary[StringValue] = + Arbitrary(arbitrary[String].map(StringValue.apply)) + implicit val nullValueArb: Arbitrary[NullValue.type] = + Arbitrary(Gen.const(NullValue)) + implicit val emptyValueArb: Arbitrary[EmptyValue.type] = + Arbitrary(Gen.const(EmptyValue)) - val timeGenerator = Gen.choose(1L, 253375661380264L) // until year 9999 - implicit val timestampValueArb = Arbitrary { + val timeGenerator: Gen[Long] = Gen.choose(1L, 253375661380264L) // until year 9999 + + implicit val timestampValueArb: Arbitrary[Value] = Arbitrary { val UTC = java.util.TimeZone.getTimeZone("UTC") val timestampValue = new TimestampValue(UTC, UTC) for { @@ -49,7 +59,7 @@ class MySqlConversionLaws extends CheckProperties with BaseProperties { } yield timestampValue(new Timestamp(x)) } - implicit val timestampArb = Arbitrary { + implicit val timestampArb: Arbitrary[Timestamp] = Arbitrary { for { x <- timeGenerator } yield new Timestamp(x) @@ -87,7 +97,10 @@ class MySqlConversionLaws extends CheckProperties with BaseProperties { isInjection[NullValue.type, Option[String]] } property("Timestamp") { - // Custom equivalence typeclass for RawValue + /** Custom equivalence typeclass for RawValue + * This is here to compare two RawValues generated from Timestamps. + * Because they contain byte arrays, just =='ing them does not work as expected. + */ implicit val valueEquiv = new scala.math.Equiv[Value] { override def equiv(a: Value, b: Value) = (a, b) match { case (RawValue(Type.Timestamp, Charset.Binary, true, bytes1), From bf0386df93507e02e6c6e599c25ab1a691674b47 Mon Sep 17 00:00:00 2001 From: Joakim Bodin Date: Sun, 15 Mar 2015 21:47:21 +0100 Subject: [PATCH 13/19] Add implicit conversion for GZippedBase64String to String - Include unit test for both GZippedBase64String and Base64String to String injections --- .../twitter/bijection/BinaryBijections.scala | 10 ++++++++- .../bijection/BinaryBijectionLaws.scala | 22 +++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/bijection-core/src/main/scala/com/twitter/bijection/BinaryBijections.scala b/bijection-core/src/main/scala/com/twitter/bijection/BinaryBijections.scala index e45f8a7bc..939dc108e 100644 --- a/bijection-core/src/main/scala/com/twitter/bijection/BinaryBijections.scala +++ b/bijection-core/src/main/scala/com/twitter/bijection/BinaryBijections.scala @@ -30,13 +30,21 @@ case class GZippedBytes(bytes: Array[Byte]) extends AnyVal { case class GZippedBase64String(str: String) extends AnyVal +object GZippedBase64String { + implicit val unwrap: Injection[GZippedBase64String, String] = + new AbstractInjection[GZippedBase64String, String] { + override def apply(gzbs: GZippedBase64String) = gzbs.str + override def invert(str: String) = attemptWhen(str)(Base64.isBase64)(GZippedBase64String(_)) + } +} + case class Base64String(str: String) extends AnyVal object Base64String { implicit val unwrap: Injection[Base64String, String] = new AbstractInjection[Base64String, String] { override def apply(bs: Base64String) = bs.str - override def invert(str: String) = attemptWhen(str)(Base64.isBase64(_))(Base64String(_)) + override def invert(str: String) = attemptWhen(str)(Base64.isBase64)(Base64String(_)) } } diff --git a/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala b/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala index a32d3275c..0ef9c5ab0 100644 --- a/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala +++ b/bijection-core/src/test/scala/com/twitter/bijection/BinaryBijectionLaws.scala @@ -17,14 +17,14 @@ limitations under the License. package com.twitter.bijection import java.nio.ByteBuffer -import org.scalatest.{ PropSpec, MustMatchers } -import org.scalatest.prop.PropertyChecks -import org.scalacheck.Prop._ +import com.twitter.bijection.codec.Base64 +import org.scalacheck.Arbitrary +import org.scalatest.MustMatchers class BinaryBijectionLaws extends CheckProperties with MustMatchers with BaseProperties { - implicit val arbBB = arbitraryViaFn[Array[Byte], ByteBuffer] { ByteBuffer.wrap(_) } + implicit val arbBB = arbitraryViaFn[Array[Byte], ByteBuffer] { ByteBuffer.wrap } // TODO: These are all bijections, property("Array[Byte] <=> ByteBuffer") { @@ -40,10 +40,24 @@ class BinaryBijectionLaws extends CheckProperties with MustMatchers isInjective[Array[Byte], Base64String] } + property("Base64String -> String") { + implicit val arbB64: Arbitrary[Base64String] = arbitraryViaFn { s: String => + Base64String(Base64.encodeBase64String(s.getBytes("UTF-8"))) + } + isInjection[Base64String, String] + } + property("rts Array[Byte] -> GZippedBase64String") { isInjective[Array[Byte], GZippedBase64String] } + property("GZippedBase64String -> String") { + implicit val arbGzB64: Arbitrary[GZippedBase64String] = arbitraryViaFn { s: String => + GZippedBase64String(Base64.encodeBase64String(s.getBytes("UTF-8"))) + } + isInjection[GZippedBase64String, String] + } + implicit val optSer = JavaSerializationInjection[Option[Int]] property("java serialize Option[Int]") { From c16f3209e9eecd2264bc3773e46dd749952e9faa Mon Sep 17 00:00:00 2001 From: Alex Henning Johannessen Date: Thu, 26 Mar 2015 21:41:20 +0000 Subject: [PATCH 14/19] Typo in example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b20212ed..679992b39 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ string2Long2Bytes2B64: com.twitter.bijection.Bijection[String,com.twitter.biject scala> 243L.as[Base64String] res0: com.twitter.bijection.Base64String = Base64String(MjQz) -scala> long2String2Bytes2B64.invert(res5) +scala> long2String2Bytes2B64.invert(res0) res1: Try[Long] = Success(243) ``` From 1ae5390f365f801a157215dac4930fd91e4b0120 Mon Sep 17 00:00:00 2001 From: Mansur Ashraf Date: Mon, 6 Apr 2015 11:45:30 -0700 Subject: [PATCH 15/19] upgrade testing libraries --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 581fcc822..51603b2e2 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -29,8 +29,8 @@ object BijectionBuild extends Build { javacOptions in doc := Seq("-source", "1.6"), libraryDependencies ++= Seq( - "org.scalacheck" %% "scalacheck" % "1.11.5" % "test", - "org.scalatest" %% "scalatest" % "2.2.2" % "test" + "org.scalacheck" %% "scalacheck" % "1.12.2" % "test", + "org.scalatest" %% "scalatest" % "2.2.4" % "test" ), resolvers ++= Seq( From 7cafeb7d014763512d8a0a6ebffdb66e2fa5d6f0 Mon Sep 17 00:00:00 2001 From: Daniel Schobel Date: Mon, 20 Apr 2015 17:24:17 -0700 Subject: [PATCH 16/19] bump util-core dep and add Buf <-> Array[Byte] bijection --- .../twitter/bijection/twitter_util/UtilBijections.scala | 7 +++++++ .../twitter/bijection/twitter_util/UtilBijectionLaws.scala | 6 ++++++ project/Build.scala | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala index 7537441a7..f7cf819fe 100644 --- a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala +++ b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala @@ -17,6 +17,7 @@ limitations under the License. package com.twitter.bijection.twitter_util import com.twitter.bijection.{ AbstractBijection, Bijection, ImplicitBijection } +import com.twitter.io.Buf import com.twitter.util.{ Future => TwitterFuture, Try => TwitterTry, Promise => TwitterPromise, Return, Throw, FuturePool } import scala.concurrent.{ Future => ScalaFuture, Promise => ScalaPromise, ExecutionContext } @@ -122,6 +123,12 @@ trait UtilBijections { override def apply(pool: FuturePool) = new TwitterExecutionContext(pool) override def invert(context: ExecutionContext) = new ScalaFuturePool(context) } + + implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = + new AbstractBijection[Array[Byte], Buf] { + override def apply(bytes: Array[Byte]) = Buf.ByteArray.Owned(bytes) + override def invert(buf: Buf) = Buf.ByteArray.Owned.extract(buf) + } } object UtilBijections extends UtilBijections diff --git a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala index 87d65b1df..cc98e96e7 100644 --- a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala +++ b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala @@ -17,6 +17,7 @@ limitations under the License. package com.twitter.bijection.twitter_util import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection } +import com.twitter.io.Buf import com.twitter.util.{ Future => TwitterFuture, Try => TwitterTry, Await => TwitterAwait } import java.lang.{ Integer => JInt, Long => JLong } import org.scalacheck.Arbitrary @@ -44,6 +45,7 @@ class UtilBijectionLaws extends CheckProperties with BaseProperties { implicit val jIntArb = arbitraryViaBijection[Int, JInt] implicit val jLongArb = arbitraryViaBijection[Long, JLong] + implicit val bufArb: Arbitrary[Buf] = arbitraryViaFn[Array[Byte], Buf](Buf.ByteArray.Owned.apply) implicit protected def futureEq[T: Equiv]: Equiv[TwitterFuture[T]] = Equiv.fromFunction { (f1, f2) => Equiv[Option[T]].equiv(toOption(f1), toOption(f2)) @@ -80,4 +82,8 @@ class UtilBijectionLaws extends CheckProperties with BaseProperties { isBijection[TwitterFuture[ToMap], ScalaFuture[ToMap]] } + property("round trips com.twitter.io.Buf -> Array[Byte]") { + isBijection[Array[Byte], Buf] + } + } diff --git a/project/Build.scala b/project/Build.scala index 51603b2e2..0f301d5ff 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -226,7 +226,7 @@ object BijectionBuild extends Build { lazy val bijectionUtil = module("util").settings( osgiExportAll("com.twitter.bijection.twitter_util"), - libraryDependencies += "com.twitter" %% "util-core" % "6.20.0" + libraryDependencies += "com.twitter" %% "util-core" % "6.23.0" ).dependsOn(bijectionCore % "test->test;compile->compile") lazy val bijectionFinagleMySql = module("finagle-mysql").settings( From 4b449fbf44cfdda8d7daa59fdfd9b37505f8ab85 Mon Sep 17 00:00:00 2001 From: Daniel Schobel Date: Tue, 21 Apr 2015 10:23:49 -0700 Subject: [PATCH 17/19] explicit Shared/Owned scope for Buf bijection --- .../twitter_util/UtilBijections.scala | 20 ++++++++++++++----- .../twitter_util/UtilBijectionLaws.scala | 9 ++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala index f7cf819fe..e9ed91b65 100644 --- a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala +++ b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala @@ -124,11 +124,21 @@ trait UtilBijections { override def invert(context: ExecutionContext) = new ScalaFuturePool(context) } - implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = - new AbstractBijection[Array[Byte], Buf] { - override def apply(bytes: Array[Byte]) = Buf.ByteArray.Owned(bytes) - override def invert(buf: Buf) = Buf.ByteArray.Owned.extract(buf) - } + object Owned { + implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = + new AbstractBijection[Array[Byte], Buf] { + override def apply(bytes: Array[Byte]) = Buf.ByteArray.Owned(bytes) + override def invert(buf: Buf) = Buf.ByteArray.Owned.extract(buf) + } + } + + object Shared { + implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = + new AbstractBijection[Array[Byte], Buf] { + override def apply(bytes: Array[Byte]) = Buf.ByteArray.Shared(bytes) + override def invert(buf: Buf) = Buf.ByteArray.Shared.extract(buf) + } + } } object UtilBijections extends UtilBijections diff --git a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala index cc98e96e7..5021ec8c8 100644 --- a/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala +++ b/bijection-util/src/test/scala/com/twitter/bijection/twitter_util/UtilBijectionLaws.scala @@ -82,8 +82,15 @@ class UtilBijectionLaws extends CheckProperties with BaseProperties { isBijection[TwitterFuture[ToMap], ScalaFuture[ToMap]] } - property("round trips com.twitter.io.Buf -> Array[Byte]") { + property("round trips shared com.twitter.io.Buf -> Array[Byte]") { + import Shared.byteArrayBufBijection + isBijection[Array[Byte], Buf] } + property("round trips owned com.twitter.io.Buf -> Array[Byte]") { + import Owned.byteArrayBufBijection + + isBijection[Array[Byte], Buf] + } } From 489d5d1f515848195d6b736cadefaa4ced917aa0 Mon Sep 17 00:00:00 2001 From: Daniel Schobel Date: Tue, 21 Apr 2015 13:53:25 -0700 Subject: [PATCH 18/19] add description of Shared vs Owned Buf semantics --- .../twitter/bijection/twitter_util/UtilBijections.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala index e9ed91b65..ae13ffe66 100644 --- a/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala +++ b/bijection-util/src/main/scala/com/twitter/bijection/twitter_util/UtilBijections.scala @@ -125,6 +125,10 @@ trait UtilBijections { } object Owned { + /** + * A bijection using Buf's Owned api which minimizes copying of the underlying + * array data but places the onus of immutability on the user. + */ implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = new AbstractBijection[Array[Byte], Buf] { override def apply(bytes: Array[Byte]) = Buf.ByteArray.Owned(bytes) @@ -133,6 +137,10 @@ trait UtilBijections { } object Shared { + /** + * A bijection using Buf's Shared api which avoids sharing state at the cost + * added allocations for defensive copies. + */ implicit def byteArrayBufBijection: Bijection[Array[Byte], Buf] = new AbstractBijection[Array[Byte], Buf] { override def apply(bytes: Array[Byte]) = Buf.ByteArray.Shared(bytes) From cf205bd8bd5f1c7ed05b35865e51a1b17e63b932 Mon Sep 17 00:00:00 2001 From: Joe Nievelt Date: Fri, 8 May 2015 12:19:12 -0700 Subject: [PATCH 19/19] Prepare for release of 0.8.0 --- CHANGES.md | 8 ++++++++ README.md | 2 +- project/Build.scala | 6 +++--- version.sbt | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4946aa98d..7b379d49e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # Bijection # +### 0.8.0 +* add twitter util Buf <-> Array[Byte] bijection https://github.com/twitter/bijection/pull/208 +* upgrade testing libraries https://github.com/twitter/bijection/pull/207 +* Add implicit conversion for GZippedBase64String to String https://github.com/twitter/bijection/pull/203 +* Make property tests work again https://github.com/twitter/bijection/pull/198 +* Add a module for finagle-mysql bijections. https://github.com/twitter/bijection/pull/197 +* Build bijection-scrooge for scala 2.11 https://github.com/twitter/bijection/pull/196 + ### 0.7.2 * FIX: gzip Bijection resource leak. https://github.com/twitter/bijection/pull/193 * Use new Travis CI infrastructure https://github.com/twitter/bijection/pull/191 diff --git a/README.md b/README.md index 679992b39..9dfc35ac8 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Discussion occurs primarily on the [Bijection mailing list](https://groups.googl ## Maven -Bijection modules are available on maven central. The current groupid and version for all modules is, respectively, `"com.twitter"` and `0.7.2`. +Bijection modules are available on maven central. The current groupid and version for all modules is, respectively, `"com.twitter"` and `0.8.0`. Current published artifacts are diff --git a/project/Build.scala b/project/Build.scala index 0f301d5ff..7bfee62b3 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -18,11 +18,11 @@ object BijectionBuild extends Build { val sharedSettings = Project.defaultSettings ++ osgiSettings ++ scalariformSettings ++ Seq( organization := "com.twitter", - crossScalaVersions := Seq("2.10.4", "2.11.5"), + crossScalaVersions := Seq("2.10.5", "2.11.5"), ScalariformKeys.preferences := formattingPreferences, - scalaVersion := "2.10.4", + scalaVersion := "2.10.5", javacOptions ++= Seq("-source", "1.6", "-target", "1.6"), @@ -122,7 +122,7 @@ object BijectionBuild extends Build { def youngestForwardCompatible(subProj: String) = Some(subProj) .filterNot(unreleasedModules.contains(_)) - .map { s => "com.twitter" % ("bijection-" + s + "_2.10") % "0.7.0" } + .map { s => "com.twitter" % ("bijection-" + s + "_2.10") % "0.8.0" } def osgiExportAll(packs: String*) = OsgiKeys.exportPackage := packs.map(_ + ".*;version=${Bundle-Version}") diff --git a/version.sbt b/version.sbt index 38be20ed4..014e7f4a2 100644 --- a/version.sbt +++ b/version.sbt @@ -1,2 +1,2 @@ -version in ThisBuild := "0.7.2" +version in ThisBuild := "0.8.0"