PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/razpubs/test_src/com/razie/pub/test/TestAssetMgrTrait.scala

http://razpub.googlecode.com/
Scala | 43 lines | 26 code | 11 blank | 6 comment | 0 complexity | c279ff22877f68ac9ec88bcf8256277e MD5 | raw file
 1package com.razie.pub.test
 2
 3import com.razie.pub.assets._
 4import com.razie.pub.base._
 5import org.scalatest.junit._
 6import razie.assets._
 7import razie.base._
 8
 9// just to instantiate a trait
10class SampleAssetMgrTrait extends AssetMgrInjector {
11}
12
13// injected sample - has 1 type and 2 actions
14class SampleAJ extends AssetCmdInjection {
15   val entityTypes = Array("Movie")
16   val actions = Array(new ActionItem("organize"), new ActionItem("moveto"))
17   
18  def doAction (entityKey:AssetKey, entity:Referenceable, action:String, ctx:ScriptContext) : AnyRef = {
19    println(action)
20    "Ok."
21  }
22}
23
24class TestAssetMgrTrait extends JUnit3Suite {
25  
26  type fun = (AssetKey, Referenceable, String, ScriptContext) => AnyRef
27  private[this] implicit def str2ActionI (s:String) : ActionItem = new ActionItem (s)
28
29
30  def testActionItem = {
31   val am = new SampleAssetMgrTrait
32 
33   am.inject(new SampleAJ)
34   
35//   am.inject("Movie","organize",111)
36   //am.inject("Movie","moveto",println ("moveto" + _ + _ + _ )))
37
38  val aa = am.injections("Movie")
39  println ("A: " + (aa mkString ","))
40//   Assert.assertTrue(idx.get1k("Movie")==List("organize", "moveto"))
41   //Assert.assertTrue(idx.get2("Movie","organize") == Some(111))
42  }
43}