diff --git a/blended.mgmt.agent/src/test/scala/blended/mgmt/agent/internal/MgmtAgentActivatorSpec.scala b/blended.mgmt.agent/src/test/scala/blended/mgmt/agent/internal/MgmtAgentActivatorSpec.scala index 259f825d1..c9c0d1729 100644 --- a/blended.mgmt.agent/src/test/scala/blended/mgmt/agent/internal/MgmtAgentActivatorSpec.scala +++ b/blended.mgmt.agent/src/test/scala/blended/mgmt/agent/internal/MgmtAgentActivatorSpec.scala @@ -18,16 +18,17 @@ class MgmtAgentActivatorSpec extends SimplePojoContainerSpec with PojoSrTestHelper with Matchers { + val akkaBundleName = classOf[BlendedAkkaActivator].getPackage().getName().replaceAll("[.]internal", "") + val bundleName = classOf[MgmtAgentActivator].getPackage().getName().replaceAll("[.]internal", "") + override def bundles : Seq[(String, BundleActivator)] = Seq( - "blended.akka" -> new BlendedAkkaActivator(), - "blended.mgmt.agent" -> new MgmtAgentActivator() + akkaBundleName -> new BlendedAkkaActivator(), + bundleName -> new MgmtAgentActivator() ) override def baseDir : String = new File(BlendedTestSupport.projectTestOutput, "container").getAbsolutePath() - val bundleName = classOf[MgmtAgentActivator].getPackage().getName().replaceAll("[.]internal", "") - - s"The ${bundleName}" - { + s"The bundle ${bundleName}" - { "should register a MgmtReporter actor into the Akka system" in { val actorSystem = mandatoryService[ActorSystem](registry, None) diff --git a/blended.updater/src/test/resources/container/etc/application.conf b/blended.updater/src/test/resources/container/etc/application.conf new file mode 100644 index 000000000..e69de29bb diff --git a/blended.updater/src/test/scala/blended/launcher/TestBrandingPropsMutator.scala b/blended.updater/src/test/scala/blended/launcher/TestBrandingPropsMutator.scala new file mode 100644 index 000000000..16dcbb085 --- /dev/null +++ b/blended.updater/src/test/scala/blended/launcher/TestBrandingPropsMutator.scala @@ -0,0 +1,12 @@ +package blended.launcher +import java.util.Properties + +object TestBrandingPropsMutator { + + def setBrandingProperties(properties: Map[String, String]) = { + val props = new Properties() + properties.foreach { case (k, v) => props.put(k, v) } + BrandingProperties.setLastBrandingProperties(props) + } + +} diff --git a/blended.updater/src/test/scala/blended/updater/internal/BlendedUpdaterActivatorSpec.scala b/blended.updater/src/test/scala/blended/updater/internal/BlendedUpdaterActivatorSpec.scala new file mode 100644 index 000000000..5f28ba07f --- /dev/null +++ b/blended.updater/src/test/scala/blended/updater/internal/BlendedUpdaterActivatorSpec.scala @@ -0,0 +1,65 @@ +package blended.updater.internal + +import java.io.File + +import scala.concurrent.Await +import scala.concurrent.duration._ +import scala.util.Try + +import akka.actor.{ActorSelection, ActorSystem} +import blended.akka.internal.BlendedAkkaActivator +import blended.launcher.TestBrandingPropsMutator +import blended.testsupport.BlendedTestSupport +import blended.testsupport.pojosr.{PojoSrTestHelper, SimplePojoContainerSpec} +import blended.testsupport.scalatest.LoggingFreeSpecLike +import blended.updater.config.Profile +import org.osgi.framework.BundleActivator + +class BlendedUpdaterActivatorSpec extends SimplePojoContainerSpec with LoggingFreeSpecLike with PojoSrTestHelper { + + override def baseDir: String = new File(BlendedTestSupport.projectTestOutput, "container").getAbsolutePath() + + val akkaBundleName = classOf[BlendedAkkaActivator].getPackage().getName().replaceAll("[.]internal", "") + val bundleName = classOf[BlendedUpdaterActivator].getPackage().getName().replaceAll("[.]internal", "") + + override def bundles: Seq[(String, BundleActivator)] = Seq( + akkaBundleName -> new BlendedAkkaActivator() +// bundleName -> new BlendedUpdaterActivator() + ) + + s"The bundle ${bundleName}" - { + "in an non-updateable environment" - { + "should fail a bundle start" in { + val fail = withStartedBundle(registry)(bundleName, new BlendedUpdaterActivator()) { _ => + Try { () } + } + assert(fail.isFailure) + } + } + "in an updateable environment" - { + + "should register a bundle actor into the Akka system" in { + val actorSystem = mandatoryService[ActorSystem](registry, None) + + val sel: ActorSelection = actorSystem.actorSelection(s"/user/${bundleName}") + val shouldFail = Await.ready(sel.resolveOne(1.second), 2.seconds) + assert(shouldFail.isCompleted && shouldFail.value.get.isFailure) + + TestBrandingPropsMutator.setBrandingProperties( + Map( + Profile.Properties.PROFILE_NAME -> "test", + Profile.Properties.PROFILE_VERSION -> "1.0", + Profile.Properties.PROFILES_BASE_DIR -> (baseDir + "/profile") + )) + val result = withStartedBundle(registry)(bundleName, new BlendedUpdaterActivator()) { _ => + Try { + val sel: ActorSelection = actorSystem.actorSelection(s"/user/${bundleName}") + Await.result(sel.resolveOne(1.second), 2.seconds) + } + } + assert(result.isSuccess, s"But was: ${result}") + } + } + } + +} diff --git a/build.sc b/build.sc index edbaf5ca5..f21442e92 100644 --- a/build.sc +++ b/build.sc @@ -1777,7 +1777,9 @@ class BlendedCross(crossScalaVersion: String) extends GenIdeaModule { blended => deps.mockitoAll )} override def moduleDeps: Seq[JavaModule] = super.moduleDeps ++ Seq( - blended.testsupport + blended.testsupport, + blended.testsupport.pojosr, + blended.akka ) }