Package org.tamacat.util

Source Code of org.tamacat.util.JavaScriptUtilsTest

package org.tamacat.util;

import static org.junit.Assert.*;

import java.lang.reflect.Method;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

import org.junit.Test;
import org.tamacat.util.JavaScript_test.JavaScript;

public class JavaScriptUtilsTest {
 
  @JavaScript("var test = true;")
  public void execute() {
  }
     
  @Test
  public void testEvalMethod() throws ScriptException {
    Method method = ClassUtils.getMethod(JavaScriptUtilsTest.class, "execute", (Class<?>[]) null);
    ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");
    JavaScript script = method.getAnnotation(JavaScript.class);
    assertNull(engine.eval(script.value()));
  }

  @Test
  public void testEvalJavaScript() throws ScriptException {
    Method method = ClassUtils.getMethod(JavaScriptUtilsTest.class, "execute", (Class<?>[]) null);
    JavaScript script = method.getAnnotation(JavaScript.class);
    assertNull(JavaScriptUtils.getScriptEngine().eval(script.value()));
  }
}
TOP

Related Classes of org.tamacat.util.JavaScriptUtilsTest

TOP
Copyright © 2018 www.massapi.com. 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.