Skip to content

Commit

Permalink
[BE2] drop scala-reflect dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Bettens committed Jun 13, 2022
1 parent bc9a138 commit 5136902
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
1 change: 0 additions & 1 deletion be2-scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,5 @@ libraryDependencies += "com.networknt" % "json-schema-validator" % "1.0.60"
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.0.0-RC3"

// Scala file system handling
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value

conflictManager := ConflictManager.latestCompatible
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import java.io.File

import com.typesafe.config.{Config, ConfigFactory}

import scala.reflect.io.Directory
import scala.sys.SystemProperties

/** RuntimeConfiguration object provider This object provides application config
Expand All @@ -17,6 +16,14 @@ import scala.sys.SystemProperties
*/
object RuntimeEnvironment {

def deleteRecursively(f: File): Boolean = {
if (f.isDirectory) f.listFiles match {
case null =>
case xs => xs foreach deleteRecursively
}
f.delete()
}

private lazy val sp = new SystemProperties()

private def getConfDir: String = {
Expand All @@ -25,9 +32,9 @@ object RuntimeEnvironment {
// starting the program with fresh database
println("Starting the server without any previous persistent state")

// removing database folder
val directory = new Directory(new File("database"))
if (directory.deleteRecursively()) {
// removing database directory
val database = new File("database/")
if (deleteRecursively(database)) {
println("Removed old database folder")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern.AskableActorRef
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.network.method.message.data.ObjectType
import ch.epfl.pop.model.objects._
import ch.epfl.pop.pubsub.graph.{GraphMessage, PipelineError}
Expand All @@ -17,8 +18,6 @@ import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers._
import util.examples.data.PostTransactionMessages._

import scala.reflect.io.Directory

class CoinValidatorSuite extends TestKit(ActorSystem("coinValidatorTestActorSystem"))
with AnyFunSuiteLike
with ImplicitSender
Expand All @@ -34,8 +33,8 @@ class CoinValidatorSuite extends TestKit(ActorSystem("coinValidatorTestActorSyst
TestKit.shutdownActorSystem(system)

// Deletes the test database
val directory = new Directory(new File(DB_TEST_FOLDER))
directory.deleteRecursively()
val directory = new File(DB_TEST_FOLDER)
deleteRecursively(directory)
}

test("Posting a transaction works as intended") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern.AskableActorRef
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.network.method.message.Message
import ch.epfl.pop.model.network.method.message.data.ObjectType
import ch.epfl.pop.model.objects._
Expand All @@ -22,7 +23,6 @@ import util.examples.JsonRpcRequestExample._

import java.io.File
import java.util.concurrent.TimeUnit
import scala.reflect.io.Directory

class ElectionValidatorSuite extends TestKit(ActorSystem("electionValidatorTestActorSystem"))
with AnyFunSuiteLike
Expand All @@ -42,8 +42,8 @@ class ElectionValidatorSuite extends TestKit(ActorSystem("electionValidatorTestA
TestKit.shutdownActorSystem(system)

// Deletes the test database
val directory = new Directory(new File(DB_TEST_FOLDER))
directory.deleteRecursively()
val directory = new File(DB_TEST_FOLDER)
deleteRecursively(directory)
}

private final val sender: PublicKey = SetupElectionExamples.SENDER_SETUPELECTION
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.epfl.pop.pubsub.graph.validators

import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.network.method.message.data.ObjectType
import ch.epfl.pop.model.objects.{Base64Data, ChannelData, LaoData, PrivateKey, PublicKey}
import ch.epfl.pop.storage.{DbActor, InMemoryStorage}
Expand All @@ -19,8 +20,6 @@ import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers._
import util.examples.JsonRpcRequestExample._

import scala.reflect.io.Directory

class LaoValidatorSuite extends TestKit(ActorSystem("laoValidatorTestActorSystem"))
with AnyFunSuiteLike
with ImplicitSender
Expand All @@ -38,8 +37,8 @@ class LaoValidatorSuite extends TestKit(ActorSystem("laoValidatorTestActorSystem
TestKit.shutdownActorSystem(system)

// Deletes the test database
val directory = new Directory(new File(DB_TEST_FOLDER))
directory.deleteRecursively()
val directory = new File(DB_TEST_FOLDER)
deleteRecursively(directory)
}

test("LAO creation works as intended") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern.AskableActorRef
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.network.method.message.data.{ActionType, ObjectType}
import ch.epfl.pop.model.objects._
import ch.epfl.pop.pubsub.graph.{GraphMessage, PipelineError}
Expand All @@ -22,7 +23,6 @@ import util.examples.RollCall.CreateRollCallExamples.{SENDER, _}

import java.io.File
import java.util.concurrent.TimeUnit
import scala.reflect.io.Directory

class RollCallValidatorSuite extends TestKit(ActorSystem("rollcallValidatorTestActorSystem"))
with AnyFunSuiteLike
Expand All @@ -42,8 +42,8 @@ class RollCallValidatorSuite extends TestKit(ActorSystem("rollcallValidatorTestA
TestKit.shutdownActorSystem(system)

// Deletes the test database
val directory = new Directory(new File(DB_TEST_FOLDER))
directory.deleteRecursively()
val directory = new File(DB_TEST_FOLDER)
deleteRecursively(directory)
}

private final val sender: PublicKey = SENDER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern.AskableActorRef
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.network.method.message.data.ObjectType
import ch.epfl.pop.model.objects._
import ch.epfl.pop.pubsub.graph.{GraphMessage, PipelineError}
Expand All @@ -18,8 +19,6 @@ import org.scalatest.matchers._
import util.examples.JsonRpcRequestExample._
import util.examples.socialMedia.AddChirpExamples

import scala.reflect.io.Directory

class SocialMediaValidatorSuite extends TestKit(ActorSystem("socialMediaValidatorTestActorSystem"))
with AnyFunSuiteLike
with ImplicitSender
Expand All @@ -38,8 +37,8 @@ class SocialMediaValidatorSuite extends TestKit(ActorSystem("socialMediaValidato
TestKit.shutdownActorSystem(system)

// Deletes the test database
val directory = new Directory(new File(DB_TEST_FOLDER))
directory.deleteRecursively()
val directory = new File(DB_TEST_FOLDER)
deleteRecursively(directory)
}

private final val PUBLIC_KEY: PublicKey = PublicKey(Base64Data("jsNj23IHALvppqV1xQfP71_3IyAHzivxiCz236_zzQc="))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package ch.epfl.pop.storage

import java.io.File

import ch.epfl.pop.config.RuntimeEnvironment.deleteRecursively
import ch.epfl.pop.model.objects.DbActorNAckException
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers._

import scala.collection.concurrent.TrieMap
import scala.reflect.io.Directory

class DiskStorageSuite extends AnyFunSuite with should.Matchers with BeforeAndAfterAll {
// concurrent map storing all instances of DiskStorage
Expand All @@ -28,8 +28,8 @@ class DiskStorageSuite extends AnyFunSuite with should.Matchers with BeforeAndAf
for ((storeName, store) <- stores) {
store.close()

val directory = new Directory(new File(storeName))
directory.deleteRecursively()
val directory = new File(storeName)
deleteRecursively(directory)
}
}

Expand Down

0 comments on commit 5136902

Please sign in to comment.