Search in sources :

Example 1 with BSFEngine

use of org.apache.bsf.BSFEngine in project groovy by apache.

the class BSFSpecTest method testAccess.

@Test
public void testAccess() throws BSFException {
    // tag::bsf_access[]
    BSFManager manager = new BSFManager();
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    manager.declareBean("myvar", "hello", String.class);
    Object myvar = manager.lookupBean("myvar");
    String result = (String) bsfEngine.call(myvar, "reverse", new Object[0]);
    assertEquals("olleh", result);
// end::bsf_access[]
}
Also used : BSFEngine(org.apache.bsf.BSFEngine) BSFManager(org.apache.bsf.BSFManager) Test(org.junit.Test)

Example 2 with BSFEngine

use of org.apache.bsf.BSFEngine in project groovy by apache.

the class BSFTest method testCall.

public void testCall() throws Exception {
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    manager.declareBean("myvar", "hello", String.class);
    Object myvar = manager.lookupBean("myvar");
    String result = (String) bsfEngine.call(myvar, "reverse", new Object[] {});
    assertEquals("olleh", result);
}
Also used : BSFEngine(org.apache.bsf.BSFEngine)

Example 3 with BSFEngine

use of org.apache.bsf.BSFEngine in project ant by apache.

the class ScriptRunner method createManager.

private BSFManager createManager() throws BSFException {
    if (manager != null) {
        return manager;
    }
    BSFManager m = new BSFManager();
    m.setClassLoader(getScriptClassLoader());
    if (getKeepEngine()) {
        BSFEngine e = manager.loadScriptingEngine(getLanguage());
        this.manager = m;
        this.engine = e;
    }
    return m;
}
Also used : BSFEngine(org.apache.bsf.BSFEngine) BSFManager(org.apache.bsf.BSFManager)

Example 4 with BSFEngine

use of org.apache.bsf.BSFEngine in project groovy-core by groovy.

the class BSFSpecTest method testAccess.

@Test
public void testAccess() throws BSFException {
    // tag::bsf_access[]
    BSFManager manager = new BSFManager();
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    manager.declareBean("myvar", "hello", String.class);
    Object myvar = manager.lookupBean("myvar");
    String result = (String) bsfEngine.call(myvar, "reverse", new Object[0]);
    assertEquals("olleh", result);
// end::bsf_access[]
}
Also used : BSFEngine(org.apache.bsf.BSFEngine) BSFManager(org.apache.bsf.BSFManager) Test(org.junit.Test)

Example 5 with BSFEngine

use of org.apache.bsf.BSFEngine in project groovy-core by groovy.

the class CacheBSFTest method testVersion.

public void testVersion() throws Exception {
    // System.out.println("BSFManager.getVersion() = " + BSFManager.getVersion());
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    assertEquals(CACHING_ENGINE, bsfEngine.getClass());
}
Also used : BSFEngine(org.apache.bsf.BSFEngine)

Aggregations

BSFEngine (org.apache.bsf.BSFEngine)10 BSFManager (org.apache.bsf.BSFManager)4 BSFException (org.apache.bsf.BSFException)3 File (java.io.File)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 SampleResult (org.apache.jmeter.samplers.SampleResult)1