當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。