### Question:
JythonScriptEngineService implements ScriptEngineService { @Override public List<Instrumenter> createInstrumenters() throws EngineException { final List<Instrumenter> instrumenters = new ArrayList<Instrumenter>(); if (m_dcrContext != null) { if (instrumenters.size() == 0) { try { instrumenters.add(new Jython25Instrumenter(m_dcrContext)); } catch (WeavingException e) { instrumenters.add(new Jython22Instrumenter(m_dcrContext)); } } } return instrumenters; } JythonScriptEngineService(GrinderProperties properties,
                                   DCRContext dcrContext,
                                   ScriptLocation scriptLocation);  JythonScriptEngineService(); @Override List<Instrumenter> createInstrumenters(); @Override ScriptEngine createScriptEngine(ScriptLocation script);  }### Answer:
@Test public void testCreateInstrumentedProxy() throws Exception { final GrinderProperties properties = new GrinderProperties(); final DCRContext context = DCRContextImplementation.create(null); final List<Instrumenter> instrumenters = new JythonScriptEngineService(properties, context, m_pyScript) .createInstrumenters(); assertEquals(1, instrumenters.size()); final Instrumenter instrumenter = instrumenters.get(0); assertEquals("byte code transforming instrumenter for Jython 2.5", instrumenter.getDescription()); final Object foo = new Object(); PySystemState.initialize(); instrumenter.createInstrumentedProxy(m_test, m_recorder, foo); try { instrumenter.createInstrumentedProxy(m_test, m_recorder, new PyObject()); fail("Expected NotWrappableTypeException"); } catch (NotWrappableTypeException e) { } }
@Test public void testInstrument() throws Exception { final GrinderProperties properties = new GrinderProperties(); final DCRContextImplementation context = DCRContextImplementation.create(null); final List<Instrumenter> instrumenters = new JythonScriptEngineService(properties, context, m_pyScript) .createInstrumenters(); assertEquals(1, instrumenters.size()); final Instrumenter instrumenter = instrumenters.get(0); final Object foo = new Object(); instrumenter.instrument(m_test, m_recorder, foo, null); }
@Test public void testWithNoInstrumenters() throws Exception { final List<Instrumenter> instrumenters = new JythonScriptEngineService(new GrinderProperties(), null, new ScriptLocation(new File("notpy.blah"))) .createInstrumenters(); assertEquals(0, instrumenters.size()); }