コード例 #1
0
 static {
   try {
     s_weaver =
         new DCRWeaver(
             new ASMTransformerFactory(RecorderLocator.class),
             ExposeInstrumentation.getInstrumentation());
   } catch (WeavingException e) {
     throw new ExceptionInInitializerError(e);
   }
 }
コード例 #2
0
  public void testInstrumentUnmodifiableCLass() throws Exception {

    final RandomStubFactory<Instrumentation> instrumentationStubFactory =
        RandomStubFactory.create(Instrumentation.class);
    final Instrumentation instrumentation = instrumentationStubFactory.getStub();

    ExposeInstrumentation.premain("", instrumentation);

    instrumentationStubFactory.setThrows("retransformClasses", new UnmodifiableClassException());

    // Create a new weaver to force the weaving.
    final JavaDCRInstrumenter instrumenter =
        new JavaDCRInstrumenter(
            new DCRWeaver(
                new ASMTransformerFactory(RecorderLocator.class),
                ExposeInstrumentation.getInstrumentation()),
            RecorderLocator.getRecorderRegistry());

    try {
      instrumenter.createInstrumentedProxy(null, m_recorder, MyClass.class);
      fail("Expected NotWrappableTypeException");
    } catch (NotWrappableTypeException e) {
    }
  }
コード例 #3
0
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   ExposeInstrumentation.premain("", m_originalInstrumentation);
   RecorderLocator.clearRecorders();
 }
コード例 #4
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   m_originalInstrumentation = ExposeInstrumentation.getInstrumentation();
 }