blended.itestsupport.jms.JMSMessageFactory.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blended.itestsupport Show documentation
Show all versions of blended.itestsupport Show documentation
Define an integration test API for collaborating blended container(s) using docker as a runtime
for the container(s) under test and an Akka based Camel framework to perform the integration tests
as pure blackbox tests. Container(s) may be prestarted and discovered (for execution speed) or
started by the integration test (for reproducability).
The newest version!
package blended.itestsupport.jms
import javax.jms.{Message, Session}
import blended.jms.utils.JMSMessageFactory
import scala.util.Random
class FixedSizeMessageFactory(size: Int) extends JMSMessageFactory[Unit] {
private val rnd = new Random()
private lazy val body = {
val result = new Array[Byte](size)
rnd.nextBytes(result)
result
}
override def createMessage(session: Session, content: Unit): Message = {
val m = session.createBytesMessage()
m.writeBytes(body)
m
}
}
class TextMessageFactory extends JMSMessageFactory[String] {
override def createMessage(session: Session, content: String) = {
session.createTextMessage(content)
}
}