项目:bench
文件:ForkedActorManagerTest.java
@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));
}
项目:bench
文件:ForkedActorManagerTest.java
@Theory
public void close_actor_twice(final AgentClusterRule agentCluster)
throws ValidationException,rdvFileInit);
ManagedActor actor = actorManager.createActor(actorConfig);
ProcessWatchDogThread watchDogThread = actorManager.getProcesses().get(DUMMY_ACTOR);
verifyFileContentWithin(rdvFileInit,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(true));
}
项目:bench
文件:WatcherActorsTest.java
/**
* 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());
}
项目:bench
文件:WatcherActorsTest.java
@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,stopSampling(deployInfo.getPid()));
processesWatcher.dumpMetrics();
sleepUninterruptibly(1,TimeUnit.SECONDS);
assertTrue(getUninterruptibly(metrics).metrics().size() > 0);
getUninterruptibly(systemWatcher.close());
getUninterruptibly(processesWatcher.close());
}
项目:bench
文件:ResourceManagerAgentTest.java
@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);
}
项目:omero-ms-queue
文件:MessageRepeaterTest.java
@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());
}
项目:omero-ms-queue
文件:MessageRepeaterTest.java
@Theory
public void hanlderNeverCalledOnLastDeliveryIfConsumerStops(
Duration[] intervals,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());
}
项目:xpath-to-xml
文件:NotEqualsExprTest.java
@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())));
}
项目:omero-ms-queue
文件:ScheduleTest.java
@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())));
}
}
@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());
}
@Theory
public void addOrderIsRespected(Path p1,Path p3) {
String[] actual = new Classpath()
.add(p1,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);
}
项目:bench
文件:ForkedActorManagerTest.java
@Theory
public void null_parameters_invalid(final AgentClusterRule agentCluster) {
before(agentCluster);
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicConstructors(ForkedActorManager.class);
tester.testAllPublicInstanceMethods(actorManager);
}
项目:bench
文件:ForkedActorManagerTest.java
@Theory
public void create_actor_init_called(final AgentClusterRule agentCluster)
throws ValidationException,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,TimeUnit.SECONDS);
}
项目:personium-core
文件:RangeHeaderHandlerTest.java
/**
* 正常系.
* @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());
}
项目:omero-ms-queue
文件:CryptoSourceReaderTest.java
@Theory
public void writeThenReadisIdentity(byte[] input) throws Exception {
ByteArrayInputStream source = encrypt(input);
byte[] decrypted = decryptionFilter.read(source);
assertArrayEquals(input,decrypted);
}
项目:bench
文件:ForkedActorManagerTest.java
@Theory
public void create_manager_but_cant_create_local_log_dir(final AgentClusterRule agentCluster) throws IOException {
before(agentCluster);
File folder = this.folder.newFolder();
File localLogDir = spy(folder);
doReturn(false).when(localLogDir).mkdirs(); // NOSONAR
doReturn(false).when(localLogDir).exists(); // NOSONAR
expectedException.expect(IllegalStateException.class);
actorManager = new ForkedActorManager(clusterConfigFactory,localLogDir);
}
项目:bench
文件:ForkedActorManagerTest.java
@Theory
public void watchdog_thread_is_interrupted_while_waitfor(final AgentClusterRule agentCluster)
throws InterruptedException {
before(agentCluster);
Process mockedProcess = mock(Process.class);
when(mockedProcess.waitFor()).thenThrow(new InterruptedException());
ProcessWatchDogThread watchdog = new ProcessWatchDogThread(DUMMY_ACTOR.getName(),mockedProcess,actorManager);
watchdog.start();
watchdog.awaitUntilStarted();
watchdog.close();
joinUninterruptibly(watchdog);
assertthat(watchdog.hasProcessExited(),is(false));
}
项目:bench
文件:AgentBootstrapIntegrationTest.java
@Theory
public void bootstrap_with_server(final AgentClusterRule clusterRule) throws Exception {
before(clusterRule);
AgentRegistryListener listener = mock(AgentRegistryListener.class);
registryClusterClient.startRegistryListener(listener);
agentBootstrapThread.start();
verify(listener,timeout(TIMEOUT_MS)).onAgentRegistration(any(AgentRegistrationMessage.class));
verifyNoMoreInteractions(listener);
after(clusterRule);
}
项目:bench
文件:WatcherActorsTest.java
@Theory
public void create_and_initialize_watcher_actors(boolean forked,final supplier supplier)
throws ExecutionException {
BenchRule benchRule = (BenchRule) supplier.get();
before(benchRule);
Actors.ActorHandle systemWatcher = createSystemWatcher(forked);
Actors.ActorHandle processesWatcher = createProcessWatcher(forked);
getUninterruptibly(systemWatcher.actorInitialization());
getUninterruptibly(processesWatcher.actorInitialization());
}
项目:xpath-to-xml
文件:AdditionExprTest.java
@Theory
public void shouldAddLeftViewToRightView(@FromDataPoints("3.0") View<TestNode> left,@FromDataPoints("3.0") View<TestNode> right) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(left);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(right);
ViewContext<TestNode> context = new ViewContext<>(navigator,new NodeView<>(node("node")),false);
// when
assertthat(new AdditionExpr(leftExpr,rightExpr).resolve(context)).extracting("number").contains(6.0);
}
项目:omero-ms-queue
文件:IdentifiableHashTest.java
@Theory
public void negativeNumberOfBucketsIsSameAsPositive(Integer nBuckets) {
assertSameFunction(
buckets(nBuckets,range(-100,100)),buckets(-nBuckets,100))
);
}
项目:bench
文件:ResourceManagerAgentTest.java
@Theory
public void create_and_close_embedded_actor_on_agent(final supplier supplier) throws Exception {
BenchRule benchRule = (BenchRule) supplier.get();
before(benchRule);
List<String> preferredHosts = new ArrayList<>();
ActorSync sync = createActorWith(preferredHosts);
sync.assertActorCreated();
resourceManager.closeActor(DUMMY_ACTOR);
sync.assertActorClosed();
assertthat(actorRegistry.all().size(),is(0));
after(benchRule);
}
项目:xpath-to-xml
文件:SubtractionExprTest.java
@Theory
public void shouldMultiplyLeftViewToRightView(@FromDataPoints("3.0") View<TestNode> left,false);
// when
assertthat(new SubtractionExpr(leftExpr,rightExpr).resolve(context)).extracting("number").contains(0.0);
}
项目:Java-EX
文件:StringUtilTest.java
@Theory
public void testNotExistChars(@TestedOn(ints = { 5,50,500 }) int count) {
StringBuilder sb = new StringBuilder();
IntStream.range(0,count)
.mapToObj(a -> (char) (Math.random() * 100 + 128))
.forEach(sb::append);
String string = sb.toString();
Flowable.fromIterable(() -> notExistChars(string))
.test(0)
.requestMore(count)
.assertNever(c -> string.indexOf(c.charValue()) != -1);
}
@Theory
public void joiningLinesThenReadingIsTheIdentity(String[] lines) {
String expected = buildTextInput(lines);
InputStream input = toInputStream(expected);
String actual = readLinesIntoString(input);
assertthat(actual,is(expected));
}
@Theory
public void shouldResolvetoTrueWhenLeftIsGreaterThanRight(@FromDataPoints("less") View<TestNode> less,@FromDataPoints("greater") View<TestNode> greater) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(greater);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(less);
ViewContext<TestNode> context = new ViewContext<>(navigator,false);
// when
View<TestNode> result = new GreaterThanorEqualsExpr(leftExpr,rightExpr).resolve(context);
// then
assertthat(result).isEqualTo(BooleanView.of(true));
}
项目:omero-ms-queue
文件:WrapperTest.java
@Theory
public void equalsDelegatesToWrappedValue(Wrapper<String> w,String x) {
assumeTrue(w != null); // (*)
String wrappedValue = w.get();
assertthat(w.equals(x),is(wrappedValue.equals(x)));
}
项目:omero-ms-queue
文件:SerializationFactoryTest.java
@Theory
public void serializeThenDeserializeIsIdentity(CryptoConfigSource config,String value)
throws Exception{
SerializationFactory sf = new SerializationFactory(config);
ByteArrayOutputStream sink = new ByteArrayOutputStream();
sf.serializer().write(sink,value);
ByteArrayInputStream source =
new ByteArrayInputStream(sink.toByteArray());
String deserialized = sf.deserializer(String.class).read(source);
assertthat(deserialized,is(value));
}
项目:omero-ms-queue
文件:RemoteMountTest.java
@Theory
public void nullNeverTranslatesToLocalPath(
RemoteBase remote,LocalBase local) {
RemoteMount target = new RemoteMount(uri(remote),path(local));
Optional<Path> actual = target.toLocalPath(null);
assertFalse(actual.isPresent());
}
项目:omero-ms-queue
文件:RemoteMountTest.java
@Theory
public void localPathNeverTranslatesToLocalPath(
RemoteBase remote,LocalBase local,String path) {
RemoteMount target = new RemoteMount(uri(remote),path(local));
Optional<Path> actual = target.toLocalPath(uri(path));
assertFalse(actual.isPresent());
}
项目:omero-ms-queue
文件:RemoteMountTest.java
@Theory
public void translateRemotePathIfSameRemotePrefix(
RemoteBase remote,path(local));
URI input = join(remote,path);
Path expected = join(local,path);
Optional<Path> actual = target.toLocalPath(input);
assertTrue(actual.isPresent());
assertthat(actual.get(),is(expected));
}
项目:omero-ms-queue
文件:RemoteMountTest.java
@Theory
public void neverTranslateRemotePathIfNotSameRemotePrefix(
RemoteBase remote,String path) {
assumeThat(remote.get(),not(endsWith("/")));
RemoteMount target = new RemoteMount(uri(remote),path(local));
RemoteBase otherRemote = new RemoteBase(remote.get() + "different");
URI input = join(otherRemote,path);
Optional<Path> actual = target.toLocalPath(input);
assertFalse(actual.isPresent());
}
项目:omero-ms-queue
文件:RemoteFilePathTest.java
@Theory
public void isRemoteJustInCaseIsFileSchemeAndHasHost(
Scheme s,Host h,String path) {
String scheme = s.get(),host = h.get();
URI x = buildURI(scheme,host,path);
boolean expected = "file".equals(scheme) && !host.isEmpty();
boolean actual = RemoteMount.isRemoteFilePath(x);
assertthat(actual,is(expected));
}
项目:omero-ms-queue
文件:ImportBatchStatusTest.java
@Theory
public void allProcessedTrueIfAllImportsBeenAdded(int nSuccess,int nFails) {
assumeTrue(isPartition(nSuccess,nFails));
markCompletions(target,nSuccess,nFails);
assertTrue(target.allProcessed());
assertSuccessAndFailSetsAredisjoint(nSuccess,nFails);
}
项目:omero-ms-queue
文件:WrapperTest.java
@Theory
public void toStringDelegatesToWrappedValue(Wrapper<String> w) {
assumeTrue(w != null); // (*)
String wrappedValue = w.get();
assertthat(w.toString(),is(wrappedValue));
}
项目:omero-ms-queue
文件:EithersPartitionTest.java
@Theory
public void leaveLeftNullsBe(String[] ls) {
Stream<Either<String,Integer>> xs = asstream(ls).map(Either::left);
List<String> actual = partitionEithers(xs).fst();
assertthat(actual,contains(ls));
}
@Theory
public void shouldResolvetoTrueWhenLeftIsLessthanRight(@FromDataPoints("less") View<TestNode> less,@FromDataPoints("greater") View<TestNode> greater) {
// given
when(leftExpr.resolve(any(ViewContext.class))).thenReturn(less);
when(rightExpr.resolve(any(ViewContext.class))).thenReturn(greater);
ViewContext<TestNode> context = new ViewContext<>(navigator,false);
// when
View<TestNode> result = new LessthanorEqualsExpr(leftExpr,rightExpr).resolve(context);
// then
assertthat(result).isEqualTo(BooleanView.of(true));
}
项目:omero-ms-queue
文件:RemotePathMapperTest.java
@Theory
public void forceLocalPathSameAsToLocalPathWhenInputIsMatchingRemotePath(
RemoteMount[] remotetoLocalmap,URI matchingRemotePath) {
assumeThat(remotetoLocalmap.length,greaterThan(0));
RemotePathResolver target = resolver(remotetoLocalmap);
Path p1 = target.forceLocalPath(matchingRemotePath);
Optional<Path> p2 = target.toLocalPath(matchingRemotePath);
assertNotNull(p1);
assertNotNull(p2);
assertTrue(p2.isPresent());
assertthat(p1,is(p2.get()));
}
项目:omero-ms-queue
文件:EithersPartitionTest.java
@Theory
public void leaveRightNullsBe(Integer[] rs) {
Stream<Either<String,Integer>> xs = asstream(rs).map(Either::right);
List<Integer> actual = partitionEithers(xs).snd();
assertthat(actual,contains(rs));
}
项目:omero-ms-queue
文件:ImportOutcomeNotifierTest.java
@Theory
public void userIsAlwaysNotified(
ImportBatchStatus outcome,String sysAdminemail) {
ImportEnv env = mockedImportEnvWithMemBatchStore(sysAdminemail);
ImportOutcomeNotifier target = new ImportOutcomeNotifier(env,outcome);
target.notifyOutcome();
Email user = ImportOutcomeNotifier.findAnyEmail(outcome);
verify(env.mail(),times(1)).enqueue(
argThat(hasRecipientOf(user.get())));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。