Package org.jrack

Examples of org.jrack.Context


   *
   * @throws Exception
   */
  @Test
  public void testBSFEngineIntegration() throws Exception {
    Context context = new MicroContext();


    BSFEngine engine = micro.getSite().getBSFEngine("beanshell",
        (MicroContext) context.with("unu", 1),
        Collections.singletonMap("foo", "bar"));

    engine.exec("complexCalculus", 0, 0,
        "context.with(\"one\", context.get(\"unu\") * 1);" +
            "log.info(\"One is: \" + context.get(\"one\"));"); // :P
    Assert.assertEquals("BSFEngine failure", 1, context.get("one"));
  }
View Full Code Here


  @Test
  public void testCloseableBSF() throws Exception {
    final SiteContext site = micro.getSite();
    final String canonicalName = TestController.class.getCanonicalName();

    Context context = new MicroContext<String>()
        .with(Globals.LOG, site.getLog())
        .with(Globals.SITE, site);

    site.getControllerManager().execute("Foo.bsh", (MicroContext) context, Collections.singletonMap("foo", "bar"));
    Assert.assertTrue("Foo is not Bar, broken configuration",
        ((String) context.get("foo")).equalsIgnoreCase("bar"));

    site.getControllerManager().execute("Bat.bsh", (MicroContext) context, Collections.singletonMap("Bat", "Man"));
    Assert.assertTrue("Bat is not the Man, c'mon man",
        ((String) context.get("Bat")).equalsIgnoreCase("Man"));

    site.getControllerManager().execute("ca.simplegames.micro.TestController",
        (MicroContext) context, Collections.singletonMap("class", canonicalName));
    Assert.assertTrue("Can't execute Java class",
        ((String) context.get("class")).equalsIgnoreCase(canonicalName));
  }
View Full Code Here

TOP

Related Classes of org.jrack.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.