Skip to content

Instantly share code, notes, and snippets.

@gbeaty
Created May 31, 2013 03:12
Show Gist options
  • Save gbeaty/8194a40706355e7013ef to your computer and use it in GitHub Desktop.
Save gbeaty/8194a40706355e7013ef to your computer and use it in GitHub Desktop.
Trying to reproduce null entity var issue.
import net.fwbrasil.activate.ActivateContext
import net.fwbrasil.activate.storage.memory.TransientMemoryStorage
import net.fwbrasil.activate.entity.Entity
import org.specs2.mutable._
import akka.util._
import akka.actor._
object Context extends ActivateContext {
lazy val storage = new TransientMemoryStorage
val system = ActorSystem("EntityInitTests")
}
import Context._
class Tester(a: A) extends Actor {
def receive = {
case 0 => assert(a.uuids != null)
}
}
class A extends Entity {
var uuids = for(i <- 1 to 100) yield java.util.UUID.randomUUID.toString
def tester = system.actorOf(Props(new Tester(this)))
}
class EntityInitTests extends Specification {
"Entities" should {
"Initialize" in {
transactional {
val as = for(i <- 1 to 10) yield i
as.par.foreach { _ =>
val a = new A
a.tester ! 0
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment