Skip to content

Commit 8d47172

Browse files
committed
Merge branch 'release/0.5.0'
2 parents 0363427 + 3cc60a3 commit 8d47172

File tree

25 files changed

+237
-244
lines changed

25 files changed

+237
-244
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: scala
22
scala:
3-
- 2.10.3
4-
- 2.9.3
3+
- 2.10.4
4+
- 2.11.2

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# chill #
22

3+
### 0.5.0
4+
* Move to211: https://github.com/twitter/chill/pull/197
5+
* Make 2.10.4 the default, move to scalatest: https://github.com/twitter/chill/pull/196
6+
37
### 0.4.0
48
* Support serializing asJavaIterable.: https://github.com/twitter/chill/pull/192
59
* Remove a deprecation, that really should never have been there: https://github.com/twitter/chill/pull/189

chill-akka/src/test/scala/com/twitter/chill/akka/AkkaTests.scala

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ limitations under the License.
1616

1717
package com.twitter.chill.akka
1818

19-
import org.specs._
19+
import org.scalatest._
2020

2121
import akka.actor.{ ActorRef, ActorSystem }
2222
import akka.serialization._
2323
import com.typesafe.config.ConfigFactory
2424

25-
class AkkaTests extends Specification {
26-
27-
noDetailedDiffs() //Fixes issue for scala 2.9
25+
class AkkaTests extends WordSpec with Matchers {
2826

2927
val system = ActorSystem("example", ConfigFactory.parseString("""
3028
akka.actor.serializers {
@@ -44,24 +42,24 @@ class AkkaTests extends Specification {
4442
"be selected for tuples" in {
4543
// Find the Serializer for it
4644
val serializer = serialization.findSerializerFor((1, 2, 3))
47-
serializer.getClass.equals(classOf[AkkaSerializer]) must beTrue
45+
serializer.getClass.equals(classOf[AkkaSerializer]) should equal(true)
4846
}
4947

5048
"be selected for ActorRef" in {
5149
val serializer = serialization.findSerializerFor(system.actorFor("akka://test-system/test-actor"))
52-
serializer.getClass.equals(classOf[AkkaSerializer]) must beTrue
50+
serializer.getClass.equals(classOf[AkkaSerializer]) should equal(true)
5351
}
5452

5553
"serialize and deserialize ActorRef successfully" in {
5654
val actorRef = system.actorFor("akka://test-system/test-actor")
5755

5856
val serialized = serialization.serialize(actorRef)
59-
serialized.isSuccess must beTrue
57+
serialized.isSuccess should equal(true)
6058

6159
val deserialized = serialization.deserialize(serialized.get, classOf[ActorRef])
62-
deserialized.isSuccess must beTrue
60+
deserialized.isSuccess should equal(true)
6361

64-
deserialized.get.equals(actorRef) must beTrue
62+
deserialized.get.equals(actorRef) should equal(true)
6563
}
6664

6765
}

chill-algebird/src/test/scala/com/twitter/chill/algebird/AlgebirdSerializersSpec.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package com.twitter.chill.algebird
1818

1919
import com.twitter.chill.{ KSerializer, ScalaKryoInstantiator, KryoPool }
2020
import com.twitter.algebird.{ AveragedValue, DecayedValue, HyperLogLogMonoid, MomentsGroup, AdaptiveVector }
21-
import org.specs.Specification
21+
import org.scalatest._
2222

23-
class AlgebirdSerializersSpec extends Specification {
23+
class AlgebirdSerializersSpec extends WordSpec with Matchers {
2424
val kryo = {
2525
val inst = () => {
2626
val newK = (new ScalaKryoInstantiator).newKryo
@@ -36,13 +36,14 @@ class AlgebirdSerializersSpec extends Specification {
3636
//println("bytes size : " + bytes.size)
3737
//println("bytes: " + new String(bytes, "UTF-8"))
3838
val result = kryo.fromBytes(bytes).asInstanceOf[X]
39-
result must_== x
39+
result should equal(x)
40+
4041
}
4142

4243
def roundtripNoEq[X](x: X)(f: X => Any) {
4344
val bytes = kryo.toBytesWithClass(x)
4445
val result = kryo.fromBytes(bytes).asInstanceOf[X]
45-
f(result) must_== f(x)
46+
f(result) should equal(f(x))
4647
}
4748

4849
"kryo with AlgebirdRegistrar" should {

chill-avro/src/test/scala/com/twitter/chill/avro/AvroSerializerSpec.scala

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
*/
1515
package com.twitter.chill.avro
1616

17-
import org.specs.Specification
17+
import org.scalatest._
1818
import com.twitter.chill.{ KSerializer, ScalaKryoInstantiator, KryoPool }
1919
import avro.FiscalRecord
2020
import org.apache.avro.generic.GenericRecordBuilder
@@ -25,7 +25,7 @@ import org.apache.avro.generic.GenericData.Record
2525
* @author Mansur Ashraf
2626
* @since 2/9/14.
2727
*/
28-
object AvroSerializerSpec extends Specification {
28+
object AvroSerializerSpec extends WordSpec with Matchers {
2929

3030
def getKryo[T: Manifest](k: KSerializer[T]) = {
3131
val inst = {
@@ -54,7 +54,7 @@ object AvroSerializerSpec extends Specification {
5454
val kryo = getKryo(AvroSerializer.SpecificRecordSerializer[FiscalRecord])
5555
val bytes = kryo.toBytesWithClass(testRecord)
5656
val result = kryo.fromBytes(bytes).asInstanceOf[FiscalRecord]
57-
testRecord must_== result
57+
testRecord should equal(result)
5858
}
5959
}
6060

@@ -63,7 +63,7 @@ object AvroSerializerSpec extends Specification {
6363
val kryo = getKryo(AvroSerializer.SpecificRecordBinarySerializer[FiscalRecord])
6464
val bytes = kryo.toBytesWithClass(testRecord)
6565
val result = kryo.fromBytes(bytes).asInstanceOf[FiscalRecord]
66-
testRecord must_== result
66+
testRecord should equal(result)
6767
}
6868
}
6969

@@ -72,7 +72,7 @@ object AvroSerializerSpec extends Specification {
7272
val kryo = getKryo(AvroSerializer.SpecificRecordJsonSerializer[FiscalRecord](FiscalRecord.SCHEMA$))
7373
val bytes = kryo.toBytesWithClass(testRecord)
7474
val result = kryo.fromBytes(bytes).asInstanceOf[FiscalRecord]
75-
testRecord must_== result
75+
testRecord should equal(result)
7676
}
7777
}
7878

@@ -81,13 +81,13 @@ object AvroSerializerSpec extends Specification {
8181
val kryo = getKryo(AvroSerializer.GenericRecordSerializer[Record]())
8282
val userBytes = kryo.toBytesWithClass(user)
8383
val userResult = kryo.fromBytes(userBytes).asInstanceOf[Record]
84-
userResult.get("name").toString must_== "Jeff"
85-
userResult.get("ID") must_== 1
86-
user.toString must_== userResult.toString
84+
userResult.get("name").toString should equal("Jeff")
85+
userResult.get("ID") should equal(1)
86+
user.toString should equal(userResult.toString)
8787

8888
val testRecordBytes = kryo.toBytesWithClass(testRecord)
8989
val testRecordResult = kryo.fromBytes(testRecordBytes).asInstanceOf[FiscalRecord]
90-
testRecord.toString must_== testRecordResult.toString
90+
testRecord.toString should equal(testRecordResult.toString)
9191
}
9292
}
9393
}

chill-bijection/src/main/scala/com/twitter/chill/BijectionEnrichedKryo.scala

+14-12
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ package com.twitter.chill
1919
import com.twitter.bijection.Injection
2020
import com.twitter.bijection.{ Bufferable, Bijection, ImplicitBijection, Injection }
2121

22+
import scala.reflect.ClassTag
23+
2224
object BijectionEnrichedKryo {
2325
implicit def enrich(k: Kryo): BijectionEnrichedKryo = new BijectionEnrichedKryo(k)
2426

2527
/**
2628
* Use a bijection[A,B] then the KSerializer on B
2729
*/
28-
def viaBijection[A, B](kser: KSerializer[B])(implicit bij: ImplicitBijection[A, B], cmf: ClassManifest[B]): KSerializer[A] =
30+
def viaBijection[A, B](kser: KSerializer[B])(implicit bij: ImplicitBijection[A, B], cmf: ClassTag[B]): KSerializer[A] =
2931
new KSerializer[A] {
3032
def write(k: Kryo, out: Output, obj: A) { kser.write(k, out, bij(obj)) }
3133
def read(k: Kryo, in: Input, cls: Class[A]) =
32-
bij.invert(kser.read(k, in, cmf.erasure.asInstanceOf[Class[B]]))
34+
bij.invert(kser.read(k, in, cmf.runtimeClass.asInstanceOf[Class[B]]))
3335
}
3436

3537
def viaBufferable[T](implicit b: Bufferable[T]): KSerializer[T] =
@@ -38,32 +40,32 @@ object BijectionEnrichedKryo {
3840

3941
class BijectionEnrichedKryo(k: Kryo) {
4042

41-
def injectionForClass[T](implicit inj: Injection[T, Array[Byte]], cmf: ClassManifest[T]): Kryo = {
42-
k.register(cmf.erasure, InjectiveSerializer.asKryo[T])
43+
def injectionForClass[T](implicit inj: Injection[T, Array[Byte]], cmf: ClassTag[T]): Kryo = {
44+
k.register(cmf.runtimeClass, InjectiveSerializer.asKryo[T])
4345
k
4446
}
4547

46-
def injectionForSubclass[T](implicit inj: Injection[T, Array[Byte]], cmf: ClassManifest[T]): Kryo = {
47-
k.addDefaultSerializer(cmf.erasure, InjectiveSerializer.asKryo[T])
48+
def injectionForSubclass[T](implicit inj: Injection[T, Array[Byte]], cmf: ClassTag[T]): Kryo = {
49+
k.addDefaultSerializer(cmf.runtimeClass, InjectiveSerializer.asKryo[T])
4850
k
4951
}
5052

51-
def bufferableForClass[T](implicit b: Bufferable[T], cmf: ClassManifest[T]): Kryo = {
52-
k.register(cmf.erasure, BijectionEnrichedKryo.viaBufferable[T])
53+
def bufferableForClass[T](implicit b: Bufferable[T], cmf: ClassTag[T]): Kryo = {
54+
k.register(cmf.runtimeClass, BijectionEnrichedKryo.viaBufferable[T])
5355
k
5456
}
5557

5658
/**
5759
* B has to already be registered, then use the KSerializer[B] to create KSerialzer[A]
5860
*/
59-
def forClassViaBijection[A, B](implicit bij: ImplicitBijection[A, B], acmf: ClassManifest[A], bcmf: ClassManifest[B]): Kryo = {
60-
val kserb = k.getSerializer(bcmf.erasure).asInstanceOf[KSerializer[B]]
61-
k.register(acmf.erasure, BijectionEnrichedKryo.viaBijection[A, B](kserb))
61+
def forClassViaBijection[A, B](implicit bij: ImplicitBijection[A, B], acmf: ClassTag[A], bcmf: ClassTag[B]): Kryo = {
62+
val kserb = k.getSerializer(bcmf.runtimeClass).asInstanceOf[KSerializer[B]]
63+
k.register(acmf.runtimeClass, BijectionEnrichedKryo.viaBijection[A, B](kserb))
6264
k
6365
}
6466

6567
/** Helpful override to alleviate rewriting types. */
66-
def forClassViaBijection[A, B](bij: Bijection[A, B])(implicit acmf: ClassManifest[A], bcmf: ClassManifest[B]): Kryo = {
68+
def forClassViaBijection[A, B](bij: Bijection[A, B])(implicit acmf: ClassTag[A], bcmf: ClassTag[B]): Kryo = {
6769
implicit def implicitBij = bij
6870
this.forClassViaBijection[A, B]
6971
}

chill-bijection/src/test/scala/com/twitter/chill/CustomSerializationSpec.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.twitter.chill
1818

19-
import org.specs._
19+
import org.scalatest._
2020

2121
import com.twitter.bijection.Bijection
2222

@@ -29,7 +29,7 @@ object Globals {
2929
var temp = false
3030
}
3131

32-
class CustomSerializationSpec extends Specification with BaseProperties {
32+
class CustomSerializationSpec extends WordSpec with Matchers with BaseProperties {
3333
"Custom KryoSerializers and KryoDeserializers" should {
3434
"serialize objects that have registered serialization" in {
3535

@@ -66,7 +66,7 @@ class CustomSerializationSpec extends Specification with BaseProperties {
6666
val point = Point(5, 6)
6767
val coloredPoint = ColoredPoint(color, point)
6868

69-
rt(myInst, coloredPoint) must_== coloredPoint
69+
rt(myInst, coloredPoint) should equal(coloredPoint)
7070
}
7171
"use bijections" in {
7272
implicit val bij = Bijection.build[TestCaseClassForSerialization, (String, Int)] { s =>
@@ -78,18 +78,18 @@ class CustomSerializationSpec extends Specification with BaseProperties {
7878
.newKryo
7979
.forClassViaBijection[TestCaseClassForSerialization, (String, Int)]
8080
}
81-
rt(inst, TestCaseClassForSerialization("hey", 42)) must be_==(TestCaseClassForSerialization("hey", 42))
81+
rt(inst, TestCaseClassForSerialization("hey", 42)) should equal(TestCaseClassForSerialization("hey", 42))
8282
}
8383
"Make sure KryoInjection and instances are Java Serializable" in {
8484
val ki = jrt(KryoInjection)
85-
ki.invert(ki(1)).get must be_==(1)
85+
ki.invert(ki(1)).get should equal(1)
8686
val kii = jrt(KryoInjection.instance(new ScalaKryoInstantiator))
87-
kii.invert(kii(1)).get must be_==(1)
87+
kii.invert(kii(1)).get should equal(1)
8888
}
8989
}
9090
"KryoInjection handle an example with closure to function" in {
9191
val x = rt(() => Foo.Bar)
92-
x() must be_==(Foo.Bar)
92+
x() should equal(Foo.Bar)
9393
}
9494
"handle a closure to println" in {
9595
Globals.temp = false
@@ -101,6 +101,6 @@ class CustomSerializationSpec extends Specification with BaseProperties {
101101
})
102102
val inv = KryoInjection.invert(bytes)
103103
inv.get.asInstanceOf[() => Unit].apply()
104-
Globals.temp must be_==(true)
104+
Globals.temp should equal(true)
105105
}
106106
}

chill-hadoop/src/test/scala/com/twitter/chill/hadoop/HadoopTests.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package com.twitter.chill.hadoop
1818

19-
import org.specs._
19+
import org.scalatest._
2020

2121
import com.esotericsoftware.kryo.Kryo;
2222
import com.esotericsoftware.kryo.io.Input;
@@ -37,9 +37,7 @@ class StdKryoInstantiator extends KryoInstantiator {
3737
k
3838
}
3939
}
40-
class HadoopTests extends Specification {
41-
noDetailedDiffs() //Fixes issue for scala 2.9
42-
40+
class HadoopTests extends WordSpec with Matchers {
4341
def rt[A <: AnyRef](k: KryoSerialization, a: A): A = {
4442
val out = new BAOut
4543
val cls = a.getClass.asInstanceOf[Class[AnyRef]]
@@ -65,7 +63,7 @@ class HadoopTests extends Specification {
6563
val ks = new KryoSerialization(conf)
6664
Seq(classOf[List[_]], classOf[Int], this.getClass).forall { cls =>
6765
ks.accept(cls)
68-
} must beTrue
66+
} should equal(true)
6967
}
7068
"Serialize a list of random things" in {
7169
val conf = new Configuration
@@ -76,7 +74,7 @@ class HadoopTests extends Specification {
7674
val ks = new KryoSerialization(conf)
7775
val things = List(1.asInstanceOf[AnyRef], "hey", (1, 2))
7876

79-
things.map { rt(ks, _) } must be_==(things)
77+
things.map { rt(ks, _) } should equal(things)
8078
}
8179
}
8280
}

chill-java/src/test/scala/com/twitter/chill/config/ConfiguredInstantiatorTest.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ limitations under the License.
1616

1717
package com.twitter.chill.config
1818

19-
import org.specs._
19+
import org.scalatest._
2020

2121
import com.twitter.chill._
2222
import com.esotericsoftware.kryo.Kryo
2323

2424
class TestInst extends KryoInstantiator { override def newKryo = new Kryo }
2525

26-
class ReflectingInstantiatorTest extends Specification {
26+
class ReflectingInstantiatorTest extends WordSpec with Matchers {
2727
"A ConfiguredInstantiator" should {
2828
"work with a reflected instantiator" in {
2929
val conf = new JavaMapConfig
3030
ConfiguredInstantiator.setReflect(conf, classOf[TestInst])
31-
conf.get(ConfiguredInstantiator.KEY) must be_==(classOf[TestInst].getName)
31+
conf.get(ConfiguredInstantiator.KEY) should equal(classOf[TestInst].getName)
3232
val cci = new ConfiguredInstantiator(conf)
33-
cci.getDelegate.getClass == classOf[TestInst] must beTrue
33+
cci.getDelegate.getClass should equal(classOf[TestInst])
3434
}
3535
"work with a serialized instantiator" in {
3636
val conf = new JavaMapConfig
3737
ConfiguredInstantiator.setSerialized(conf, new TestInst)
3838
val cci = new ConfiguredInstantiator(conf)
3939
// Here is the only assert:
40-
cci.getDelegate.getClass == classOf[TestInst] must beTrue
40+
cci.getDelegate.getClass should equal(classOf[TestInst])
4141
}
4242
}
4343
}

chill-java/src/test/scala/com/twitter/chill/java/LocaleTest.scala

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
package com.twitter.chill.java
1818

19-
import org.specs._
19+
import org.scalatest._
2020

2121
import com.esotericsoftware.kryo.Kryo;
2222
import com.esotericsoftware.kryo.io.Input;
@@ -26,8 +26,7 @@ import org.objenesis.strategy.StdInstantiatorStrategy
2626

2727
import _root_.java.util.Locale
2828

29-
class LocaleSpec extends Specification {
30-
noDetailedDiffs() //Fixes issue for scala 2.9
29+
class LocaleSpec extends WordSpec with Matchers {
3130

3231
def rt[A](k: Kryo, a: A): A = {
3332
val out = new Output(1000, -1)
@@ -45,7 +44,7 @@ class LocaleSpec extends Specification {
4544
LocaleSerializer.registrar()(kryo)
4645

4746
Locale.getAvailableLocales.foreach { l =>
48-
rt(kryo, l) must be_==(l)
47+
rt(kryo, l) should equal(l)
4948
}
5049
}
5150
}

0 commit comments

Comments
 (0)