예제 #1
0
  /** Test of getEngineVersion method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetEngineVersion() {
    logger1.info("getEngineVersion");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = org.jruby.runtime.Constants.VERSION;
    String result = instance.getEngineVersion();
    assertEquals(expResult, result);

    instance = null;
  }
예제 #2
0
  /** Test of getEngineName method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetEngineName() {
    logger1.info("getEngineName");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = "JSR 223 JRuby Engine";
    String result = instance.getEngineName();
    assertEquals(expResult, result);

    instance = null;
  }
예제 #3
0
  /** Test of getScriptEngine method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetScriptEngine() {
    logger1.info("getScriptEngine");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    Object expResult = instance;
    ScriptEngine engine = instance.getScriptEngine();
    Object result = engine.getFactory();
    assertEquals(expResult, result);

    instance = null;
  }
예제 #4
0
  /** Test of getOutputStatement method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetOutputStatement() {
    logger1.info("getOutputStatement");
    String toDisplay = "abc";
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = "puts abc\nor\nprint abc";
    String result = instance.getOutputStatement(toDisplay);
    assertEquals(expResult, result);

    instance = null;
  }
예제 #5
0
  /** Test of getMimeTypes method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetMimeTypes() {
    logger1.info("getMimeTypes");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    List expResult = new ArrayList();
    expResult.add("application/x-ruby");
    List result = instance.getMimeTypes();
    assertEquals(expResult, result);

    instance = null;
  }
예제 #6
0
  /** Test of getLanguageVersion method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetLanguageVersion() {
    logger1.info("getLanguageVersion");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = "jruby " + Constants.VERSION;
    String result = instance.getLanguageVersion();
    assertTrue(result.startsWith(expResult));
    logger1.info(result);

    instance = null;
  }
예제 #7
0
  /** Test of getExtensions method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetExtensions() {
    logger1.info("getExtensions");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    List expResult = new ArrayList();
    expResult.add("rb");
    List result = instance.getExtensions();
    assertEquals(expResult, result);

    instance = null;
  }
예제 #8
0
  /** Test of getProgram method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetProgram() {
    logger1.info("getProgram");
    String[] statements = {"1.upto(7) {|i| print i, \" \"}", "hh = {\"p\" => 3.14, \"e\" => 2.22}"};
    System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = "1.upto(7) {|i| print i, \" \"}\nhh = {\"p\" => 3.14, \"e\" => 2.22}\n";
    String result = instance.getProgram(statements);
    assertEquals(expResult, result);

    instance = null;
  }
예제 #9
0
  /** Test of getMethodCallSyntax method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetMethodCallSyntax() {
    logger1.info("getMethodCallSyntax");
    String obj = "receiver";
    String m = "establish_connection";
    String[] args = {"localhost", "1099"};
    JRubyEngineFactory instance = new JRubyEngineFactory();
    String expResult = "receiver.establish_connection(localhost, 1099)";
    String result = instance.getMethodCallSyntax(obj, m, args);
    assertEquals(expResult, result);

    instance = null;
  }
예제 #10
0
  /** Test of getParameter method, of class Jsr223JRubyEngineFactory. */
  @Test
  public void testGetParameter() {
    logger1.info("getParameter");
    String key = "";
    JRubyEngineFactory instance = new JRubyEngineFactory();
    Object expResult = null;
    Object result = instance.getParameter(key);
    assertEquals(expResult, result);

    key = ScriptEngine.ENGINE;
    expResult = "JSR 223 JRuby Engine";
    result = instance.getParameter(key);
    assertEquals(expResult, result);

    key = ScriptEngine.ENGINE_VERSION;
    expResult = org.jruby.runtime.Constants.VERSION;
    result = instance.getParameter(key);
    assertEquals(expResult, result);

    key = ScriptEngine.NAME;
    expResult = "JSR 223 JRuby Engine";
    result = instance.getParameter(key);
    assertEquals(expResult, result);

    key = ScriptEngine.LANGUAGE;
    expResult = "ruby";
    result = instance.getParameter(key);
    assertEquals(expResult, result);

    key = ScriptEngine.LANGUAGE_VERSION;
    expResult = "jruby " + Constants.VERSION;
    result = instance.getParameter(key);
    assertTrue(((String) result).startsWith((String) expResult));

    key = "THREADING";
    expResult = "THREAD-ISOLATED";
    result = instance.getParameter(key);
    assertEquals(expResult, result);

    instance = null;
  }