コード例 #1
0
  public void testCreateInstrumentedProxyWithDefaults() throws Exception {
    final MasterInstrumenter masterInstrumenter =
        new MasterInstrumenter(m_loggerStubFactory.getLogger(), false);

    assertEquals(
        "traditional Jython instrumenter; " + "byte code transforming instrumenter for Java",
        masterInstrumenter.getDescription());

    m_loggerStubFactory.assertOutputMessageContains("traditional Jython");
    m_loggerStubFactory.assertNoMoreCalls();

    try {
      masterInstrumenter.createInstrumentedProxy(null, m_recorder, null);
      fail("Expected NotWrappableTypeException");
    } catch (NotWrappableTypeException e) {
    }

    final Object foo = new Object();

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

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

    try {
      masterInstrumenter.createInstrumentedProxy(m_test, m_recorder, new PyObject());
      fail("Expected NotWrappableTypeException");
    } catch (NotWrappableTypeException e) {
    }
  }