Browse files

Minor clean up

  • Loading branch information...
1 parent 7f79cc0 commit e3c1a0a6267b0a288bccfcac7b62c37070dd0a0c @slandelle slandelle committed Dec 27, 2012
View
120 gatling-app/src/main/scala/com/excilys/ebi/gatling/app/ZincCompiler.scala
@@ -33,61 +33,57 @@ import xsbti.compile.CompileOrder
object ZincCompiler extends Logging {
- val classpathURLs = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs
-
- def setupZincCompiler(): Setup = {
- def jarMatching(regex: String): JFile = {
- val compiledRegex = regex.r
- val jarUrl = classpathURLs
- .filter(url => compiledRegex.findFirstMatchIn(url.toString).isDefined)
- .headOption
- .getOrElse(throw new RuntimeException("Can't find the jar matching " + regex))
+ def apply(sourceDirectory: Directory): Directory = {
- new JFile(jarUrl.toURI)
+ val classpathURLs = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs
+
+ def simulationInputs(sourceDirectory: Directory, binDir: Path) = {
+ val classpath = classpathURLs.map(url => new JFile(url.toURI))
+
+ val sources = sourceDirectory
+ .deepFiles
+ .toList
+ .collect { case file if (file.hasExtension("scala")) => file.jfile }
+
+ def analysisCacheMapEntry(directoryName: String) = (GATLING_HOME / directoryName).jfile -> (binDir / "cache" / directoryName).jfile
+
+ Inputs.inputs(classpath = classpath,
+ sources = sources,
+ classesDirectory = (binDir / "classes").jfile,
+ scalacOptions = Seq("-deprecation"),
+ javacOptions = Nil,
+ analysisCache = Some((binDir / "zincCache").jfile),
+ analysisCacheMap = Map(analysisCacheMapEntry("bin"), analysisCacheMapEntry("conf"), analysisCacheMapEntry("user-files")), // avoids having GATLING_HOME polluted with a "cache" folder
+ forceClean = false,
+ javaOnly = false,
+ compileOrder = CompileOrder.JavaThenScala,
+ outputRelations = None,
+ outputProducts = None)
}
- val scalaCompiler = ClassPath.scalaCompiler.getOrElse(throw new RuntimeException("No Scala compiler available")).jfile
- val scalaLibrary = ClassPath.scalaLibrary.getOrElse(throw new RuntimeException("No Scala library available")).jfile
- val sbtInterfaceSrc: JFile = new JFile(classOf[Compilation].getProtectionDomain.getCodeSource.getLocation.toURI)
- val compilerInterfaceSrc: JFile = jarMatching("""(.*compiler-interface-\d+.\d+.\d+-sources.jar)$""")
-
- Setup.setup(scalaCompiler = scalaCompiler,
- scalaLibrary = scalaLibrary,
- scalaExtra = Nil,
- sbtInterface = sbtInterfaceSrc,
- compilerInterfaceSrc = compilerInterfaceSrc,
- javaHomeDir = None)
- }
-
- def simulationInputs(sourceDirectory: Directory, binDir: Path) = {
- val classpath = classpathURLs.map(url => new JFile(url.toURI))
-
- val sources = sourceDirectory
- .deepFiles
- .toList
- .collect { case file if (file.hasExtension("scala")) => file.jfile }
-
- // avoids having GATLING_HOME polluted with a "cache" folder
- val analysisCacheMap: Map[JFile, JFile] = Map[JFile, JFile](
- (GATLING_HOME / "bin").jfile -> (binDir / "cache" / "bin").jfile,
- (GATLING_HOME / "conf").jfile -> (binDir / "cache" / "conf").jfile,
- (GATLING_HOME / "user-files").jfile -> (binDir / "cache" / "user-files").jfile)
-
- Inputs.inputs(classpath = classpath,
- sources = sources,
- classesDirectory = (binDir / "classes").jfile,
- scalacOptions = Seq("-deprecation"),
- javacOptions = Nil,
- analysisCache = Some((binDir / "zincCache").jfile),
- analysisCacheMap = analysisCacheMap,
- forceClean = false,
- javaOnly = false,
- compileOrder = CompileOrder.JavaThenScala,
- outputRelations = None,
- outputProducts = None)
- }
-
- def apply(sourceDirectory: Directory): Directory = {
+ def setupZincCompiler(): Setup = {
+ def jarMatching(regex: String): JFile = {
+ val compiledRegex = regex.r
+ val jarUrl = classpathURLs
+ .filter(url => compiledRegex.findFirstMatchIn(url.toString).isDefined)
+ .headOption
+ .getOrElse(throw new RuntimeException("Can't find the jar matching " + regex))
+
+ new JFile(jarUrl.toURI)
+ }
+
+ val scalaCompiler = ClassPath.scalaCompiler.getOrElse(throw new RuntimeException("No Scala compiler available")).jfile
+ val scalaLibrary = ClassPath.scalaLibrary.getOrElse(throw new RuntimeException("No Scala library available")).jfile
+ val sbtInterfaceSrc: JFile = new JFile(classOf[Compilation].getProtectionDomain.getCodeSource.getLocation.toURI)
+ val compilerInterfaceSrc: JFile = jarMatching("""(.*compiler-interface-\d+.\d+.\d+-sources.jar)$""")
+
+ Setup.setup(scalaCompiler = scalaCompiler,
+ scalaLibrary = scalaLibrary,
+ scalaExtra = Nil,
+ sbtInterface = sbtInterfaceSrc,
+ compilerInterfaceSrc = compilerInterfaceSrc,
+ javaHomeDir = None)
+ }
// Setup the compiler
val setup = setupZincCompiler
@@ -106,20 +102,10 @@ object ZincCompiler extends Logging {
}
class ZincLogger extends Logger {
- def error(arg: xsbti.F0[String]) {
- logger.error(arg.apply)
- }
- def warn(arg: xsbti.F0[String]) {
- logger.warn(arg.apply)
- }
- def info(arg: xsbti.F0[String]) {
- logger.info(arg.apply)
- }
- def debug(arg: xsbti.F0[String]) {
- logger.debug(arg.apply)
- }
- def trace(arg: xsbti.F0[Throwable]) {
- logger.trace(arg.apply)
- }
+ def error(arg: xsbti.F0[String]) { logger.error(arg.apply) }
+ def warn(arg: xsbti.F0[String]) { logger.warn(arg.apply) }
+ def info(arg: xsbti.F0[String]) { logger.info(arg.apply) }
+ def debug(arg: xsbti.F0[String]) { logger.debug(arg.apply) }
+ def trace(arg: xsbti.F0[Throwable]) { logger.trace(arg.apply) }
}
}
View
4 gatling-app/src/test/scala/com/excilys/ebi/gatling/app/test/CompileTest.scala
@@ -46,8 +46,8 @@ object CompileTest extends Simulation {
.userAgentHeader("Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19")
val httpConfToVerifyUserProvidedInfoExtractors = httpConfig
- .requestInfoExtractor((request: Request) => { List.empty })
- .responseInfoExtractor((response: Response) => { List.empty })
+ .requestInfoExtractor(request => List.empty)
+ .responseInfoExtractor(response => List.empty)
val usersInformation = tsv("user_information.tsv")
View
4 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/Predef.scala
@@ -36,7 +36,7 @@ object Predef {
implicit def extractorCheckBuilder2MatcherCheckBuilder[C <: Check[R, XC], R, XC, X](extractorCheckBuilder: ExtractorCheckBuilder[C, R, XC, X]) = extractorCheckBuilder.find
implicit def extractorCheckBuilder2CheckBuilder[C <: Check[R, XC], R, XC, X](extractorCheckBuilder: ExtractorCheckBuilder[C, R, XC, X]) = extractorCheckBuilder.find.exists
implicit def extractorCheckBuilder2Check[C <: Check[R, XC], R, XC, X](extractorCheckBuilder: ExtractorCheckBuilder[C, R, XC, X]) = extractorCheckBuilder.find.exists.build
- implicit def stringMap2ExpressionMap(map: Map[String, Any]): Map[String, Expression[Any]] = map.map { entry =>
+ implicit def map2ExpressionMap(map: Map[String, Any]): Map[String, Expression[Any]] = map.map { entry =>
entry._2 match {
case string: String => entry._1 -> Expression[String](string)
case any => entry._1 -> any.success
@@ -70,5 +70,5 @@ object Predef {
val assertions = new AssertionBuilder
- implicit def string2path: String => Path = Path.string2path
+ implicit def string2path(string: String) = Path.string2path(string)
}
View
3 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/Expression.scala
@@ -92,13 +92,12 @@ object Expression {
ELParser(elString) match {
case List(StaticPart(string)) => (session: Session) => TypeHelper.as[T](string)
case List(dynamicPart) => dynamicPart.resolve _ andThen (_.flatMap(TypeHelper.as[T](_)))
- case parts => (session: Session) => {
+ case parts => (session: Session) =>
val resolvedString = parts.map(_.resolve(session))
.sequence[({ type l[a] = Validation[String, a] })#l, Any]
.map(_.mkString)
resolvedString.flatMap(TypeHelper.as[T](_))
- }
}
}
}
View
15 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/Session.scala
@@ -49,35 +49,20 @@ object Session extends Logging {
class Session(val scenarioName: String, val userId: Int, attributes: Map[String, Any] = Map.empty) {
def apply(name: String) = attributes(name)
- @deprecated("Use apply instead, will be removed in 1.5.0", "1.4.0")
- def getAttribute(key: String): Any = apply(key)
-
- @deprecated("Use apply(key).asInstanceOf[T] instead, will be removed in 1.5.0", "1.4.0")
- def getTypedAttribute[T](key: String): T = attributes(key).asInstanceOf[T]
def get(key: String): Option[Any] = attributes.get(key)
def getAs[T](key: String): Option[T] = attributes.get(key).map(_.asInstanceOf[T])
- @deprecated("Use getAs instead, will be removed in 1.5.0", "1.4.0")
- def getAttributeAsOption[T](key: String): Option[T] = getAs(key)
def safeGetAs[T: ClassManifest](key: String): Validation[String, T] = attributes.get(key).map(TypeHelper.as[T](_)).getOrElse(undefinedSessionAttributeMessage(key).failure[T])
def set(attributes: Map[String, Any]) = new Session(scenarioName, userId, attributes ++ attributes)
- @deprecated("Use set instead, will be removed in 1.5.0", "1.4.0")
- def setAttributes(attributes: Map[String, Any]) = set(attributes)
def set(key: String, value: Any) = new Session(scenarioName, userId, attributes + (key -> value))
- @deprecated("Use set instead, will be removed in 1.5.0", "1.4.0")
- def setAttribute(key: String, value: Any) = set(key, value)
def remove(key: String) = if (contains(key)) new Session(scenarioName, userId, attributes - key) else this
- @deprecated("Use remove instead, will be removed in 1.5.0", "1.4.0")
- def removeAttribute(key: String) = remove(key)
def contains(attributeKey: String) = attributes.contains(attributeKey)
- @deprecated("Use contains instead, will be removed in 1.5.0", "1.4.0")
- def isAttributeDefined(attributeKey: String) = contains(attributeKey)
def setFailed: Session = set(Session.FAILED_KEY, "")

0 comments on commit e3c1a0a

Please sign in to comment.