コード例 #1
0
  @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) {
    }
  }
コード例 #2
0
  @Test
  public void testWithForcedDCRInsstrumentation() throws Exception {
    final GrinderProperties properties = new GrinderProperties();
    properties.setBoolean("grinder.dcrinstrumentation", true);

    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);

    assertEquals(
        "byte code transforming instrumenter for Jython 2.1/2.2", instrumenter.getDescription());
  }
コード例 #3
0
  @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();

    // instrument() is not supported by the traditional instrumenter.
    try {
      instrumenter.instrument(m_test, m_recorder, foo, null);
      fail("Expected NonInstrumentableTypeException");
    } catch (NonInstrumentableTypeException e) {
    }
  }
コード例 #4
0
ファイル: TestData.java プロジェクト: ahlfors/the_grinder
 /** {@inheritDoc} */
 @Override
 public Object createProxy(Object o) throws NotWrappableTypeException {
   return m_instrumenter.createInstrumentedProxy(getTest(), this, o);
 }
コード例 #5
0
ファイル: TestData.java プロジェクト: ahlfors/the_grinder
 /** {@inheritDoc} */
 @Override
 public void instrument(Object target, InstrumentationFilter filter)
     throws NonInstrumentableTypeException {
   m_instrumenter.instrument(getTest(), this, target, filter);
 }