diff --git a/simulator/kompics-scala-simulator.sbt b/simulator/kompics-scala-simulator.sbt index 492a5b1..6220492 100644 --- a/simulator/kompics-scala-simulator.sbt +++ b/simulator/kompics-scala-simulator.sbt @@ -2,7 +2,7 @@ name := "Kompics-Scala-Simulator" organization := "se.sics.kompics" -version := "1.0.2" +version := "1.1.0-SNAPSHOT" scalaVersion := "2.12.8" @@ -10,15 +10,17 @@ crossScalaVersions := Seq("2.11.12", "2.12.8") scalacOptions ++= Seq("-deprecation","-feature") +val kompicsV = "1.1.0-SNAPSHOT"; + resolvers += Resolver.mavenLocal resolvers += Resolver.jcenterRepo resolvers += Resolver.bintrayRepo("kompics", "Maven") -libraryDependencies += "se.sics.kompics" %% "kompics-scala" % "1.0.1" -libraryDependencies += "se.sics.kompics.simulator" % "core" % "1.0.1" +libraryDependencies += "se.sics.kompics" %% "kompics-scala" % kompicsV +libraryDependencies += "se.sics.kompics.simulator" % "core" % kompicsV libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value -libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.+" -libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.+" % "test" +libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5" +libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test" libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.+" libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.+" % "test" diff --git a/simulator/src/main/scala/se/sics/kompics/sl/simulator/Op.scala b/simulator/src/main/scala/se/sics/kompics/sl/simulator/Op.scala index 8d34cca..d690b75 100644 --- a/simulator/src/main/scala/se/sics/kompics/sl/simulator/Op.scala +++ b/simulator/src/main/scala/se/sics/kompics/sl/simulator/Op.scala @@ -5,46 +5,45 @@ import se.sics.kompics.simulator.adaptor._ object Op { - class FunctionOperation[E <: KompicsEvent](generator: Unit => E) extends Operation[E] { - override def generate(): E = { - generator(()); - } + class FunctionOperation[E <: KompicsEvent](generator: Unit => E) extends Operation[E] { + override def generate(): E = { + generator(()); } - class FunctionOperation1[E <: KompicsEvent, N <: Number](generator: N => E) extends Operation1[E, N] { - override def generate(n: N): E = { - generator(n); - } + } + class FunctionOperation1[E <: KompicsEvent, N <: Number](generator: N => E) extends Operation1[E, N] { + override def generate(n: N): E = { + generator(n); } - class FunctionOperation2[E <: KompicsEvent, N <: Number, N2 <: Number](generator: (N, N2) => E) extends Operation2[E, N, N2] { - override def generate(n: N, n2: N2): E = { - generator(n, n2); - } + } + class FunctionOperation2[E <: KompicsEvent, N <: Number, N2 <: Number](generator: (N, N2) => E) extends Operation2[E, N, N2] { + override def generate(n: N, n2: N2): E = { + generator(n, n2); } + } - class FunctionOperation3[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number](generator: (N, N2, N3) => E) extends Operation3[E, N, N2, N3] { - override def generate(n: N, n2: N2, n3: N3): E = { - generator(n, n2, n3); - } + class FunctionOperation3[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number](generator: (N, N2, N3) => E) extends Operation3[E, N, N2, N3] { + override def generate(n: N, n2: N2, n3: N3): E = { + generator(n, n2, n3); } + } - class FunctionOperation4[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number](generator: (N, N2, N3, N4) => E) extends Operation4[E, N, N2, N3, N4] { - override def generate(n: N, n2: N2, n3: N3, n4: N4): E = { - generator(n, n2, n3, n4); - } + class FunctionOperation4[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number](generator: (N, N2, N3, N4) => E) extends Operation4[E, N, N2, N3, N4] { + override def generate(n: N, n2: N2, n3: N3, n4: N4): E = { + generator(n, n2, n3, n4); } + } - class FunctionOperation5[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number, N5 <: Number](generator: (N, N2, N3, N4, N5) => E) extends Operation5[E, N, N2, N3, N4, N5] { - override def generate(n: N, n2: N2, n3: N3, n4: N4, n5: N5): E = { - generator(n, n2, n3, n4, n5); - } + class FunctionOperation5[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number, N5 <: Number](generator: (N, N2, N3, N4, N5) => E) extends Operation5[E, N, N2, N3, N4, N5] { + override def generate(n: N, n2: N2, n3: N3, n4: N4, n5: N5): E = { + generator(n, n2, n3, n4, n5); } - - - def apply[E <: KompicsEvent](generator: Unit => E): Operation[E] = new FunctionOperation(generator) - def apply[E <: KompicsEvent, N <: Number](generator: N => E): Operation1[E, N] = new FunctionOperation1(generator) - def apply[E <: KompicsEvent, N <: Number, N2 <: Number](generator: (N, N2) => E): Operation2[E, N, N2] = new FunctionOperation2(generator) - def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number](generator: (N, N2, N3) => E): Operation3[E, N, N2, N3] = new FunctionOperation3(generator) - def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number](generator: (N, N2, N3, N4) => E): Operation4[E, N, N2, N3, N4] = new FunctionOperation4(generator) - def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number, N5 <: Number](generator: (N, N2, N3, N4, N5) => E): Operation5[E, N, N2, N3, N4, N5] = new FunctionOperation5(generator) + } + + def apply[E <: KompicsEvent](generator: Unit => E): Operation[E] = new FunctionOperation(generator) + def apply[E <: KompicsEvent, N <: Number](generator: N => E): Operation1[E, N] = new FunctionOperation1(generator) + def apply[E <: KompicsEvent, N <: Number, N2 <: Number](generator: (N, N2) => E): Operation2[E, N, N2] = new FunctionOperation2(generator) + def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number](generator: (N, N2, N3) => E): Operation3[E, N, N2, N3] = new FunctionOperation3(generator) + def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number](generator: (N, N2, N3, N4) => E): Operation4[E, N, N2, N3, N4] = new FunctionOperation4(generator) + def apply[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number, N5 <: Number](generator: (N, N2, N3, N4, N5) => E): Operation5[E, N, N2, N3, N4, N5] = new FunctionOperation5(generator) } diff --git a/simulator/src/test/scala/se/sics/kompics/sl/simulator/BasicTestSuite.scala b/simulator/src/test/scala/se/sics/kompics/sl/simulator/BasicTestSuite.scala index caa9fbb..029d867 100644 --- a/simulator/src/test/scala/se/sics/kompics/sl/simulator/BasicTestSuite.scala +++ b/simulator/src/test/scala/se/sics/kompics/sl/simulator/BasicTestSuite.scala @@ -1,23 +1,23 @@ /** - * This file is part of the Kompics component model runtime. - * - * Copyright (C) 2009 Swedish Institute of Computer Science (SICS) - * Copyright (C) 2009 Royal Institute of Technology (KTH) - * - * Kompics is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + * This file is part of the Kompics component model runtime. + * + * Copyright (C) 2009 Swedish Institute of Computer Science (SICS) + * Copyright (C) 2009 Royal Institute of Technology (KTH) + * + * Kompics is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ package se.sics.kompics.sl.simulator import org.scalatest._ @@ -26,7 +26,7 @@ import se.sics.kompics.sl._ import se.sics.kompics.KompicsEvent import se.sics.kompics.Kompics -import se.sics.kompics.simulator.{SimulationScenario => JSimulationScenario} +import se.sics.kompics.simulator.{ SimulationScenario => JSimulationScenario } import se.sics.kompics.simulator.run.LauncherComp import se.sics.kompics.simulator.adaptor._ import se.sics.kompics.simulator.events.system._ @@ -38,7 +38,7 @@ import se.sics.kompics.simulator.instrumentation.{ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException -import se.sics.kompics.network.{Network, Address, Header, Msg, Transport}; +import se.sics.kompics.network.{ Network, Address, Header, Msg, Transport }; import se.sics.kompics.timer.{ Timer, SchedulePeriodicTimeout, @@ -298,14 +298,14 @@ final case class TAddress(isa: InetSocketAddress) extends Address { } final case class THeader(src: TAddress, dst: TAddress, proto: Transport) - extends Header[TAddress] { + extends Header[TAddress] { override def getDestination(): TAddress = dst; override def getProtocol(): Transport = proto; override def getSource(): TAddress = src; } final case class TMessage[C <: KompicsEvent](header: THeader, payload: C) - extends Msg[TAddress, THeader] { + extends Msg[TAddress, THeader] { override def getDestination(): TAddress = header.dst; override def getHeader(): THeader = header; override def getProtocol(): Transport = header.proto; diff --git a/simulator/src/test/scala/se/sics/kompics/sl/simulator/KompicsUnitSuite.scala b/simulator/src/test/scala/se/sics/kompics/sl/simulator/KompicsUnitSuite.scala index 4849271..fc83b50 100644 --- a/simulator/src/test/scala/se/sics/kompics/sl/simulator/KompicsUnitSuite.scala +++ b/simulator/src/test/scala/se/sics/kompics/sl/simulator/KompicsUnitSuite.scala @@ -1,35 +1,35 @@ /** - * This file is part of the Kompics component model runtime. - * - * Copyright (C) 2009 Swedish Institute of Computer Science (SICS) - * Copyright (C) 2009 Royal Institute of Technology (KTH) - * - * Kompics is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + * This file is part of the Kompics component model runtime. + * + * Copyright (C) 2009 Swedish Institute of Computer Science (SICS) + * Copyright (C) 2009 Royal Institute of Technology (KTH) + * + * Kompics is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ package se.sics.kompics.sl import org.scalatest._ -import concurrent.AsyncAssertions +import concurrent.Waiters import se.sics.kompics.KompicsEvent import se.sics.kompics.Component import se.sics.kompics.config.ConfigUpdate trait EventTester { @volatile protected var check: KompicsEvent => Unit = { (msg) => - } + } def registerHandler(f: KompicsEvent => Unit) { check = f @@ -43,7 +43,7 @@ object KompicsUnitSuite { type EventChecker = KompicsEvent => Unit; class SetupDefinition(init: Init[SetupDefinition]) - extends ComponentDefinition { + extends ComponentDefinition { private val (conf, checker) = init match { case Init(conf: Conf @unchecked, checker: EventChecker @unchecked) => @@ -51,15 +51,15 @@ object KompicsUnitSuite { }; def child[T <: se.sics.kompics.ComponentDefinition]( - definition: Class[T]): Component = child(definition, None, None); + definition: Class[T]): Component = child(definition, None, None); def child[T <: se.sics.kompics.ComponentDefinition]( - definition: Class[T], - initEvent: Option[se.sics.kompics.Init[T]]): Component = + definition: Class[T], + initEvent: Option[se.sics.kompics.Init[T]]): Component = child(definition, initEvent, None); def child[T <: se.sics.kompics.ComponentDefinition]( - definition: Class[T], - initEvent: Option[se.sics.kompics.Init[T]], - update: Option[ConfigUpdate]): Component = { + definition: Class[T], + initEvent: Option[se.sics.kompics.Init[T]], + update: Option[ConfigUpdate]): Component = { val c = (initEvent, update) match { case (Some(ie), Some(u)) => create(definition, ie, u) case (Some(ie), None) => create(definition, ie) @@ -79,22 +79,21 @@ object KompicsUnitSuite { } abstract class KompicsUnitSuite - extends FunSuite - with Matchers - with AsyncAssertions { + extends FunSuite + with Matchers + with Waiters { import KompicsUnitSuite._ import org.scalatest.exceptions.NotAllowedException import org.scalatest.exceptions.TestFailedException import org.scalatest.concurrent.PatienceConfiguration._ - import time.{Nanoseconds, Seconds, Span} + import time.{ Nanoseconds, Seconds, Span } override implicit def patienceConfig = PatienceConfig(scaled(Span(5, Seconds))) - def setup(configure: Conf, checker: EventChecker) - : Tuple2[Class[SetupDefinition], Init[SetupDefinition]] = + def setup(configure: Conf, checker: EventChecker): Tuple2[Class[SetupDefinition], Init[SetupDefinition]] = (classOf[SetupDefinition], Init(configure, checker)) class EventWaiter extends EventChecker { @@ -153,8 +152,9 @@ abstract class KompicsUnitSuite val diff = endTime - System.nanoTime if (diff > 0) Span(diff, Nanoseconds) else Span.Zero } - val e = eventQueue.poll(timeLeft.totalNanos, - java.util.concurrent.TimeUnit.NANOSECONDS); + val e = eventQueue.poll( + timeLeft.totalNanos, + java.util.concurrent.TimeUnit.NANOSECONDS); println(s"Pulled a $e out of the eventQueue"); if (e != null) { val check = checkers.poll();