Skip to content

Commit

Permalink
Added Fork Per Spec to sbt settings and refactored tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
atooni committed Nov 10, 2018
1 parent 999c6ff commit 0ecd8d1
Show file tree
Hide file tree
Showing 47 changed files with 912 additions and 883 deletions.
Expand Up @@ -120,14 +120,14 @@ class BrokerControlActor(brokerCfg: BrokerConfig, cfg: OSGIActorConfig, sslCtxt:
val actor = context.self

// TODO: set Datadirectories from Code ??
val f = Future {
b.setBrokerName(brokerCfg.brokerName)
b.setStartAsync(false)
b.start()
b.waitUntilStarted()
log.info(s"ActiveMQ broker [${brokerCfg.brokerName}] started successfully.")
actor ! BrokerControlActor.BrokerStarted(uuid)
}(context.system.dispatcher)
b.setBrokerName(brokerCfg.brokerName)
b.setStartAsync(false)
b.setSchedulerSupport(true)
b.start()
b.waitUntilStarted()
log.info(s"ActiveMQ broker [${brokerCfg.brokerName}] started successfully.")
actor ! BrokerControlActor.BrokerStarted(uuid)

} catch {
case NonFatal(t) =>
log.warn(t)(s"Error starting ActiveMQ broker [${brokerCfg.brokerName}]")
Expand Down
Expand Up @@ -5,34 +5,34 @@ import java.io.File
import blended.activemq.brokerstarter.BrokerActivator
import blended.akka.internal.BlendedAkkaActivator
import blended.jms.utils.IdAwareConnectionFactory
import blended.testsupport.BlendedTestSupport
import blended.testsupport.pojosr.{PojoSrTestHelper, SimplePojosrBlendedContainer}
import blended.testsupport.scalatest.LoggingFreeSpec
import blended.testsupport.{BlendedTestSupport, RequiresForkedJVM}
import blended.testsupport.pojosr.{PojoSrTestHelper, SimplePojoContainerSpec}
import blended.testsupport.scalatest.LoggingFreeSpecLike
import org.osgi.framework.BundleActivator
import org.scalatest.Matchers

import scala.concurrent.duration._

class BrokerActivatorSpec extends LoggingFreeSpec
with SimplePojosrBlendedContainer
@RequiresForkedJVM
class BrokerActivatorSpec extends SimplePojoContainerSpec
with LoggingFreeSpecLike
with PojoSrTestHelper
with Matchers {

private val baseDir = new File(BlendedTestSupport.projectTestOutput, "container").getAbsolutePath()
override def baseDir: String = new File(BlendedTestSupport.projectTestOutput, "container").getAbsolutePath()

override def bundles: Seq[(String, BundleActivator)] = Seq(
"blended.akka" -> new BlendedAkkaActivator(),
"blended.activemq.brokerstarter" -> new BrokerActivator()
)

"The BrokerActivator should" - {

"start the configured brokers correctly" in {
withSimpleBlendedContainer(baseDir) { sr =>
withStartedBundles(sr)(Seq(
"blended.akka" -> Some(() => new BlendedAkkaActivator()),
"blended.activemq.brokerstarter" -> Some(() => new BrokerActivator())
)) { sr =>

implicit val timeout = 10.seconds
waitOnService[IdAwareConnectionFactory](sr)(Some("(&(vendor=activemq)(provider=blended))")) should be (defined)
waitOnService[IdAwareConnectionFactory](sr)(Some("(&(vendor=activemq)(provider=broker2))")) should be (defined)
}
}
implicit val timeout = 10.seconds
waitOnService[IdAwareConnectionFactory](registry)(Some("(&(vendor=activemq)(provider=blended))")) should be (defined)
waitOnService[IdAwareConnectionFactory](registry)(Some("(&(vendor=activemq)(provider=broker2))")) should be (defined)
}
}

}
@@ -1,12 +1,13 @@
package blended.akka.http.internal

import scala.util.Try
import java.io.File

import scala.util.Try
import org.scalatest.FreeSpec

import akka.http.scaladsl.testkit.ScalatestRouteTest
import blended.akka.http.HttpContext
import blended.akka.http.SimpleHttpContext
import blended.testsupport.BlendedTestSupport
import blended.testsupport.pojosr.PojoSrTestHelper
import domino.DominoActivator

Expand All @@ -15,6 +16,8 @@ class RouteProviderSpec
with ScalatestRouteTest
with PojoSrTestHelper {

override def baseDir: String = new File(System.getProperty(BlendedTestSupport.projectTestOutput)).getAbsolutePath()

val routeProvider = new RouteProvider()
val route = routeProvider.dynamicRoute

Expand All @@ -38,7 +41,7 @@ class RouteProviderSpec
"Inside a dynamic (OSGi) environment, the RouteProvider should" - {

"handle comming and going HttpContext registrations" in {
withPojoServiceRegistry { sr =>
withPojoServiceRegistry { sr => Try {

val serviceBundle = new DominoActivator() {
whenBundleActive {
Expand Down Expand Up @@ -88,10 +91,10 @@ class RouteProviderSpec
Try { routeBundle.stop(bundleContext) }
}
}
}
}}

"handle HttpContext registrations with prefixes containing slashes" in {
withPojoServiceRegistry { sr =>
withPojoServiceRegistry { sr => Try {

val serviceBundle = new DominoActivator() {
whenBundleActive {
Expand Down Expand Up @@ -141,8 +144,8 @@ class RouteProviderSpec
Try { routeBundle.stop(bundleContext) }
}
}
}
}}

}

}
}
12 changes: 7 additions & 5 deletions blended.jms.bridge/src/test/resources/container/etc/broker.amq
Expand Up @@ -58,24 +58,26 @@
</amq:policyEntry>
</amq:policyEntries>
</amq:policyMap>
</amq:destinationPolicy>

<amq:plugins>
<amq:redeliveryPlugin>
<amq:redeliveryPolicyMap>
<amq:redeliveryPolicyEntries>
<amq:redeliveryPolicyMap>
<amq:redeliveryPolicyEntries />
<amq:defaultEntry>
<amq:reliveryPolicy
<amq:redeliveryPolicy
maximumRedeliveries = "5"
initialRedeliveryDelay = "5000"
maximumRedeliveryDelay = "120000"
backOffMultiplier = "5"
useExponentialBackOff = "true"
/>
</amq:defaultEntry>
</amq:redeliveryPolicyEntries>
</amq:redeliveryPolicyMap>
</amq:redeliveryPolicyMap>
</amq:redeliveryPlugin>

</amq:destinationPolicy>
</amq:plugins>

</amq:broker>

Expand Down
13 changes: 7 additions & 6 deletions blended.jms.bridge/src/test/resources/container/etc/broker2.amq
Expand Up @@ -58,25 +58,26 @@
</amq:policyEntry>
</amq:policyEntries>
</amq:policyMap>
</amq:destinationPolicy>

<amq:plugins>
<amq:redeliveryPlugin>
<amq:redeliveryPolicyMap>
<amq:redeliveryPolicyEntries>
<amq:redeliveryPolicyMap>
<amq:redeliveryPolicyEntries />
<amq:defaultEntry>
<amq:reliveryPolicy
<amq:redeliveryPolicy
maximumRedeliveries = "5"
initialRedeliveryDelay = "5000"
maximumRedeliveryDelay = "120000"
backOffMultiplier = "5"
useExponentialBackOff = "true"
/>
</amq:defaultEntry>
</amq:redeliveryPolicyEntries>
</amq:redeliveryPolicyMap>
</amq:redeliveryPolicyMap>
</amq:redeliveryPlugin>


</amq:destinationPolicy>
</amq:plugins>

</amq:broker>

Expand Down

0 comments on commit 0ecd8d1

Please sign in to comment.