Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added activator test for blended.updater to test status quo
- Loading branch information
Showing
5 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
12 changes: 12 additions & 0 deletions
12
blended.updater/src/test/scala/blended/launcher/TestBrandingPropsMutator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
blended.updater/src/test/scala/blended/updater/internal/BlendedUpdaterActivatorSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}") | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters