@Test
  public void testVarAccess() {
    Configuration config = Configuration.instance();
    try {
      config.load();
    } catch (ConfigurationException e1) {
      e1.printStackTrace();
      fail();
    }
    BSFManager bsfManager = new BSFManager();
    BSFEngine engine = null;
    try {
      engine = bsfManager.loadScriptingEngine("BeanShell");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    assertNotNull(engine);

    try {
      // ObjectRegistry registry = bsfManager.getObjectRegistry();
      // registry.register("mmm", new Integer(3));
      // engine.exec("source", 1, 1, "print( mmm );");
      engine.exec("source", 1, 1, "mmm = 1000;");
      engine.exec("source", 1, 1, "print( mmm );");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    engine.terminate();
  }
 @Test
 public void testLoad() {
   Configuration config = Configuration.instance();
   try {
     config.load();
   } catch (ConfigurationException e) {
     e.printStackTrace();
     fail();
   }
   assertTrue(BSFManager.isLanguageRegistered("BeanShell"));
 }
 @Test
 public void checkSomeProperties() {
   try {
     Configuration.instance().load();
   } catch (ConfigurationException e) {
     e.printStackTrace();
     fail();
   }
   assertEquals(-1, Configuration.instance().getHistoryDepth());
   assertEquals(1, Configuration.instance().getInteger("tangara.level"));
 }
 @Test
 public void testSysPropConf() {
   Configuration cfg = Configuration.instance();
   try {
     cfg.load();
   } catch (ConfigurationException e) {
     e.printStackTrace();
     fail();
   }
   assertNull(cfg.getProperty("name1"));
   System.setProperty(Configuration.CONF_SYS_P, "src/test/data/conf2.properties");
   Configuration cfg2 = Configuration.instance();
   try {
     cfg2.load();
   } catch (ConfigurationException e) {
     e.printStackTrace();
     fail();
   }
   assertEquals("value1", cfg2.getProperty("name1"));
   System.getProperties().remove("tangara.configuration");
 }
  @Test
  public void testEval() {
    Configuration config = Configuration.instance();
    try {
      config.load();
    } catch (ConfigurationException ex) {
      ex.printStackTrace();
      fail();
    }
    BSFManager bsfManager = new BSFManager();

    Integer i = new Integer(5);
    try {
      bsfManager.declareBean("i", i, Integer.class);
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    BSFEngine engine = null;
    try {
      engine = bsfManager.loadScriptingEngine("BeanShell");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    assertNotNull(engine);

    Integer j = new Integer(7);
    try {
      bsfManager.declareBean("j", j, Integer.class);
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    try {
      engine.exec("source", 1, 1, "a=3;\nprint(a);");
      engine.exec("source", 1, 1, "a=a+1;\nprint(a);");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    try {
      engine.exec("source", 1, 1, "print(\"i=\"+i);");
      engine.exec("source", 1, 1, "j=j*10; print(\"j=\"+j);");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    // BSFDeclaredBean toto = new BSFDeclaredBean();
    // toto.beannew BSFDeclaredBean("i", i, Integer.class);
    ObjectRegistry registry = bsfManager.getObjectRegistry();
    Object jValue = registry.lookup("j");
    if (jValue != null) {
      System.out.println("j-value = " + jValue.toString());
    }
    registry.register("k", new Integer(1000));
    Object kValue = registry.lookup("k");
    assertNotNull(kValue);
    System.out.println("k=" + kValue.toString());
    try {
      engine.exec("source", 1, 1, "print(\"k=\"+k);");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    try {
      bsfManager.declareBean("k", kValue, Integer.class);
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    try {
      engine.exec("source", 1, 1, "print(\"k=\"+k);");
    } catch (BSFException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    engine.terminate();
  }