alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (TestOptions.scala)

This example Akka source code file (TestOptions.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to akka.io; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

apache, boolean, defaultcompositeoption, file, karaf, list, none, option, paxoption, testoptions

The TestOptions.scala Akka example source code

package akka.sample.osgi.test

import org.ops4j.pax.exam.CoreOptions._
import org.ops4j.pax.exam.options.DefaultCompositeOption
import org.ops4j.pax.exam.{ Option => PaxOption }
import org.apache.karaf.tooling.exam.options.LogLevelOption
import org.apache.karaf.tooling.exam.options.KarafDistributionOption._
import java.io.File

/**
 * Re-usable PAX Exam option groups.
 */
object TestOptions {

  val scalaDepVersion = System.getProperty("scala.dep.version")

  def karafOptions(useDeployFolder: Boolean = false, extractInTargetFolder: Boolean = true): PaxOption = {
    val kdc = karafDistributionConfiguration.frameworkUrl(
      maven.groupId("org.apache.karaf").artifactId("apache-karaf").`type`("zip").version(System.getProperty("karaf.version")))
      .karafVersion(System.getProperty("karaf.version")).name("Apache Karaf").useDeployFolder(useDeployFolder)

    new DefaultCompositeOption(if (extractInTargetFolder) kdc.unpackDirectory(new File("target/paxexam/unpack/")) else kdc,
      editConfigurationFilePut("etc/config.properties", "karaf.framework", "equinox"))
  }

  def testBundles(): PaxOption = {
    new DefaultCompositeOption(
      mavenBundle("com.typesafe.akka", "akka-testkit_%s".format(scalaDepVersion)).versionAsInProject,
      mavenBundle("org.scalatest", "scalatest_%s".format(scalaDepVersion)).versionAsInProject,
      junitBundles)
  }

  def debugOptions(level: LogLevelOption.LogLevel = LogLevelOption.LogLevel.INFO, debugPort: Option[Int] = None): PaxOption = {
    val options: List[PaxOption] = List(logLevel(level), configureConsole().startLocalConsole(), configureConsole().startRemoteShell()) ++
      debugPort.toList.map(p => debugConfiguration(String.valueOf(p), true))
    new DefaultCompositeOption(options: _*)
  }

  def karafOptionsWithTestBundles(useDeployFolder: Boolean = false, extractInTargetFolder: Boolean = true): PaxOption = {
    new DefaultCompositeOption(
      karafOptions(useDeployFolder, extractInTargetFolder),
      testBundles())
  }

  def featureDiningHakkers(): PaxOption = {
    akkaFeature("dining-hakker")
  }

  def akkaFeature(feature: String): PaxOption = {
    scanFeatures(maven.groupId("com.typesafe.akka.akka-sample-osgi-dining-hakkers")
      .artifactId("akka-sample-osgi-dining-hakkers").`type`("xml").classifier("features")
      .version(System.getProperty("project.version")), feature)
  }

}

Other Akka source code examples

Here is a short list of links related to this Akka TestOptions.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.