Ejemplo n.º 1
0
 @Test(expected = BizdevIncokeLimitationException.class)
 public void testUnitLimit()
     throws SecurityException, NoSuchMethodException, InterruptedException {
   Method method = myService.getClass().getDeclaredMethod("service1");
   while (true) {
     unitLimitWrapper.beforeTargetInvokedManual(method);
     myService.service1();
   }
 }
Ejemplo n.º 2
0
  @Before
  public void init() {
    unitLimitWrapper = new UnitLimitWrapper();
    myService = new MyServiceImpl();
    unitLimitWrapper.setSpecifiedMethods(
        new HashMap<String, Map<String, Object>>() {
          /** */
          private static final long serialVersionUID = 1L;

          {
            put(
                MyServiceImpl.class.getName(),
                new HashMap<String, Object>() {
                  /** */
                  private static final long serialVersionUID = 1L;

                  {
                    put(
                        AbstractLimitWrapper.METHOD_KEY,
                        new HashSet<String>() {
                          /** */
                          private static final long serialVersionUID = 1L;

                          {
                            add("service1");
                          }
                        });
                    put(
                        AbstractLimitWrapper.LIMIT_KEY,
                        Math.min((long) (Integer.MAX_VALUE * Math.random()), (long) Math.pow(10, 9))
                            / 100000);
                    put(
                        AbstractLimitWrapper.TIME_UNIT_KEY,
                        timeUntis[(int) (timeUntis.length * Math.random())]);
                  }
                });
          }
        });
  }