Examples of Aop1


Examples of org.nutz.aop.asm.test.Aop1

    AsmClassAgent agent = new AsmClassAgent();
    MyL interceptor = new MyL();
    agent.addInterceptor(new RegexMethodMatcher(null, "nonArgsVoid", 0), interceptor);
    agent.addInterceptor(MethodMatcherFactory.matcher(".*"), new LoggingMethodInterceptor());
    Mirror<Aop1> mirror = Mirror.me(agent.define(Nutzs.cd(), Aop1.class));
    Aop1 aop1 = mirror.born("Nutz");
    aop1.nonArgsVoid();
    assertFalse(interceptor.runned);
    aop1.argsVoid(null);
    assertTrue(interceptor.runned);
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

  }

  @Test
  public void testBorn() {
    Class<Aop1> klass = classAgent.define(Nutzs.cd(), Aop1.class);
    Aop1 a1 = Mirror.me(klass).born("Nut");
    a1.returnObjectArray();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    assertTrue(newClass.getDeclaredConstructors().length > 0);
  }

  @Test
  public void testReturnPrimitive() throws Throwable {
    Aop1 a1 = classAgent.define(Nutzs.cd(), Aop1.class)
              .getConstructor(String.class)
              .newInstance("Nutz");
    a1.returnLong();
    a1.returnBoolean();
    a1.returnByte();
    a1.returnChar();
    a1.returnFloat();
    a1.returnShort();
    a1.returnDouble();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    a1.returnDouble();
  }

  @Test
  public void testReturnPrimitiveArray() {
    Aop1 a1 = getNewInstance(Aop1.class);
    a1.returnIntArray();
    a1.returnLongArray();
    a1.returnBooleanArray();
    a1.returnByteArray();
    a1.returnCharArray();
    a1.returnFloatArray();
    a1.returnShortArray();
    a1.returnDoubleArray();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    a1.returnDoubleArray();
  }

  @Test
  public void testReturnObject() throws Throwable {
    Aop1 a1 = getNewInstance(Aop1.class);
    a1.returnString();
    a1.returnObjectArray();
    a1.getRunnable();
    a1.getEnum();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    a1.getEnum();
  }

  @Test(expected = RuntimeException.class)
  public void testThrowError() throws Throwable {
    Aop1 a1 = getNewInstance(Aop1.class);
    a1.throwError();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    a1.throwError();
  }

  @Test(expected = Exception.class)
  public void testThrowException() throws Throwable {
    Aop1 a1 = getNewInstance(Aop1.class);
    a1.throwException();
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    a1.throwException();
  }

  @Test
  public void testArgs() throws Throwable {
    Aop1 a1 = getNewInstance(Aop1.class);
    a1.nonArgsVoid();
    a1.argsVoid("Wendal is the best!");
    a1.mixObjectsVoid("Arg1", new Object(), 1, null);
    a1.mixArgsVoid("XX", "WendalXXX", 0, 'c', 1L, 9090L);
    a1.mixArgsVoid2("Aop1",
            Boolean.TRUE,
            8888,
            'p',
            34L,
            false,
            'b',
            "Gp",
            null,
            null,
            23L,
            90L,
            78L);
    String result = String.valueOf(a1.mixArgsVoid4("WendalXXX"));
    assertEquals("WendalXXX", result);
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    }
    Constructor<?>[] constructors = classZ.getDeclaredConstructors();
    for (Constructor<?> constructor : constructors) {
      System.out.println("找个一个Constructor: " + constructor);
    }
    Aop1 a1 = Mirror.me(classZ).born("Wendal");
    a1.nonArgsVoid();
    a1.argsVoid("Wendal is the best!");
    a1.mixObjectsVoid("Arg1", new Object(), 1, null);
    a1.mixArgsVoid("XX", "WendalXXX", 0, 'c', 1L, 9090L);
    a1.mixArgsVoid2("Aop1",
            Boolean.TRUE,
            8888,
            'p',
            34L,
            false,
            'b',
            "Gp",
            null,
            null,
            23L,
            90L,
            78L);
    String result = (String) a1.mixArgsVoid4("WendalXXX");
    System.out.println("返回值: " + result);
    try {
      a1.x();
    }
    catch (Throwable e) {
      // TODO: handle exception
    }
    a1.returnString();
    a1.returnLong();
    a1.returnBoolean();
    a1.returnByte();
    a1.returnChar();
    a1.returnFloat();
    a1.returnShort();
    a1.toString();
    a1.equals(new Object());
    a1.getLog(new StringBuilder("I am OK"));
    try {
      a1.throwError();
    }
    catch (Throwable e) {
      System.out.println("抓住你:");
      e.printStackTrace(System.out);
    }
    a1.returnObjectArray();
    a1.returnLongArray();
    a1.returnBooleanArray();
    a1.returnByteArray();
    a1.returnCharArray();
    a1.returnFloatArray();
    a1.returnShortArray();
    {
      // 带异常的构造函数
      Constructor<?> constructor = a1  .getClass()
                      .getConstructor(new Class<?>[]{  Object.class,
                                      Object.class});
      System.out.println("构造方法:"
                + constructor
                + " \n带有的异常:"
                + Castors.me().castToString(constructor.getExceptionTypes()));
    }
    a1.getRunnable();
    a1.getEnum();
    System.out.println("-Demo Over-");
  }
View Full Code Here

Examples of org.nutz.aop.asm.test.Aop1

    }

    @Test
    public void testBorn() {
        Class<Aop1> klass = classAgent.define(Nutzs.cd(), Aop1.class);
        Aop1 a1 = Mirror.me(klass).born("Nut");
        a1.returnObjectArray();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.