8000 Going forward with the specs2 upgrade · mst-appear/postgresql-async@3477a01 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 3477a01

Browse files
committed
Going forward with the specs2 upgrade
1 parent ffa2c26 commit 3477a01

File tree

12 files changed

+46
-47
lines changed

12 files changed

+46
-47
lines changed

db-async-common/src/main/scala/com/github/mauricio/async/db/util/FutureUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import scala.language.postfixOps
2222

2323
object FutureUtils {
2424

25-
def await[T]( future : Future[T] ) : T = {
25+
def awaitFuture[T]( future : Future[T] ) : T = {
2626
Await.result(future, 5 seconds )
2727
}
2828

mysql-async/src/main/scala/com/github/mauricio/async/db/mysql/codec/MySQLConnectionHandler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class MySQLConnectionHandler(
8686

8787
override def channelRead0(ctx: ChannelHandlerContext, message: Object) {
8888

89-
log.debug("Message received {}", message)
89+
//log.debug("Message received {}", message)
9090

9191
message match {
9292
case m: ServerMessage => {

mysql-async/src/main/scala/com/github/mauricio/async/db/mysql/codec/MySQLFrameDecoder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class MySQLFrameDecoder(charset: Charset, connectionId : String) extends ByteToM
7777

7878
// TODO: Remove once https://github.com/netty/netty/issues/1704 is fixed
7979
val slice = buffer.readSlice(size).order(ByteOrder.LITTLE_ENDIAN)
80-
val dump = MySQLHelper.dumpAsHex(slice)
81-
log.debug(s"[${messagesCount.get()}] Dump of message is - $messageType - $size isInQuery $isInQuery processingColumns $processingColumns processedColumns $processedColumns processingParams $processingParams processedParams $processedParams \n{}", dump)
80+
//val dump = MySQLHelper.dumpAsHex(slice)
81+
//log.debug(s"[${messagesCount.get()}] Dump of message is - $messageType - $size isInQuery $isInQuery processingColumns $processingColumns processedColumns $processedColumns processingParams $processingParams processedParams $processedParams \n{}", dump)
8282

8383
slice.readByte()
8484

mysql-async/src/main/scala/com/github/mauricio/async/db/mysql/codec/MySQLOneToOneEncoder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MySQLOneToOneEncoder(charset: Charset, charsetMapper: CharsetMapper) exten
6969
case _ => throw new EncoderNotAvailableException(message)
7070
}
7171

72-
log.debug("Writing message {}", message)
72+
//log.debug("Writing message {}", message)
7373

7474
val result = encoder.encode(message)
7575

mysql-async/src/main/scala/com/github/mauricio/async/db/mysql/decoder/PreparedStatementPrepareResponseDecoder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class PreparedStatementPrepareResponseDecoder extends MessageDecoder {
2727

2828
def decode(buffer: ByteBuf): ServerMessage = {
2929

30-
val dump = MySQLHelper.dumpAsHex(buffer)
31-
log.debug("prepared statement response dump is \n{}", dump)
30+
//val dump = MySQLHelper.dumpAsHex(buffer)
31+
//log.debug("prepared statement response dump is \n{}", dump)
3232

3333
val statementId = Array[Byte]( buffer.readByte(), buffer.readByte(), buffer.readByte(), buffer.readByte() )
3434
val columnsCount = buffer.readUnsignedShort()

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/ConnectionHelper.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.github.mauricio.async.db.mysql
1818

19-
import com.github.mauricio.async.db.util.FutureUtils.await
19+
import com.github.mauricio.async.db.util.FutureUtils.awaitFuture
2020
import com.github.mauricio.async.db._
2121
import com.github.mauricio.async.db.pool.{PoolConfiguration, ConnectionPool}
2222
import com.github.mauricio.async.db.mysql.pool.MySQLConnectionFactory
@@ -110,7 +110,7 @@ trait ConnectionHelper {
110110
try {
111111
fn(pool)
112112
} finally {
113-
await( pool.close )
113+
awaitFuture( pool.close )
114114
}
115115

116116
}
@@ -120,20 +120,20 @@ trait ConnectionHelper {
120120
val connection = new MySQLConnection(this.defaultConfiguration)
121121

122122
try {
123-
await( connection.connect )
123+
awaitFuture( connection.connect )
124124
fn(connection)
125125
} finally {
126-
await( connection.close )
126+
awaitFuture( connection.close )
127127
}
128128

129129
}
130130

131131
def executeQuery( connection : Connection, query : String ) : QueryResult = {
132-
await( connection.sendQuery(query) )
132+
awaitFuture( connection.sendQuery(query) )
133133
}
134134

135135
def executePreparedStatement( connection : Connection, query : String, values : Any * ) : QueryResult = {
136-
await( connection.sendPreparedStatement(query, values) )
136+
awaitFuture( connection.sendPreparedStatement(query, values) )
137137
}
138138

139139
}

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/MySQLConnectionSpec.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.github.mauricio.async.db.mysql
1818

1919
import com.github.mauricio.async.db.Configuration
20-
import com.github.mauricio.async.db.util.FutureUtils.await
20+
import com.github.mauricio.async.db.util.FutureUtils.awaitFuture
2121
import org.specs2.mutable.Specification
2222

2323
class MySQLConnectionSpec extends Specification {
@@ -60,29 +60,29 @@ class MySQLConnectionSpec extends Specification {
6060

6161
withNonConnectedConnection {
6262
connection =>
63-
await(connection.connect) === connection
63+
awaitFuture(connection.connect) === connection
6464
}(configuration)
6565

6666
}
6767

6868
"connect to a MySQL instance without password" in {
6969
withNonConnectedConnection({
7070
connection =>
71-
await(connection.connect) === connection
71+
awaitFuture(connection.connect) === connection
7272
}) (rootConfiguration)
7373
}
7474

7575
"connect to a MySQL instance without a database" in {
7676
withNonConnectedConnection({
7777
connection =>
78-
await(connection.connect) === connection
78+
awaitFuture(connection.connect) === connection
7979
}) (configurationWithoutDatabase)
8080
}
8181

8282
"connect to a MySQL instance without database with password" in {
8383
withNonConnectedConnection({
8484
connection =>
85-
await(connection.connect) === connection
85+
awaitFuture(connection.connect) === connection
8686
}) (configurationWithPasswordWithoutDatabase)
8787
}
8888

@@ -94,7 +94,7 @@ class MySQLConnectionSpec extends Specification {
9494
try {
9595
fn(connection)
9696
} finally {
97-
await(connection.close)
97+
awaitFuture(connection.close)
9898
}
9999

100100

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/PreparedStatementsSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit
2121
import org.joda.time._
2222
import org.specs2.mutable.Specification
2323
import scala.concurrent.duration.Duration
24-
import com.github.mauricio.async.db.util.FutureUtils._
2524
import scala.Some
25+
import org.specs2.execute.Skipped
2626

2727
class PreparedStatementsSpec extends Specification with ConnectionHelper {
2828

@@ -271,7 +271,7 @@ class PreparedStatementsSpec extends Specification with ConnectionHelper {
271271
connection =>
272272

273273
if ( connection.version < MySQLConnection.MicrosecondsVersion ) {
274-
pending(s"this version of MySQL (${connection.version}) does not support microseconds")
274+
skipped(s"this version of MySQL (${connection.version}) does not support microseconds")
275275
} else {
276276
executeQuery(connection, create)
277277
executeQuery(connection, insert)

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/TransactionSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.github.mauricio.async.db.mysql
22

33
import org.specs2.mutable.Specification
44
import com.github.mauricio.async.db.util.ExecutorServiceUtils._
5-
import com.github.mauricio.async.db.util.FutureUtils.await
5+
import com.github.mauricio.async.db.util.FutureUtils.awaitFuture
66

77
class TransactionSpec extends Specification with ConnectionHelper {
88

@@ -21,7 +21,7 @@ class TransactionSpec extends Specification with ConnectionHelper {
2121
.flatMap( r => connection.sendPreparedStatement(this.insert))
2222
}
2323

24-
await(future)
24+
awaitFuture(future)
2525

2626
val result = executePreparedStatement(connection, this.select).rows.get
2727
result.size === 2

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/pool/MySQLConnectionFactorySpec.scala

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.github.mauricio.async.db.mysql.pool
1818

1919
import com.github.mauricio.async.db.mysql.{MySQLConnection, ConnectionHelper}
20-
import com.github.mauricio.async.db.util.FutureUtils.await
20+
import com.github.mauricio.async.db.util.FutureUtils.awaitFuture
2121
import org.specs2.mutable.Specification
2222
import scala.util._
2323
import com.github.mauricio.async.db.exceptions.ConnectionNotConnectedException
@@ -39,28 +39,27 @@ class MySQLConnectionFactorySpec extends Specification with ConnectionHelper {
3939
}
4040

4141
try {
42-
factory.validate(connection) match {
43-
case Failure(e) => ok("connection sucessfully rejected")
44-
case Success(e) => failure("should not have come here")
42+
if (factory.validate(connection).isSuccess) {
43+
throw new IllegalStateException("should not have come here")
4544
}
4645
} finally {
47-
await(connection.close)
46+
awaitFuture(connection.close)
4847
}
4948

50-
49+
ok("connection successfully rejected")
5150
}
5251

5352
"it should take a connection from the pool and the pool should not accept it back if it is broken" in {
5453
withPool {
5554
pool =>
56-
val connection = await(pool.take)
55+
val connection = awaitFuture(pool.take)
5756

5857
pool.inUse.size === 1
5958

60-
await(connection.disconnect)
59+
awaitFuture(connection.disconnect)
61< 10000 /code>60

6261
try {
63-
await(pool.giveBack(connection))
62+
awaitFuture(pool.giveBack(connection))
6463
} catch {
6564
case e: ConnectionNotConnectedException => {
6665
// all good
@@ -79,18 +78,18 @@ class MySQLConnectionFactorySpec extends Specification with ConnectionHelper {
7978
}
8079
}
8180

82-
"fail validation if a connection is disconnected" in {
81+
"fail validation if a connection is disconnected" in {
8382

84-
val connection = factory.create
83+
val connection = factory.create
8584

86-
await(connection.disconnect)
85+
awaitFuture(connection.disconnect)
8786

88-
factory.validate(connection) match {
89-
case Failure(e) => ok("Connection successfully rejected")
90-
case Success(c) => failure("should not have come here")
91-
}
87+
factory.validate(connection) match {
88+
case Failure(e) => ok("Connection successfully rejected")
89+
case Success(c) => failure("should not have come here")
90+
}
9291

93-
}
92+
}
9493

9594
"fail validation if a connection is still waiting for a query" in {
9695
val connection = factory.create
@@ -103,7 +102,7 @@ class MySQLConnectionFactorySpec extends Specification with ConnectionHelper {
103102
case Success(c) => failure("should not have come here")
104103
}
105104

106-
await(connection.close) === connection
105+
awaitFuture(connection.close) === connection
107106
}
108107

109108
"accept a good connection" in {
@@ -114,7 +113,7 @@ class MySQLConnectionFactorySpec extends Specification with ConnectionHelper {
114113
case Failure(e) => failure("should not have come here")
115114
}
116115

117-
await(connection.close) === connection
116+
awaitFuture(connection.close) === connection
118117
}
119118

120119
"test a valid connection and say it is ok" in {
@@ -126,15 +125,15 @@ class MySQLConnectionFactorySpec extends Specification with ConnectionHelper {
126125
case Failure(e) => failure("should not have come here")
127126
}
128127

129-
await(connection.close) === connection
128+
awaitFuture(connection.close) === connection
130129

131130
}
132131

133132
"fail test if a connection is disconnected" in {
134133

135134
val connection = factory.create
136135

137-
await(connection.disconnect)
136+
awaitFuture(connection.disconnect)
138137

139138
factory.test(connection) match {
140139
case Failure(e) => ok("Connection successfully rejected")

postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnectionSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ class PostgreSQLConnectionSpec extends Specification with DatabaseTestHelper {
282282
withHandler(configuration, {
283283
handler =>
284284
executeQuery(handler, "SELECT 0")
285-
failure("should not have come here")
285+
throw new IllegalStateException("should not have come here")
286286
})
287287
} catch {
288288
case e: GenericDatabaseException => {
289289
e.errorMessage.fields(InformationMessage.Routine) === "auth_failed"
290290
}
291291
case e: Exception => {
292-
failure("should not have come here")
292+
throw new IllegalStateException("should not have come here")
293293
}
294294
}
295295

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object Configuration {
4848
val commonVersion = "0.2.9-SNAPSHOT"
4949
val projectScalaVersion = "2.10.3"
5050

51-
val specs2Dependency = "org.specs2" %% "specs2" % "2.0" % "test"
51+
val specs2Dependency = "org.specs2" %% "specs2" % "2.3.4" % "test"
5252
val logbackDependency = "ch.qos.logback" % "logback-classic" % "1.0.13" % "test"
5353

5454
val commonDependencies = Seq(

0 commit comments

Comments
 (0)
0