Permalink
Browse files

Minor Code cleanups

  • Loading branch information...
atooni committed Dec 4, 2018
1 parent 70a631c commit 46c7d0089324174cc664b4106327b070e4792f1e
@@ -130,7 +130,7 @@ class ProxyRouteSpec extends FreeSpec with ScalatestRouteTest {
}
}
"Live Tests - you need to have internet access - enable with env variabe TEST_ONLINE=true" - {
"Live Tests - you need to have internet access - enable with env variable TEST_ONLINE=true" - {
def whenOnline(test: => Unit): Unit = System.getenv("TEST_ONLINE") match {
case null | "false" | "0" => pending
@@ -160,7 +160,6 @@ class ProxyRouteSpec extends FreeSpec with ScalatestRouteTest {
assert(handled === true)
assert(entityAs[String].contains("SBuild - the magic free but powerful build tool"))
}
}
"live test against http://heise.de with redirectCount 0" in whenOnline {
@@ -124,6 +124,6 @@ class SimpleIdAwareConnectionFactory(
pingEnabled = false
), None
) {
override def toString: String = s"${getClass().getSimpleName()}($vendor:$provider:$clientId)"
override protected def createHolder(cfg: ConnectionConfig) : ConnectionHolder = new FactoryConfigHolder(cfg, cf)
}
@@ -20,22 +20,27 @@ case class DispatcherFanout(
/*-------------------------------------------------------------------------------------------------*/
private[builder] val funFanoutOutbound : FlowEnvelope => Try[Seq[(OutboundRouteConfig, FlowEnvelope)]] = { env =>
Try {
val fanouts = bs.withContextObject[ResourceTypeConfig, Seq[(OutboundRouteConfig, FlowEnvelope)]](bs.rtConfigKey, env) { rtCfg: ResourceTypeConfig =>
Try {
rtCfg.outbound.map { ob =>
val obEnv =
env
.withContextObject(bs.outboundCfgKey, ob)
.withHeader(bs.headerConfig.headerBranch, ob.id).get
(ob, outboundMsg(ob)(obEnv).get)
}
bs.withContextObject[ResourceTypeConfig, Seq[(OutboundRouteConfig, FlowEnvelope)]](bs.rtConfigKey, env) { rtCfg: ResourceTypeConfig =>
Try {
rtCfg.outbound.map { ob =>
val obEnv =
env
.withContextObject(bs.outboundCfgKey, ob)
.withHeader(bs.headerConfig.headerBranch, ob.id).get
(ob, outboundMsg(ob)(obEnv).get)
}
}
fanouts.right.get
} match {
case Right(s) => Success(s)
case Left(t) =>
bs.streamLogger.error(s"Exception in fan out step [${env.id}]")
t.exception.foreach { e =>
bs.streamLogger.error(e)(e.getMessage())
}
Failure(t.exception.getOrElse(new Exception("Undexpected exception")))
}
}
private[builder] lazy val fanoutOutbound = FlowProcessor.transform[Seq[(OutboundRouteConfig, FlowEnvelope)]]("fanoutOutbound", bs.streamLogger)(funFanoutOutbound)
/*-------------------------------------------------------------------------------------------------*/
@@ -8,18 +8,6 @@ object CommonSettings {
val m2Repo = "file://" + System.getProperty("maven.repo.local", System.getProperty("user.home") + "/.m2/repository")
def hasForkAnnotation(clazz: AnalyzedClass): Boolean = {
val c = clazz.api().classApi()
c.annotations.exists { ann =>
ann.base() match {
case proj: Projection if proj.id() == "RequiresForkedJVM" => true
case _ => false
}
}
}
def apply() : Seq[Def.Setting[_]] = Seq(
organization := "de.wayofquality.blended",
homepage := Some(url("https://github.com/woq-blended/blended")),
@@ -1,4 +1,3 @@
import CommonSettings.hasForkAnnotation
import de.wayofquality.sbt.testlogconfig.TestLogConfig
import de.wayofquality.sbt.testlogconfig.TestLogConfig.autoImport._
import com.typesafe.sbt.osgi.SbtOsgi
@@ -8,6 +7,7 @@ import sbt.Tests.{Group, SubProcess}
import sbt._
import sbt.internal.inc.Analysis
import xerial.sbt.Sonatype
import xsbti.api.{AnalyzedClass, Projection}
trait ProjectFactory {
val project: Project
@@ -64,6 +64,18 @@ class ProjectSettings(
def sbtBundle: Option[BlendedBundle] = if (osgi) Some(bundle) else None
private def hasForkAnnotation(clazz: AnalyzedClass): Boolean = {
val c = clazz.api().classApi()
c.annotations.exists { ann =>
ann.base() match {
case proj: Projection if proj.id() == "RequiresForkedJVM" => true
case _ => false
}
}
}
def defaultSettings: Seq[Setting[_]] = CommonSettings() ++ {
val osgiSettings: Seq[Setting[_]] = sbtBundle.toSeq.flatMap(_.osgiSettings)

0 comments on commit 46c7d00

Please sign in to comment.