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


Java Theory类代码示例

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


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

示例1: close_actor_and_watchdog_detects

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void close_actor_and_watchdog_detects(final AgentClusterRule agentCluster)
        throws ValidationException, IOException, InterruptedException {
    before(agentCluster);
    File rdvFileInit = folder.newFile();
    ActorConfig actorConfig = configWithInitRdv(TestActorWriter.class.getName(), rdvFileInit);
    ManagedActor actor = actorManager.createActor(actorConfig);

    ProcessWatchDogThread watchDogThread = actorManager.getProcesses().get(DUMMY_ACTOR);
    assertNotNull(watchDogThread);

    // Sync with process
    verifyFileContentWithin(rdvFileInit, TestActorWriter.OK, MAX_TIMEOUT_SEC, TimeUnit.SECONDS);

    actor.close();

    // We do not check the fact that the shutdown hook is actually called here
    joinUninterruptibly(watchDogThread);

    assertThat(actorManager.getProcesses().size(), is(0));
    assertThat(watchDogThread.hasProcessExited(), is(true));
}
 
开发者ID:florentw,项目名称:bench,代码行数:23,代码来源:ForkedActorManagerTest.java

示例2: close_actor_twice

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void close_actor_twice(final AgentClusterRule agentCluster)
        throws ValidationException, IOException, InterruptedException {
    before(agentCluster);
    File rdvFileInit = folder.newFile();
    ActorConfig actorConfig = configWithInitRdv(TestActorWriter.class.getName(), rdvFileInit);
    ManagedActor actor = actorManager.createActor(actorConfig);

    ProcessWatchDogThread watchDogThread = actorManager.getProcesses().get(DUMMY_ACTOR);

    verifyFileContentWithin(rdvFileInit, TestActorWriter.OK, MAX_TIMEOUT_SEC, TimeUnit.SECONDS);

    actor.close();
    actor.close();

    // We do not check the fact that the shutdown hook is actually called here
    joinUninterruptibly(watchDogThread);

    assertThat(actorManager.getProcesses().size(), is(0));
    assertThat(watchDogThread.hasProcessExited(), is(true));
}
 
开发者ID:florentw,项目名称:bench,代码行数:22,代码来源:ForkedActorManagerTest.java

示例3: stopWatch_process_monitoring

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
/**
 * Here we monitor the {@link SystemWatcherActor} process using the {@link ProcessWatcherActor}
 *
 * @throws ExecutionException Not expected
 */
@Theory
public void stopWatch_process_monitoring(boolean forked, final Supplier supplier) throws ExecutionException {
    BenchRule benchRule = (BenchRule) supplier.get();
    before(benchRule);
    MetricsRepository metricsRepository = benchRule.metricsRepository();
    Future<MetricValuesMessage> metrics = metricsRepository.expectValuesFor(PROCESS_WATCHER);

    Actors.ActorHandle systemWatcher = createAndInitSystemWatcher(forked);
    Actors.ActorHandle processesWatcher = createProcessWatcher(forked);
    ActorDeployInfo deployInfo = getUninterruptibly(processesWatcher.actorInitialization());

    processesWatcher.send(PROCESS_WATCHER.getName(), startStopwatch(deployInfo.getPid(), METRIC_KEY));

    sleepUninterruptibly(2, TimeUnit.SECONDS);

    processesWatcher.send(PROCESS_WATCHER.getName(), stopStopwatch(deployInfo.getPid(), METRIC_KEY));

    processesWatcher.dumpMetrics();
    sleepUninterruptibly(1, TimeUnit.SECONDS);
    assertThat(getUninterruptibly(metrics).metrics().size(), is(13));
    getUninterruptibly(systemWatcher.close());
    getUninterruptibly(processesWatcher.close());
}
 
开发者ID:florentw,项目名称:bench,代码行数:29,代码来源:WatcherActorsTest.java

示例4: sampling_process_monitoring

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void sampling_process_monitoring(boolean forked, final Supplier supplier) throws ExecutionException {
    BenchRule benchRule = (BenchRule) supplier.get();
    before(benchRule);
    Future<MetricValuesMessage> metrics = metricsRepository.expectValuesFor(PROCESS_WATCHER);

    Actors.ActorHandle systemWatcher = createAndInitSystemWatcher(forked);
    Actors.ActorHandle processesWatcher = createProcessWatcher(forked);
    ActorDeployInfo deployInfo = getUninterruptibly(processesWatcher.actorInitialization());

    processesWatcher.send(PROCESS_WATCHER.getName(), startSampling(deployInfo.getPid(), 1, METRIC_KEY));

    sleepUninterruptibly(2, TimeUnit.SECONDS);

    processesWatcher.send(PROCESS_WATCHER.getName(), stopSampling(deployInfo.getPid()));

    processesWatcher.dumpMetrics();
    sleepUninterruptibly(1, TimeUnit.SECONDS);
    assertTrue(getUninterruptibly(metrics).metrics().size() > 0);
    getUninterruptibly(systemWatcher.close());
    getUninterruptibly(processesWatcher.close());
}
 
开发者ID:florentw,项目名称:bench,代码行数:23,代码来源:WatcherActorsTest.java

示例5: create_and_close_forked_actor_on_agent

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void create_and_close_forked_actor_on_agent(final Supplier supplier) throws Exception {
    BenchRule benchRule = (BenchRule) supplier.get();
    before(benchRule);

    List<String> jvmArgs = new ArrayList<>();
    jvmArgs.add("-Xmx128m");
    ActorSync sync = createForkedActor(jvmArgs);

    // Verify that the forked actor is properly registered
    assertThat(actorRegistry.all().size(), is(1));
    assertThat(actorRegistry.byKey(DUMMY_ACTOR).getDeployInfo().getCommand(), hasItem(jvmArgs.get(0)));
    assertTrue(actorRegistry.byKey(DUMMY_ACTOR).getDeployInfo().getPid() > 0);
    assertNotNull(actorRegistry.byKey(DUMMY_ACTOR).getDeployInfo().getEndpoint());

    resourceManager.closeActor(DUMMY_ACTOR);

    sync.assertActorClosed();
    assertThat(actorRegistry.all().size(), is(0));
    after(benchRule);
}
 
开发者ID:florentw,项目名称:bench,代码行数:22,代码来源:ResourceManagerAgentTest.java

示例6: repeatWhenConsumerSaysSo

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void repeatWhenConsumerSaysSo(Duration[] intervals, Integer deliveryCount) {
    assumeThat(deliveryCount, lessThanOrEqualTo(intervals.length));
    
    Integer sentData = 2;
    MessageRepeater<Integer> target = newRepeater(intervals, Repeat);
    Optional<Schedule<Integer>> schedule = 
            target.consume(newCountedSchedule(deliveryCount), sentData);
    
    assertTrue(schedule.isPresent());
    assertNear(intervals[deliveryCount - 1], schedule.get().when());
    assertThat(schedule.get().what(), is(sentData));
    
    assertTrue(consumedData.isPresent());
    assertThat(consumedData.get(), is(sentData));
    
    assertFalse(exceededRedeliveryData.isPresent());
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:19,代码来源:MessageRepeaterTest.java

示例7: hanlderNeverCalledOnLastDeliveryIfConsumerStops

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void hanlderNeverCalledOnLastDeliveryIfConsumerStops(
        Duration[] intervals, Integer deliveryCount) {
    assumeThat(deliveryCount, greaterThan(intervals.length));
    
    Integer sentData = 3;
    MessageRepeater<Integer> target = newRepeater(intervals, Stop);
    Optional<Schedule<Integer>> schedule = 
            target.consume(newCountedSchedule(deliveryCount), sentData);
    
    assertFalse(schedule.isPresent());
    
    assertTrue(consumedData.isPresent());
    assertThat(consumedData.get(), is(sentData));
    assertFalse(exceededRedeliveryData.isPresent());
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:17,代码来源:MessageRepeaterTest.java

示例8: shouldApplyRightViewToLeftViewWhenShouldCreate

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void shouldApplyRightViewToLeftViewWhenShouldCreate(@FromDataPoints("ne left") View<TestNode> left,
                                                           @FromDataPoints("ne left") View<TestNode> right) {
    // given
    if (!(left instanceof NodeView)
            && (!(left instanceof NodeSetView) || !(((NodeSetView) left).iterator().next() instanceof NodeView))) {
        expectedException.expect(XmlBuilderException.class);
    }
    when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
    when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
    ViewContext<TestNode> context = new ViewContext<>(navigator, parentNode, true);

    // when
    View<TestNode> result = new NotEqualsExpr(leftExpr, rightExpr).resolve(context);

    // then
    assertThat(result).isEqualTo(BooleanView.of(true));
    verify(navigator).setText(any(TestNode.class), eq(Boolean.toString(!right.toBoolean())));
}
 
开发者ID:SimY4,项目名称:xpath-to-xml,代码行数:20,代码来源:NotEqualsExprTest.java

示例9: equalityAgreesWithHashing

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void equalityAgreesWithHashing(
        FutureTimepoint when1, String what1,
        FutureTimepoint when2, String what2) {
    Schedule<String> s1 = new Schedule<>(when1, what1);
    Schedule<String> s2 = new Schedule<>(when2, what2);

    if (when1.equals(when2) && what1.equals(what2)) {
        assertTrue(s1.equals(s2));
        assertTrue(s2.equals(s1));
        assertThat(s1.hashCode(), is(s2.hashCode()));
    } else {
        assertFalse(s1.equals(s2));
        assertFalse(s2.equals(s1));
        assertThat(s1.hashCode(), is(not(s2.hashCode())));
    }
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:ScheduleTest.java

示例10: fromStringYieldsSameClassPathAsThatBuiltByAppendingPaths

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void fromStringYieldsSameClassPathAsThatBuiltByAppendingPaths(
        Path p1, Path p2, Path p3) {
    String cp = p1 + Separator + p2 + Separator + p3;
    ClassPath parsed = ClassPathFactory.fromString(cp);
    ClassPath built = new ClassPath().add(p1, p2, p3);
    
    assertNotNull(parsed);
    assertThat(parsed, is(built));
    
    String parsedToString = parsed.toString();
    String builtToString = built.toString();
    assertNotNull(parsedToString);
    assertNotNull(builtToString);        
    assertThat(parsedToString, is(builtToString));
    
    Stream<Path> parsedToStream = parsed.toStream();
    Stream<Path> builtToStream = built.toStream();
    assertNotNull(parsedToStream);
    assertNotNull(builtToStream);
    assertArrayEquals(parsedToStream.toArray(), builtToStream.toArray());
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:23,代码来源:ClassPathTest.java

示例11: addOrderIsRespected

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void addOrderIsRespected(Path p1, Path p2, Path p3) {
    String[] actual = new ClassPath()
                     .add(p1, p2, p3)
                     .toStream()
                     .map(Path::toString)
                     .toArray(String[]::new);
    
    LinkedHashSet<String> ps = new LinkedHashSet<>();  // respects add order
    ps.add(p1.toString());
    ps.add(p2.toString());
    ps.add(p3.toString());
    ps.remove("");
    String[] expected = ps.toArray(new String[0]);
    
    assertArrayEquals(expected, actual);
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:ClassPathTest.java

示例12: null_parameters_invalid

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void null_parameters_invalid(final AgentClusterRule agentCluster) {
    before(agentCluster);
    NullPointerTester tester = new NullPointerTester();

    tester.testAllPublicConstructors(ForkedActorManager.class);
    tester.testAllPublicInstanceMethods(actorManager);
}
 
开发者ID:florentw,项目名称:bench,代码行数:9,代码来源:ForkedActorManagerTest.java

示例13: create_actor_init_called

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void create_actor_init_called(final AgentClusterRule agentCluster)
        throws ValidationException, IOException, InterruptedException {
    before(agentCluster);
    File rdvFile = folder.newFile();
    ActorConfig actorConfig = configWithInitRdv(TestActorWriter.class.getName(), rdvFile);

    ManagedActor actor = actorManager.createActor(actorConfig);

    assertNotNull(actor);
    assertThat(actor.getKey(), is(DUMMY_ACTOR));
    verifyFileContentWithin(rdvFile, TestActorWriter.OK, MAX_TIMEOUT_SEC, TimeUnit.SECONDS);
}
 
开发者ID:florentw,项目名称:bench,代码行数:14,代码来源:ForkedActorManagerTest.java

示例14: assertEquals

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
/**
 * 正常系.
 * @param f テストデータ
 * @throws Exception Exception
 */
@Theory
public void 正常系206(Fixture f) throws Exception {
    // 単一バイトレンジ指定のテストなので0固定
    int byteRangeSpecIndex = 0;

    // Rangeヘッダパース
    RangeHeaderHandler range = RangeHeaderHandler.parse(f.rangeHeaderField, f.contentSize);

    // byte-range-setの数チェック
    assertEquals(1, range.getByteRangeSpecCount());

    List<ByteRangeSpec> brss = range.getByteRangeSpecList();
    ByteRangeSpec brs = brss.get(byteRangeSpecIndex);

    // 開始・終了値チェック
    assertEquals(f.expectedFirstBytePos, brs.getFirstBytePos());
    assertEquals(f.expectedLastBytePos, brs.getLastBytePos());

    // Rangeヘッダが有効であることのチェック
    assertEquals(true, range.isValid());

    // 範囲外の指定でないことをチェック
    assertEquals(true, range.isSatisfiable());

    // Content-Lengthのチェック
    assertEquals(f.expectedContentSize, brs.getContentLength());

    // Content-Rangeヘッダのチェック
    assertEquals(f.expectedContentRange, brs.makeContentRangeHeaderField());
}
 
开发者ID:personium,项目名称:personium-core,代码行数:36,代码来源:RangeHeaderHandlerTest.java

示例15: writeThenReadIsIdentity

import org.junit.experimental.theories.Theory; //导入依赖的package包/类
@Theory
public void writeThenReadIsIdentity(byte[] input) throws Exception {
    ByteArrayInputStream source = encrypt(input);
    byte[] decrypted = decryptionFilter.read(source);

    assertArrayEquals(input, decrypted);
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:8,代码来源:CryptoSourceReaderTest.java


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