4646import javax .script .ScriptEngine ;
4747import javax .script .ScriptException ;
4848
49+ import org .junit .After ;
50+ import org .junit .Before ;
4951import org .junit .Test ;
5052import org .scijava .Context ;
5153import org .scijava .plugin .Plugin ;
5456 * Basic tests for the {@link ScriptService}.
5557 *
5658 * @author Johannes Schindelin
59+ * @author Curtis Rueden
5760 */
5861public class ScriptEngineTest {
5962
63+ private Context context ;
64+ private ScriptService scriptService ;
65+
66+ @ Before
67+ public void setUp () {
68+ context = new Context (ScriptService .class );
69+ scriptService = context .getService (ScriptService .class );
70+ }
71+
72+ @ After
73+ public void tearDown () {
74+ context .dispose ();
75+ context = null ;
76+ scriptService = null ;
77+ }
78+
6079 @ Test
6180 public void testRot13 () throws Exception {
62- final Context context = new Context (ScriptService .class );
63- final ScriptService scriptService = context .getService (ScriptService .class );
6481 final ScriptLanguage hello = scriptService .getLanguageByName ("Hello" );
6582 assertNotNull (hello );
6683 final ScriptLanguage rot13 = scriptService .getLanguageByName ("Rot13" );
@@ -70,8 +87,6 @@ public void testRot13() throws Exception {
7087
7188 @ Test
7289 public void testScriptModuleValue () throws Exception {
73- final Context context = new Context (ScriptService .class );
74- final ScriptService scriptService = context .getService (ScriptService .class );
7590 final ScriptModule module =
7691 scriptService .run ("test.rot13" , ScriptModule .class .getName (), false ,
7792 (Map <String , Object >) null ).get ();
0 commit comments