All Downloads are FREE. Search and download functionalities are using the official Maven repository.

blended.itestsupport.jms.JMSMessageFactory.scala Maven / Gradle / Ivy

Go to download

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)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy