当前位置: 首页>>代码示例>>Java>>正文


Java TearDownAccepter.addTearDown方法代码示例

本文整理汇总了Java中com.google.common.testing.TearDownAccepter.addTearDown方法的典型用法代码示例。如果您正苦于以下问题:Java TearDownAccepter.addTearDown方法的具体用法?Java TearDownAccepter.addTearDown怎么用?Java TearDownAccepter.addTearDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.testing.TearDownAccepter的用法示例。


在下文中一共展示了TearDownAccepter.addTearDown方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: repeatedlyInterruptTestThread

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
static void repeatedlyInterruptTestThread(
    long interruptPeriodMillis, TearDownAccepter tearDownAccepter) {
  final Interruptenator interruptingTask =
      new Interruptenator(Thread.currentThread(), interruptPeriodMillis);
  final Thread interruptingThread = new Thread(interruptingTask);
  interruptingThread.start();
  tearDownAccepter.addTearDown(new TearDown() {
    @Override public void tearDown() throws Exception {
      interruptingTask.stopInterrupting();
      interruptingThread.interrupt();
      joinUninterruptibly(interruptingThread, 2500, MILLISECONDS);
      Thread.interrupted();
      if (interruptingThread.isAlive()) {
        // This will be hidden by test-output redirection:
        logger.severe(
            "InterruptenatorTask did not exit; future tests may be affected");
        /*
         * This won't do any good under JUnit 3, but I'll leave it around in
         * case we ever switch to JUnit 4:
         */
        fail();
      }
    }
  });
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:InterruptionUtil.java

示例2: getTestWrapper

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Provides
@Singleton
TestWrapper getTestWrapper(final TestId testId,
    final TearDownAccepter tearDownAccepter) {
  
  return new TestWrapper() {
    
    public void toRunBeforeTest() {
      tearDownAccepter.addTearDown(new TearDown() {
        
        public void tearDown() throws Exception {
          System.out.println("Ending: " + testId);
        }
      });
      System.out.println("Beginning: " + testId);
    }
  };
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:19,代码来源:Example3TestWrapperTest.java

示例3: getTestWrapper

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Provides
TestWrapper getTestWrapper(final TestId testId,
    final TearDownAccepter tearDownAccepter) {
  
  return new TestWrapper() {
    
    public void toRunBeforeTest() {
      tearDownAccepter.addTearDown(new TearDown() {
        
        public void tearDown() throws Exception {
          System.out.println("Ending: " + testId);
        }
      });
      System.out.println("Beginning: " + testId);
    }
  };
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:18,代码来源:Example3TestWrapperTest.java

示例4: repeatedlyInterruptTestThread

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
static void repeatedlyInterruptTestThread(
    long interruptPeriodMillis, TearDownAccepter tearDownAccepter) {
  final Interruptenator interruptingTask =
      new Interruptenator(Thread.currentThread(), interruptPeriodMillis);
  final Thread interruptingThread = new Thread(interruptingTask);
  interruptingThread.start();
  tearDownAccepter.addTearDown(
      new TearDown() {
        @Override
        public void tearDown() throws Exception {
          interruptingTask.stopInterrupting();
          interruptingThread.interrupt();
          joinUninterruptibly(interruptingThread, 2500, MILLISECONDS);
          Thread.interrupted();
          if (interruptingThread.isAlive()) {
            // This will be hidden by test-output redirection:
            logger.severe("InterruptenatorTask did not exit; future tests may be affected");
            /*
             * This won't do any good under JUnit 3, but I'll leave it around in
             * case we ever switch to JUnit 4:
             */
            fail();
          }
        }
      });
}
 
开发者ID:google,项目名称:guava,代码行数:27,代码来源:InterruptionUtil.java

示例5: adapt

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
private static TestWrapper adapt(
    final com.google.inject.testing.guiceberry.TestScopeListener instance,
    final TearDownAccepter tearDownAccepter) {
  return new TestWrapper() {

    public void toRunBeforeTest() {
      tearDownAccepter.addTearDown(new TearDown() {
        public void tearDown() throws Exception {
          instance.exitingScope();
        }
      });
      instance.enteringScope();
    }
  };
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:16,代码来源:GuiceBerryUniverse.java

示例6: maybeAddGuiceBerryTearDown

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Deprecated
public static void maybeAddGuiceBerryTearDown(
    ThreadLocal<TearDown> scaffoldingThreadLocal, final TestDescription testDescription,
    final TearDown toTearDown) {
  Object testToTearDown = testDescription.getTestCase();
  if (testToTearDown instanceof TearDownAccepter) {
    TearDownAccepter tdtc = (TearDownAccepter) testToTearDown;
    tdtc.addTearDown(toTearDown);
  } else {
    scaffoldingThreadLocal.set(toTearDown);
  }
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:13,代码来源:DeprecatedGuiceBerryModule.java

示例7: getWrapper

import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@Provides
TestWrapper getWrapper(final TearDownAccepter tearDownAccepter) {
  
  return new TestWrapper() {
    public void toRunBeforeTest() {
      tearDownAccepter.addTearDown(new TearDown() {
        public void tearDown() throws Exception {
          beforeTestTearDownHasRun = true;
        }
      });
      throw new RuntimeException("kaboom");
    }
  };
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:16,代码来源:GuiceBerryUniverseTest.java


注:本文中的com.google.common.testing.TearDownAccepter.addTearDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。