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

Java TearDownAccepter类代码示例

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

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



TearDownAccepter类属于com.google.common.testing包,在下文中一共展示了TearDownAccepter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: setUp

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
/**
 * Same as {@link #setUp(TearDownAccepter, Class)}, but with the given 
 * {@code guiceBerryEnvSelector}.
 *
 * @see #setUp(TestCase, Class)
 */
public static <T extends TestCase & TearDownAccepter> void setUp(
    /* TeaDownTestCase */ T testCase,
    GuiceBerryEnvSelector guiceBerryEnvSelector) {
  final GuiceBerryWrapper toTearDown = 
    GuiceBerry.INSTANCE.buildWrapper(
        ManualTearDownGuiceBerry.buildTestDescription(testCase, testCase.getName()),
        guiceBerryEnvSelector);
  testCase.addTearDown(new TearDown() {
    
    public void tearDown() throws Exception {
      toTearDown.runAfterTest();
    }
  })  ;
  toTearDown.runBeforeTest();
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:22,代码来源:AutoTearDownGuiceBerry.java


示例3: buildTestWrapperInstance

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
private static TestWrapper buildTestWrapperInstance(Injector injector) {
  TestWrapper result = NoOpTestScopeListener.NO_OP_INSTANCE;
  try {
    boolean hasTestScopeListenerBinding = hasTestScopeListenerBinding(injector);
    boolean hasDeprecatedTestScopeListenerBinding = hasDeprecatedTestScopeListenerBinding(injector);
    if (hasTestScopeListenerBinding && hasDeprecatedTestScopeListenerBinding) {
      throw new RuntimeException(
        "Your GuiceBerry Env has bindings for both the new TestScopeListener and the deprecated one. Please fix.");
    } else if (hasTestScopeListenerBinding) {
      result = injector.getInstance(TestWrapper.class);
    } else if (hasDeprecatedTestScopeListenerBinding) {
      result = adapt(
          injector.getInstance(com.google.inject.testing.guiceberry.TestScopeListener.class),
          injector.getInstance(TearDownAccepter.class));
    }
  } catch (ConfigurationException e) {
    String msg = String.format("Error while creating a TestWrapper: '%s'.",
      e.getMessage());
    throw new RuntimeException(msg, e); 
  }
  return result;
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:23,代码来源:GuiceBerryUniverse.java


示例4: 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


示例5: 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


示例6: 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


示例7: configure

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected void configure() {
  for (Map.Entry<Key<?>, IcStrategy> e : rewriter.entrySet()) {
    bind(IcStrategy.wrap(IcClient.class, e.getKey()))
       .toProvider(new MyClientProvider(
           e.getKey(), 
           getProvider(TestId.class), 
           getProvider(e.getValue().clientSupportClass()),
           getProvider(TearDownAccepter.class)));
  }
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:13,代码来源:ControllableInjectionClientModule.java


示例8: MyClientProvider

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
public MyClientProvider(Key<T> key,  
    Provider<TestId> testIdProvider, 
    Provider<IcStrategy.ClientSupport> clientControllerSupportProvider,
    Provider<TearDownAccepter> tearDownAccepterProvider) {
  this.key = key;
  this.testIdProvider = testIdProvider;
  this.clientControllerSupportProvider = clientControllerSupportProvider;
  this.tearDownAccepterProvider = tearDownAccepterProvider;
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:10,代码来源:ControllableInjectionClientModule.java


示例9: configure

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected void configure() {
  for (Map.Entry<Key<?>, IcStrategy> e : rewriter.entrySet()) {
    bind(IcStrategy.wrap(InjectionController.class, e.getKey()))
       .toProvider(new MyClientProvider(
           e.getKey(), 
           getProvider(TestId.class), 
           getProvider(e.getValue().clientSupportClass()),
           getProvider(TearDownAccepter.class)));
  }
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:13,代码来源:ControllableInjectionClientModule.java


示例10: runBeforeTest

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
public synchronized void runBeforeTest() {
  
  // If anything should go wrong, we "tag" this scaffolding as having failed
  // to acquire an injector, so that the tear down knows to skip the
  // appropriate steps.
  injector = BOGUS_INJECTOR;

  checkPreviousTestCalledTearDown(testDescription);
  
  final Class<? extends Module> gbeClass =
    guiceBerryEnvSelector.guiceBerryEnvToUse(testDescription);
  
  universe.currentTestDescriptionThreadLocal.set(testDescription);
  injector = getAndSetInjector(gbeClass);

  stack.addTearDown(new TearDown() {
    public void tearDown() throws Exception {
      doTearDown();
    }
  });
  
  stack.addTearDown(new TearDown() {
    public void tearDown() throws Exception {
      ToTearDown toTearDown = injector.getInstance(ToTearDown.class);
      toTearDown.runTearDown();
    }
  });
  
  TearDownAccepter accepter = wrappedGetInstance(injector, TearDownAccepter.class, gbeClass);
  buildTestWrapperInstance(injector).toRunBeforeTest();
  
  injectMembersIntoTest(gbeClass, injector); 
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:34,代码来源:GuiceBerryUniverse.java


示例11: 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


示例12: configure

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
@Override
protected void configure() {
  TestScope testScope = new TestScope(universe);
  bind(TestScope.class).toInstance(testScope);
  bindScope(TestScoped.class, testScope);
  bind(TearDownAccepter.class).to(ToTearDown.class);
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:8,代码来源:GuiceBerryModule.java


示例13: 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


示例14: buildTestModule

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
private AbstractModule buildTestModule(final IcMaster icMaster) {
  return new AbstractModule() {
    @Override
    protected void configure() {
      install(icMaster.buildClientModule());
      bind(TestId.class).toInstance(TEST_ID);
      bind(TearDownAccepter.class).toInstance(new TearDownStack());
    }
  };
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:11,代码来源:IcMasterTest.java


示例15: 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


示例16: BrowserProvider

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
@Inject
public BrowserProvider(BrowserFactory browserFactory, TearDownAccepter tearDownAccepter) {
    this.browserFactory = browserFactory;
    this.tearDownAccepter = tearDownAccepter;
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:BrowserProvider.java


示例17: tearDown

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
/**   
 * You should only call this method if your test does <em>not</em> implement 
 * {@link TearDownAccepter}.
 *
 * <p>Stops storing the information that {@link TestCase} (given as the argument) 
 * is being run.
 * 
 * <p>Notifies {@link  TestScopeListener} corresponding to this module (
 * The {@link GuiceBerryEnv} annotation of the test case provides the name  
 * of the module)that {@link TestCase} has just become out of scope.
 * It also causes that {@link TestCase} is removed from the {@code TestScope} 
 * assigned to this  module. 
 * 
 * <p>Do not change the value (if any) of the
 * {@link GuiceBerryEnvRemapper#GUICE_BERRY_ENV_REMAPPER_PROPERTY_NAME} 
 * property, as it will likely cause the wrong {@link GuiceBerryEnv} to be
 * used on your tearDown.
 * 
 * <p>If your code, for whatever reason, happens to synchronize on the test
 * class while calling the {@link #setUp(TestCase)} method, <em>and</em> you 
 * run your tests in parallel, you should likewise synchronize the 
 * {@link #tearDown(TestCase)}.
 *
 * @throws IllegalArgumentException If the {@link TestCase} provided  as an 
 *     argument  has no {@link GuiceBerryEnv} annotation or the module 
 *     provided by this annotation does not exist or {@link TestCase} is not 
 *     a type of {@code Class <? extends Module>}.   
 * @throws RuntimeException If the method {@link GuiceBerryJunit3#setUp(TestCase)} 
 *     wasn't called before calling this method.                                 
 * 
 * @see TestScopeListener
 * @see com.google.guiceberry.TestScoped
 */
public synchronized static void tearDown(TestCase testCase) {
  if (testCase instanceof TearDownAccepter) {
    throw new UnsupportedOperationException("You must not call " +
    		"GuiceBerryJunit3.tearDown (it's only needed for tests that do " +
    		"not implement TearDownAccepter).");
  }
  try {
    scaffoldingThreadLocal.get().tearDown();
  } catch (Exception e) {
    throw new RuntimeException(e);
  } finally {
    scaffoldingThreadLocal.remove();
  }
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:48,代码来源:GuiceBerryJunit3.java


示例18: setUp

import com.google.common.testing.TearDownAccepter; //导入依赖的package包/类
/**
 * Sets up the {@code testCase} by leveraging the 
 * {@link AnnotationBasedGuiceBerryEnvSelector} and automatically registers a 
 * {@link TearDown} (thus the "auto" moniker).
 */
public static <T extends TestCase & TearDownAccepter> void setUp(
    /*TearDownTestCase*/ T testCase) {
  AutoTearDownGuiceBerry.setUp(testCase, AnnotationBasedGuiceBerryEnvSelector.INSTANCE);
}
 
开发者ID:zorzella,项目名称:guiceberry,代码行数:10,代码来源:AnnotationBasedAutoTearDownGuiceBerry.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java StringLiteral类代码示例发布时间:2022-05-23
下一篇:
Java NullValue类代码示例发布时间: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