• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AfterBurnerImpossibleException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException的典型用法代码示例。如果您正苦于以下问题:Java AfterBurnerImpossibleException类的具体用法?Java AfterBurnerImpossibleException怎么用?Java AfterBurnerImpossibleException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AfterBurnerImpossibleException类属于com.github.stephanenicolas.afterburner.exception包,在下文中一共展示了AfterBurnerImpossibleException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addOrInsertMethod

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
/**
 * Add/Inserts java instructions into a given method of a given class.
 * @param insertableMethod contains all information to perform byte code injection.
 * @throws CannotCompileException if the source contained in insertableMethod can't be compiled.
 * @throws AfterBurnerImpossibleException if something else goes wrong, wraps other exceptions.
 */
public void addOrInsertMethod(InsertableMethod insertableMethod) throws CannotCompileException, AfterBurnerImpossibleException {
    log.info("InsertableMethod : " + insertableMethod);
    // create or complete onViewCreated
    String targetMethodName = insertableMethod.getTargetMethodName();
    CtClass classToTransform = insertableMethod.getClassToInsertInto();
    CtMethod targetMethod = extractExistingMethod(classToTransform,
            targetMethodName);
    log.info("Method : " + targetMethod);
    if (targetMethod != null) {
        InsertableMethodInjectorEditor injectorEditor = new InsertableMethodInjectorEditor(
                classToTransform, insertableMethod);
        targetMethod.instrument(injectorEditor);
        if (!injectorEditor.isSuccessful) {
            throw new CannotCompileException("Transformation failed. Insertion method not found.: " + targetMethodName);
        }
    } else {
        classToTransform.addMethod(CtNewMethod.make(
                insertableMethod.getFullMethod(), classToTransform));
    }
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:27,代码来源:AfterBurner.java


示例2: insertConstructor

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
/**
 * Inserts java instructions into all constructors a given class.
 * @param insertableConstructor contains all information about insertion.
 * @throws CannotCompileException if the source contained in insertableMethod can't be compiled.
 * @throws AfterBurnerImpossibleException if something else goes wrong, wraps other exceptions.
 */
public void insertConstructor(InsertableConstructor insertableConstructor) throws CannotCompileException, AfterBurnerImpossibleException,
NotFoundException {
    // create or complete onViewCreated
    List<CtConstructor> constructorList = extractExistingConstructors(insertableConstructor);
    log.info("constructor : " + constructorList.toString());
    if (!constructorList.isEmpty()) {
        for (CtConstructor constructor : constructorList) {
            constructor
            .insertBeforeBody(insertableConstructor
                    .getConstructorBody(constructor
                            .getParameterTypes()));
        }
    } else {
        throw new AfterBurnerImpossibleException("No suitable constructor was found in class " + insertableConstructor.getClassToInsertInto().getName() + ". Add a constructor that is accepted by the InsertableConstructor. Don't use non static inner classes.");
    }
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:23,代码来源:AfterBurner.java


示例3: InsertableMethodInjectorEditor

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
private InsertableMethodInjectorEditor(CtClass classToTransform, InsertableMethod insertableMethod) throws AfterBurnerImpossibleException {
    this.classToTransform = classToTransform;
    String insertionAfterMethod = insertableMethod
            .getInsertionAfterMethod();
    String insertionBeforeMethod = insertableMethod
            .getInsertionBeforeMethod();
    if (insertionBeforeMethod == null && insertionAfterMethod == null) {
        throw new AfterBurnerImpossibleException(
                "Error in class "
                        + insertableMethod.getClass()
                        + " both insertionBeforeMethod && insertionAfterMethod are null.");
    } else if (insertionBeforeMethod != null) {
        insertionMethod = insertionBeforeMethod;
        insertAfter = false;
    } else {
        insertionMethod = insertionAfterMethod;
        insertAfter = true;
    }
    bodyToInsert = insertableMethod.getBody();
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:21,代码来源:AfterBurner.java


示例4: testDoIt_calls_afterburner_with_after_override_when_no_method

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test(expected=NotFoundException.class)
public void testDoIt_calls_afterburner_with_after_override_when_no_method() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";

    builder
    .insertIntoClass(classToInsertInto.toClass())
    .afterOverrideMethod(targetMethod)
    .withBody(body)
    .doIt();

    //THEN
    fail();
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:25,代码来源:InsertableMethodBuilderTest.java


示例5: testDoIt_calls_afterburner_with_before_override_when_no_method

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test(expected=NotFoundException.class)
public void testDoIt_calls_afterburner_with_before_override_when_no_method() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";

    builder
    .insertIntoClass(classToInsertInto.toClass())
    .beforeOverrideMethod(targetMethod)
    .withBody(body)
    .doIt();

    //THEN
    fail();
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:25,代码来源:InsertableMethodBuilderTest.java


示例6: testCheckAllFields_should_throw_exceptions_if_no_full_method_defined

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test(expected = AfterBurnerImpossibleException.class)
public void testCheckAllFields_should_throw_exceptions_if_no_full_method_defined() throws AfterBurnerImpossibleException {
    //GIVEN
    CtClass classToInsertInto = CtClass.intType;
    String targetMethod = "";
    String insertionBeforeMethod = "";
    String body = "";
    builder
        .insertIntoClass(classToInsertInto)
        .inMethodIfExists(targetMethod)
        .beforeACallTo(insertionBeforeMethod)
        .withBody(body);

    //WHEN
    builder.checkFields();

    //THEN
    fail("Should have thrown exception");
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:20,代码来源:InsertableMethodBuilderTest.java


示例7: testDoIt_calls_afterburner

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.insertConstructor((InsertableConstructor) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);

    builder = new InsertableConstructorBuilder(afterBurnerMock);

    CtClass classToInsertInto = CtClass.intType;
    String body = "";

    //WHEN
    builder
        .insertIntoClass(classToInsertInto)
        .withBody(body)
        .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:22,代码来源:InsertableConstructorBuilderTest.java


示例8: testCheckAllFields_should_succeed_with_all_fields_defined

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testCheckAllFields_should_succeed_with_all_fields_defined() throws AfterBurnerImpossibleException {
    //GIVEN
    CtClass classToInsertInto = CtClass.intType;
    String body = "";

    //WHEN
    InsertableConstructor constructor = builder
            .insertIntoClass(classToInsertInto)
            .withBody(body)
            .createInsertableConstructor();

    //THEN
    assertNotNull(constructor);
    assertEquals(classToInsertInto, constructor.getClassToInsertInto());
    assertEquals(body, constructor.getConstructorBody(null));
    assertTrue(constructor.acceptParameters(null));
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:19,代码来源:InsertableConstructorBuilderTest.java


示例9: injectStuffInClass

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
private void injectStuffInClass(final CtClass clazz, List<ViewBinding> views,
    List<FragmentBinding> fragments)
    throws NotFoundException, ClassNotFoundException, CannotCompileException,
    AfterBurnerImpossibleException {

  // create or complete onViewCreated
  List<CtConstructor> constructorList =
      JavassistUtils.extractValidConstructors(clazz, injectViewFilter);
  if (constructorList != null && !constructorList.isEmpty()) {
    log.debug("constructor : " + constructorList.toString());
    for (CtConstructor constructor : constructorList) {
      int indexValidParam =
          findValidParamIndex(constructor.getParameterTypes(), injectViewFilter);
      //indexValidParam is > 0 at this stage
      constructor.insertBeforeBody(
          createInjectedBodyWithParam(constructor.getParameterTypes(), indexValidParam,
              views, fragments));
    }
  } else {
    log.warn(
        "No suitable constructor was found in class {}. Add a constructor with a single argument : Activity, Fragment or View. Don't use non static inner classes.",
        clazz.getName());
  }
  clazz.detach();
}
 
开发者ID:stephanenicolas,项目名称:injectview,代码行数:26,代码来源:InjectViewProcessor.java


示例10: debugLifeCycleMethods

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
private void debugLifeCycleMethods(CtClass classToTransform, CtMethod[] methods)
    throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
  for (CtMethod lifeCycleHook : methods) {
    String methodName = lifeCycleHook.getName();

    int accessFlags = lifeCycleHook.getMethodInfo().getAccessFlags();
    boolean isFinal = (accessFlags & AccessFlag.FINAL) == AccessFlag.FINAL;
    boolean canOverride = !isFinal && (AccessFlag.isPublic(accessFlags)
        || AccessFlag.isProtected(accessFlags)
        || AccessFlag.isPackage(accessFlags));
      
      log.info("Method name: " + methodName);

      if(!supportedMethods.contains(methodName))
          continue;


      if (canOverride && methodName.startsWith("on")) {
      log.info("Overriding " + methodName);
      try {
       String body = "com.github.stephanenicolas.lxglifecycle.ActivityListenerUtil.internal._" + methodName + "(this);";
          
        afterBurner.afterOverrideMethod(classToTransform, methodName, body);
        log.info("Override successful " + methodName);
      } catch (Exception e) {
        logMoreIfDebug("Override didn't work ", e);
      }
    } else {
      log.info(
          "Skipping " + methodName + ". Either it is final, private or doesn't start by 'on...'");
    }
  }
}
 
开发者ID:emmby,项目名称:easy-a,代码行数:34,代码来源:LxgLifeCycleProcessor.java


示例11: checkFields

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
protected void checkFields() throws AfterBurnerImpossibleException {
    boolean hasInsertionMethod = insertionBeforeMethod != null
            || insertionAfterMethod != null;
    if (classToInsertInto == null || targetMethod == null
            || !hasInsertionMethod || body == null || fullMethod == null) {
        throw new AfterBurnerImpossibleException(
                "Builder was not used as intended. A field is null.");
    }
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:10,代码来源:InsertableMethodBuilder.java


示例12: createInsertableMethod

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
public InsertableMethod createInsertableMethod() throws AfterBurnerImpossibleException {
    checkFields();
    doInsertBodyInFullMethod();

    InsertableMethod method = new SimpleInsertableMethod(
            classToInsertInto, targetMethod, insertionBeforeMethod,
            insertionAfterMethod, body, fullMethod);
    return method;
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:10,代码来源:InsertableMethodBuilder.java


示例13: extractExistingConstructors

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
private List<CtConstructor> extractExistingConstructors(final InsertableConstructor insertableConstructor) throws NotFoundException, AfterBurnerImpossibleException {
    List<CtConstructor> constructors = new ArrayList<CtConstructor>();
    CtConstructor[] declaredConstructors = insertableConstructor
            .getClassToInsertInto().getDeclaredConstructors();
    for (CtConstructor constructor : declaredConstructors) {
        CtClass[] paramClasses = constructor.getParameterTypes();
        if (insertableConstructor.acceptParameters(paramClasses)) {
            constructors.add(constructor);
        }
    }
    return constructors;
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:13,代码来源:AfterBurner.java


示例14: testDoIt_calls_afterburner

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner() throws CannotCompileException, AfterBurnerImpossibleException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);

    builder = new InsertableMethodBuilder(afterBurnerMock, null);

    CtClass classToInsertInto = CtClass.intType;
    String targetMethod = "";
    String insertionAfterMethod = "";
    String fullMethod = "";
    String body = "";

    //WHEN
    builder
        .insertIntoClass(classToInsertInto)
        .inMethodIfExists(targetMethod)
        .afterACallTo(insertionAfterMethod)
        .withBody(body)
        .elseCreateMethodIfNotExists(fullMethod)
        .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:28,代码来源:InsertableMethodBuilderTest.java


示例15: testDoIt_calls_afterburner_with_after_override

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner_with_after_override() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);
    signatureExtractorMock = EasyMock.createMock(CtMethodJavaWriter.class);
    EasyMock.expect(signatureExtractorMock.invokeSuper((CtMethod) EasyMock.anyObject())).andReturn("super.foo()");
    EasyMock.expect(signatureExtractorMock.createJavaSignature((CtMethod) EasyMock.anyObject())).andReturn("public void foo()");
    EasyMock.replay(signatureExtractorMock);

    CtClass targetClassAncestor = ClassPool.getDefault().makeClass(
            "TargetAncestor" + TestCounter.testCounter++);
    targetClassAncestor.addMethod(CtNewMethod.make("public void foo() { }", targetClassAncestor));

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);
    targetClass.setSuperclass(targetClassAncestor);
    targetClass.addMethod(CtNewMethod.make("public void foo() { super.foo(); }", targetClass));

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";
    builder
        .insertIntoClass(classToInsertInto)
        .afterOverrideMethod(targetMethod)
        .withBody(body)
        .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:36,代码来源:InsertableMethodBuilderTest.java


示例16: testDoIt_calls_afterburner_with_after_override_when_no_override

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner_with_after_override_when_no_override() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);
    signatureExtractorMock = EasyMock.createMock(CtMethodJavaWriter.class);
    EasyMock.expect(signatureExtractorMock.invokeSuper((CtMethod) EasyMock.anyObject())).andReturn("super.foo()");
    EasyMock.expect(signatureExtractorMock.createJavaSignature((CtMethod) EasyMock.anyObject())).andReturn("public void foo()");
    EasyMock.replay(signatureExtractorMock);

    CtClass targetClassAncestor = ClassPool.getDefault().makeClass(
            "TargetAncestor" + TestCounter.testCounter++);
    targetClassAncestor.addMethod(CtNewMethod.make("public void foo() { }", targetClassAncestor));

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);
    targetClass.setSuperclass(targetClassAncestor);

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";
    builder
        .insertIntoClass(classToInsertInto)
        .afterOverrideMethod(targetMethod)
        .withBody(body)
        .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:35,代码来源:InsertableMethodBuilderTest.java


示例17: testDoIt_calls_afterburner_with_before_override

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner_with_before_override() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);
    signatureExtractorMock = EasyMock.createMock(CtMethodJavaWriter.class);
    EasyMock.expect(signatureExtractorMock.invokeSuper((CtMethod) EasyMock.anyObject())).andReturn("super.foo()");
    EasyMock.expect(signatureExtractorMock.createJavaSignature((CtMethod) EasyMock.anyObject())).andReturn("public void foo()");
    EasyMock.replay(signatureExtractorMock);

    CtClass targetClassAncestor = ClassPool.getDefault().makeClass(
            "TargetAncestor" + TestCounter.testCounter++);
    targetClassAncestor.addConstructor(CtNewConstructor.make("public " + targetClassAncestor.getName()+ "() { }", targetClassAncestor));
    targetClassAncestor.addMethod(CtNewMethod.make("public void foo() { }", targetClassAncestor));

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);
    targetClass.setSuperclass(targetClassAncestor);
    targetClass.addMethod(CtNewMethod.make("public void foo() { super.foo(); }", targetClass));

    targetClassAncestor.toClass();

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";

    builder
    .insertIntoClass(classToInsertInto.toClass())
    .beforeOverrideMethod(targetMethod)
    .withBody(body)
    .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:40,代码来源:InsertableMethodBuilderTest.java


示例18: testDoIt_calls_afterburner_with_before_override_when_no_override

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testDoIt_calls_afterburner_with_before_override_when_no_override() throws CannotCompileException, AfterBurnerImpossibleException, NotFoundException {
    //GIVEN
    afterBurnerMock = EasyMock.createMock(AfterBurner.class);
    afterBurnerMock.addOrInsertMethod((InsertableMethod) EasyMock.anyObject());
    EasyMock.replay(afterBurnerMock);
    signatureExtractorMock = EasyMock.createMock(CtMethodJavaWriter.class);
    EasyMock.expect(signatureExtractorMock.invokeSuper((CtMethod) EasyMock.anyObject())).andReturn("super.foo()");
    EasyMock.expect(signatureExtractorMock.createJavaSignature((CtMethod) EasyMock.anyObject())).andReturn("public void foo()");
    EasyMock.replay(signatureExtractorMock);

    CtClass targetClassAncestor = ClassPool.getDefault().makeClass(
            "TargetAncestor" + TestCounter.testCounter++);
    targetClassAncestor.addConstructor(CtNewConstructor.make("public " + targetClassAncestor.getName()+ "() { }", targetClassAncestor));
    targetClassAncestor.addMethod(CtNewMethod.make("public void foo() { }", targetClassAncestor));

    CtClass targetClass = ClassPool.getDefault().makeClass(
            "Target" + TestCounter.testCounter++);
    targetClass.setSuperclass(targetClassAncestor);

    targetClassAncestor.toClass();

    //WHEN
    builder = new InsertableMethodBuilder(afterBurnerMock, signatureExtractorMock);

    CtClass classToInsertInto = targetClass;
    String targetMethod = "foo";
    String body = "";

    builder
    .insertIntoClass(classToInsertInto.toClass())
    .beforeOverrideMethod(targetMethod)
    .withBody(body)
    .doIt();

    //THEN
    EasyMock.verify(afterBurnerMock);
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:39,代码来源:InsertableMethodBuilderTest.java


示例19: testCheckAllFields_should_succeed_with_insert_after_method_defined

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testCheckAllFields_should_succeed_with_insert_after_method_defined() throws AfterBurnerImpossibleException {
    //GIVEN
    CtClass classToInsertInto = CtClass.intType;
    String targetMethod = "";
    String insertionAfterMethod = "";
    String fullMethod = "";
    String body = "";

    //WHEN
    InsertableMethod method = builder
            .insertIntoClass(classToInsertInto)
            .inMethodIfExists(targetMethod)
            .afterACallTo(insertionAfterMethod)
            .withBody(body)
            .elseCreateMethodIfNotExists(fullMethod)
            .createInsertableMethod();

    //THEN
    assertNotNull(method);
    assertEquals(classToInsertInto, method.getClassToInsertInto());
    assertEquals(targetMethod, method.getTargetMethodName());
    assertNull(method.getInsertionBeforeMethod());
    assertEquals(insertionAfterMethod, method.getInsertionAfterMethod());
    assertEquals(fullMethod, method.getFullMethod());
    assertEquals(body, method.getBody());
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:28,代码来源:InsertableMethodBuilderTest.java


示例20: testCheckAllFields_should_succeed_with_insert_before_method_defined

import com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException; //导入依赖的package包/类
@Test
public void testCheckAllFields_should_succeed_with_insert_before_method_defined() throws AfterBurnerImpossibleException {
    //GIVEN
    CtClass classToInsertInto = CtClass.intType;
    String targetMethod = "target";
    String insertionBeforeMethod = "insertionBeforeMethod";
    String fullMethod = "fullMethod";
    String body = "body";
    

    //WHEN
    InsertableMethod method = builder
            .insertIntoClass(classToInsertInto)
            .inMethodIfExists(targetMethod)
            .beforeACallTo(insertionBeforeMethod)
            .withBody(body)
            .elseCreateMethodIfNotExists(fullMethod)
            .createInsertableMethod();

    //THEN
    assertNotNull(method);
    assertEquals(classToInsertInto, method.getClassToInsertInto());
    assertEquals(targetMethod, method.getTargetMethodName());
    assertEquals(insertionBeforeMethod, method.getInsertionBeforeMethod());
    assertNull(method.getInsertionAfterMethod());
    assertEquals(fullMethod, method.getFullMethod());
    assertEquals(body, method.getBody());
}
 
开发者ID:stephanenicolas,项目名称:afterburner,代码行数:29,代码来源:InsertableMethodBuilderTest.java



注:本文中的com.github.stephanenicolas.afterburner.exception.AfterBurnerImpossibleException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IViewProvider类代码示例发布时间:2022-05-23
下一篇:
Java DefaultExhibitorRestClient类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap