Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91282444
MetaDataServiceTest.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 15:44
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Nov 11, 15:44 (2 d)
Engine
blob
Format
Raw Data
Handle
22234355
Attached To
R2664 SHRINE MedCo Fork
MetaDataServiceTest.scala
View Options
import
akka.actor.ActorRefFactory
import
org.json4s.
{
DefaultFormats
,
DefaultJsonFormats
}
import
org.junit.runner.RunWith
import
org.scalatest.FlatSpec
import
org.scalatest.junit.JUnitRunner
import
org.json4s.native.JsonMethods.parse
import
spray.testkit.ScalatestRouteTest
@RunWith
(
classOf
[
JUnitRunner
])
class
MetaDataServiceTest
extends
FlatSpec
with
ScalatestRouteTest
with
MetaDataService
{
override
def
actorRefFactory
:
ActorRefFactory
=
system
import
scala.concurrent.duration._
implicit
val
routeTestTimeout
=
RouteTestTimeout
(
10.
seconds
)
import
spray.http.StatusCodes._
"MetaDataService"
should
"return an OK and pong for a ping"
in
{
Get
(
s
"/ping"
)
~>
route
~>
check
{
implicit
val
formats
=
DefaultFormats
val
result
=
new
String
(
body
.
data
.
toByteArray
)
assertResult
(
OK
)(
status
)
assertResult
(
result
)(
"pong"
)
}
}
"MetaDataService"
should
"return an OK and pong for a data"
in
{
Get
(
s
"/data?key=ping"
)
~>
route
~>
check
{
implicit
val
formats
=
DefaultFormats
val
result
=
new
String
(
body
.
data
.
toByteArray
)
assertResult
(
OK
)(
status
)
assertResult
(
result
)(
"\"pong\""
)
}
}
"MetaDataService"
should
"return an OK for all data"
in
{
Get
(
s
"/data"
)
~>
route
~>
check
{
implicit
val
formats
=
DefaultFormats
val
result
=
parse
(
new
String
(
body
.
data
.
toByteArray
))
assertResult
(
OK
)(
status
)
}
}
"MetaDataService"
should
"return an Ok and a list for a data"
in
{
Get
(
"/data?key=list"
)
~>
route
~>
check
{
implicit
val
formats
=
DefaultFormats
val
result
=
new
String
(
body
.
data
.
toByteArray
)
assertResult
(
OK
)(
status
)
assertResult
(
parse
(
result
).
extract
[
List
[
String
]])(
Seq
(
"list"
,
"list"
,
"list"
))
}
}
}
Event Timeline
Log In to Comment