use of java.util.Arrays in project vert.x by eclipse.
the class Http2ServerTest method testRequestResponseLifecycle.
@Test
public void testRequestResponseLifecycle() throws Exception {
waitFor(2);
server.requestHandler(req -> {
req.endHandler(v -> {
assertIllegalStateException(() -> req.setExpectMultipart(false));
assertIllegalStateException(() -> req.handler(buf -> {
}));
assertIllegalStateException(() -> req.uploadHandler(upload -> {
}));
assertIllegalStateException(() -> req.endHandler(v2 -> {
}));
complete();
});
HttpServerResponse resp = req.response();
resp.setChunked(true).write(Buffer.buffer("whatever"));
assertTrue(resp.headWritten());
assertIllegalStateException(() -> resp.setChunked(false));
assertIllegalStateException(() -> resp.setStatusCode(100));
assertIllegalStateException(() -> resp.setStatusMessage("whatever"));
assertIllegalStateException(() -> resp.putHeader("a", "b"));
assertIllegalStateException(() -> resp.putHeader("a", (CharSequence) "b"));
assertIllegalStateException(() -> resp.putHeader("a", (Iterable<String>) Arrays.asList("a", "b")));
assertIllegalStateException(() -> resp.putHeader("a", (Arrays.<CharSequence>asList("a", "b"))));
assertIllegalStateException(resp::writeContinue);
resp.end();
assertIllegalStateException(() -> resp.write("a"));
assertIllegalStateException(() -> resp.write("a", "UTF-8"));
assertIllegalStateException(() -> resp.write(Buffer.buffer("a")));
assertIllegalStateException(resp::end);
assertIllegalStateException(() -> resp.end("a"));
assertIllegalStateException(() -> resp.end("a", "UTF-8"));
assertIllegalStateException(() -> resp.end(Buffer.buffer("a")));
assertIllegalStateException(() -> resp.sendFile("the-file.txt"));
assertIllegalStateException(() -> resp.reset(0));
assertIllegalStateException(() -> resp.closeHandler(v -> {
}));
assertIllegalStateException(() -> resp.endHandler(v -> {
}));
assertIllegalStateException(() -> resp.drainHandler(v -> {
}));
assertIllegalStateException(() -> resp.exceptionHandler(err -> {
}));
assertIllegalStateException(resp::writeQueueFull);
assertIllegalStateException(() -> resp.setWriteQueueMaxSize(100));
assertIllegalStateException(() -> resp.putTrailer("a", "b"));
assertIllegalStateException(() -> resp.putTrailer("a", (CharSequence) "b"));
assertIllegalStateException(() -> resp.putTrailer("a", (Iterable<String>) Arrays.asList("a", "b")));
assertIllegalStateException(() -> resp.putTrailer("a", (Arrays.<CharSequence>asList("a", "b"))));
assertIllegalStateException(() -> resp.push(HttpMethod.GET, "/whatever", ar -> {
}));
complete();
});
startServer();
TestClient client = new TestClient();
ChannelFuture fut = client.connect(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, request -> {
int id = request.nextStreamId();
request.encoder.writeHeaders(request.context, id, GET("/"), 0, true, request.context.newPromise());
request.context.flush();
});
fut.sync();
await();
}
use of java.util.Arrays in project buck by facebook.
the class AbstractJavacOptions method appendOptionsTo.
public void appendOptionsTo(OptionsConsumer optionsConsumer, SourcePathResolver pathResolver, ProjectFilesystem filesystem) {
// Add some standard options.
optionsConsumer.addOptionValue("source", getSourceLevel());
optionsConsumer.addOptionValue("target", getTargetLevel());
// Set the sourcepath to stop us reading source files out of jars by mistake.
optionsConsumer.addOptionValue("sourcepath", "");
if (isDebug()) {
optionsConsumer.addFlag("g");
}
if (isVerbose()) {
optionsConsumer.addFlag("verbose");
}
// Override the bootclasspath if Buck is building Java code for Android.
if (getBootclasspath().isPresent()) {
optionsConsumer.addOptionValue("bootclasspath", getBootclasspath().get());
} else {
String bcp = getSourceToBootclasspath().get(getSourceLevel());
if (bcp != null) {
optionsConsumer.addOptionValue("bootclasspath", bcp);
}
}
// Add annotation processors.
AnnotationProcessingParams annotationProcessingParams = getAnnotationProcessingParams();
if (!annotationProcessingParams.isEmpty()) {
// Specify where to generate sources so IntelliJ can pick them up.
Path generateTo = annotationProcessingParams.getGeneratedSourceFolderName();
if (generateTo != null) {
//noinspection ConstantConditions
optionsConsumer.addOptionValue("s", filesystem.resolve(generateTo).toString());
}
ImmutableList<ResolvedJavacPluginProperties> annotationProcessors = annotationProcessingParams.getAnnotationProcessors(filesystem, pathResolver);
// Specify processorpath to search for processors.
optionsConsumer.addOptionValue("processorpath", annotationProcessors.stream().map(ResolvedJavacPluginProperties::getClasspath).flatMap(Arrays::stream).distinct().map(URL::toString).collect(Collectors.joining(File.pathSeparator)));
// Specify names of processors.
optionsConsumer.addOptionValue("processor", annotationProcessors.stream().map(ResolvedJavacPluginProperties::getProcessorNames).flatMap(Collection::stream).collect(Collectors.joining(",")));
// Add processor parameters.
for (String parameter : annotationProcessingParams.getParameters()) {
optionsConsumer.addFlag("A" + parameter);
}
if (annotationProcessingParams.getProcessOnly()) {
optionsConsumer.addFlag("proc:only");
}
}
// Add extra arguments.
optionsConsumer.addExtras(getExtraArguments());
}
use of java.util.Arrays in project intellij-community by JetBrains.
the class ContractInferenceInterpreter method visitExpression.
@NotNull
private List<PreContract> visitExpression(final List<ValueConstraint[]> states, @Nullable LighterASTNode expr) {
if (expr == null)
return emptyList();
if (states.isEmpty())
return emptyList();
// too complex
if (states.size() > 300)
return emptyList();
IElementType type = expr.getTokenType();
if (type == POLYADIC_EXPRESSION || type == BINARY_EXPRESSION) {
return visitPolyadic(states, expr);
}
if (type == CONDITIONAL_EXPRESSION) {
List<LighterASTNode> children = getExpressionChildren(myTree, expr);
if (children.size() != 3)
return emptyList();
List<PreContract> conditionResults = visitExpression(states, children.get(0));
return ContainerUtil.concat(visitExpression(antecedentsReturning(conditionResults, TRUE_VALUE), children.get(1)), visitExpression(antecedentsReturning(conditionResults, FALSE_VALUE), children.get(2)));
}
if (type == PARENTH_EXPRESSION) {
return visitExpression(states, findExpressionChild(myTree, expr));
}
if (type == TYPE_CAST_EXPRESSION) {
return visitExpression(states, findExpressionChild(myTree, expr));
}
if (isNegationExpression(expr)) {
return ContainerUtil.mapNotNull(visitExpression(states, findExpressionChild(myTree, expr)), PreContract::negate);
}
if (type == INSTANCE_OF_EXPRESSION) {
final int parameter = resolveParameter(findExpressionChild(myTree, expr));
if (parameter >= 0) {
return asPreContracts(ContainerUtil.mapNotNull(states, state -> contractWithConstraint(state, parameter, NULL_VALUE, FALSE_VALUE)));
}
}
if (type == NEW_EXPRESSION || type == THIS_EXPRESSION) {
return asPreContracts(toContracts(states, NOT_NULL_VALUE));
}
if (type == METHOD_CALL_EXPRESSION) {
return singletonList(new MethodCallContract(ExpressionRange.create(expr, myBody.getStartOffset()), ContainerUtil.map(states, Arrays::asList)));
}
final ValueConstraint constraint = getLiteralConstraint(expr);
if (constraint != null) {
return asPreContracts(toContracts(states, constraint));
}
int paramIndex = resolveParameter(expr);
if (paramIndex >= 0) {
List<MethodContract> result = ContainerUtil.newArrayList();
for (ValueConstraint[] state : states) {
if (state[paramIndex] != ANY_VALUE) {
// the second 'o' reference in cases like: if (o != null) return o;
result.add(new MethodContract(state, state[paramIndex]));
} else if (JavaTokenType.BOOLEAN_KEYWORD == getPrimitiveParameterType(paramIndex)) {
// if (boolValue) ...
ContainerUtil.addIfNotNull(result, contractWithConstraint(state, paramIndex, TRUE_VALUE, TRUE_VALUE));
ContainerUtil.addIfNotNull(result, contractWithConstraint(state, paramIndex, FALSE_VALUE, FALSE_VALUE));
}
}
return asPreContracts(result);
}
return emptyList();
}
use of java.util.Arrays in project Gargoyle by callakrsos.
the class DaoWizardViewController method btnExecOnMouseClick.
/**
* 텍스트에 기술된 SQL문을 실행한다. 기본적으로 ROWNUM 기술문을 100개를 감싸서 SQL을 조회한다.
*
* @작성자 : KYJ
* @작성일 : 2015. 10. 21.
*/
@FXML
public void btnExecOnMouseClick(MouseEvent e) {
LOGGER.debug("event] btnExecOnMouseClick");
String velocitySQL = txtSql.getText().trim();
if (velocitySQL == null || velocitySQL.isEmpty())
return;
LOGGER.debug(String.format("velocitySQL : %s", velocitySQL));
// 파라미터 컬럼값 반환받는다.
ObservableList<TbpSysDaoFieldsDVO> items = tbParams.getItems();
Map<String, TbpSysDaoColumnsDVO> unmapping = this.tbMappings.getItems().stream().filter(v -> {
String lockYn = v.getLockYn();
if ("Y".equals(lockYn))
return true;
return false;
}).collect(Collectors.toMap(TbpSysDaoColumnsDVO::getColumnName, v -> v));
Map<String, Object> paramMap = items.stream().filter(vo -> vo.getTestValue() != null && !vo.getTestValue().isEmpty()).collect(Collectors.toMap(TbpSysDaoFieldsDVO::getFieldName, new Function<TbpSysDaoFieldsDVO, Object>() {
@Override
public Object apply(TbpSysDaoFieldsDVO t) {
if ("Arrays".equals(t.getType())) {
String pattern = "'[^']{0,}'";
List<String> regexMatchs = ValueUtil.regexMatchs(pattern, t.getTestValue(), str -> {
return str.substring(1, str.length() - 1);
});
return regexMatchs;
}
return t.getTestValue();
}
}));
SimpleSQLResultView simpleSQLResultView = new SimpleSQLResultView(velocitySQL, paramMap);
try {
simpleSQLResultView.show();
List<TableModelDVO> columns = simpleSQLResultView.getColumns();
List<TbpSysDaoColumnsDVO> resultList = columns.stream().map(vo -> {
TbpSysDaoColumnsDVO dvo = new TbpSysDaoColumnsDVO();
dvo.setColumnName(vo.getDatabaseColumnName());
String databaseTypeName = vo.getDatabaseTypeName();
dvo.setColumnType(databaseTypeName);
if (unmapping.containsKey(vo.getDatabaseColumnName())) {
TbpSysDaoColumnsDVO tmp = unmapping.get(vo.getDatabaseColumnName());
dvo.setProgramType(tmp.getProgramType());
dvo.setLockYn(tmp.getLockYn());
} else {
String programType = DatabaseTypeMappingResourceLoader.getInstance().get(databaseTypeName);
dvo.setProgramType(programType);
}
return dvo;
}).collect(Collectors.toList());
// if (!this.tbMappings.getItems().isEmpty())
if (!resultList.isEmpty()) {
try {
this.tbMappings.getItems().clear();
getSelectedMethodItem().getTbpSysDaoColumnsDVOList().clear();
this.tbMappings.getItems().addAll(resultList);
getSelectedMethodItem().getTbpSysDaoColumnsDVOList().addAll(resultList);
} catch (NullPointerException n) {
DialogUtil.showMessageDialog("메소드를 선택해주세요.");
}
}
} catch (IOException e1) {
LOGGER.error(ValueUtil.toString(e1));
DialogUtil.showExceptionDailog(e1);
}
}
use of java.util.Arrays in project gatk-protected by broadinstitute.
the class IntegerCopyNumberTransitionProbabilityCacheUnitTest method testBasicSoundness.
@Test
public void testBasicSoundness() {
for (final RealMatrix transitionMatrix : TRANSITION_MATRICES) {
final IntegerCopyNumberTransitionProbabilityCache cache = new IntegerCopyNumberTransitionProbabilityCache(new IntegerCopyNumberTransitionMatrix(transitionMatrix, 0));
for (final int dist : DISTANCES) {
final RealMatrix transitionMatrixExponentiated = cache.getTransitionProbabilityMatrix(dist);
/* assert positivity */
Assert.assertTrue(Arrays.stream(transitionMatrixExponentiated.getData()).flatMapToDouble(Arrays::stream).allMatch(d -> d >= 0));
/* assert conservation of probability */
for (int c = 0; c < transitionMatrix.getColumnDimension(); c++) {
Assert.assertEquals(Arrays.stream(transitionMatrixExponentiated.getColumn(c)).sum(), 1.0, EPSILON);
}
/* assert correctness, T(2*d) = T(d)*T(d) */
assertEqualMatrices(cache.getTransitionProbabilityMatrix(2 * dist), transitionMatrixExponentiated.multiply(transitionMatrixExponentiated));
}
/* assert loss of initial state over long distances, i.e. all columns must be equal */
final RealMatrix longRangeTransitionMatrix = cache.getTransitionProbabilityMatrix(Integer.MAX_VALUE);
final double[] firstColumn = longRangeTransitionMatrix.getColumn(0);
final RealMatrix syntheticLongRangeTransitionMatrix = new Array2DRowRealMatrix(firstColumn.length, firstColumn.length);
for (int i = 0; i < firstColumn.length; i++) {
syntheticLongRangeTransitionMatrix.setColumn(i, firstColumn);
}
assertEqualMatrices(longRangeTransitionMatrix, syntheticLongRangeTransitionMatrix);
final double[] stationary = cache.getStationaryProbabilityVector().toArray();
ArrayAsserts.assertArrayEquals(stationary, firstColumn, EPSILON);
}
}
Aggregations