@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("traditional Jython instrumenter", instrumenter.getDescription());

    final Object foo = new Object();

    PySystemState.initialize();

    final PyObject proxy = (PyObject) instrumenter.createInstrumentedProxy(m_test, m_recorder, foo);

    assertSame(proxy.__getattr__("__target__").__tojava__(Object.class), foo);

    try {
      instrumenter.createInstrumentedProxy(m_test, m_recorder, new PyObject());
      fail("Expected NotWrappableTypeException");
    } catch (NotWrappableTypeException e) {
    }
  }
Beispiel #2
0
 /** {@inheritDoc} */
 @Override
 public Object createProxy(Object o) throws NotWrappableTypeException {
   return m_instrumenter.createInstrumentedProxy(getTest(), this, o);
 }