use of org.opentest4j.AssertionFailedError in project wicket by apache.
the class XmlLicenseHeaderHandler method checkLicenseHeader.
@Override
public boolean checkLicenseHeader(final File file) {
Revision revision = null;
try {
String header = extractLicenseHeader(file, 0, 17);
if (header.startsWith("<?xml")) {
header = header.substring(header.indexOf(LINE_ENDING) + LINE_ENDING.length());
} else {
// Then only take the first 16 lines
String[] headers = header.split(LINE_ENDING);
StringBuilder sb = new StringBuilder();
for (int i = 0; (i < 16) && (i < headers.length); i++) {
if (sb.length() > 0) {
sb.append(LINE_ENDING);
}
sb.append(headers[i]);
}
header = sb.toString();
}
revision = Diff.diff(getLicenseHeader().split(LINE_ENDING), header.split(LINE_ENDING));
} catch (Exception e) {
throw new AssertionFailedError(e.getMessage());
}
return revision.size() == 0;
}
use of org.opentest4j.AssertionFailedError in project dpc-app by CMSgov.
the class TokenResourceTest method testTokenSigning.
@Test
void testTokenSigning() throws IOException, URISyntaxException {
final IParser parser = ctx.newJsonParser();
final IGenericClient attrClient = APITestHelpers.buildAttributionClient(ctx);
// Create a new org and make sure it has no providers
final String m2 = FHIRHelpers.registerOrganization(attrClient, parser, OTHER_ORG_ID, "1112111111", getAdminURL());
// Create a new JWT
final APIAuthHelpers.AuthResponse authResponse = APIAuthHelpers.jwtAuthFlow(this.getBaseURL(), fullyAuthedToken, PUBLIC_KEY_ID, PRIVATE_KEY);
assertAll(() -> assertNotEquals("", authResponse.accessToken, "Should have token"), () -> assertEquals(300, authResponse.expiresIn, "Should be valid for 300 seconds"), () -> assertEquals("system/*.*", authResponse.scope, "Should have correct scope"), () -> assertEquals("bearer", authResponse.tokenType, "Should be a macaroon"));
// Try to authenticate using the private key for org 1 and the token for org 2, should throw an exception, but in the auth handler
final AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> APIAuthHelpers.jwtAuthFlow(this.getBaseURL(), m2, PUBLIC_KEY_ID, PRIVATE_KEY));
error.getMessage();
}
use of org.opentest4j.AssertionFailedError in project josm by openstreetmap.
the class AlignInCircleActionTest method testSelectionEvaluation.
/**
* Various cases of selections in file
* @throws Exception if an error occurs
*/
@Test
void testSelectionEvaluation() throws Exception {
DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleCases.osm")), null);
for (int i = 0; i < 80; i++) {
final String selVal = Integer.toString(i);
Set<OsmPrimitive> sel = ds.allPrimitives().stream().filter(p -> p.hasTag("sel", selVal)).collect(Collectors.toSet());
if (sel.isEmpty())
continue;
ds.setSelected(sel);
boolean selValid = sel.stream().noneMatch(p -> p.hasKey("invalid-selection"));
try {
AlignInCircleAction.buildCommand(ds);
assertTrue(selValid, "sel=" + selVal + " is not valid?");
} catch (InvalidSelection e) {
assertFalse(selValid, "sel=" + selVal + " is not invalid?");
} catch (Exception e) {
throw new AssertionFailedError("test failed: sel=" + selVal, e);
}
}
}
use of org.opentest4j.AssertionFailedError in project nebula-jdbc by nebula-contrib.
the class NebulaResultSetTest method checkReturnedDateTimeValueInNotUTCTimeZone.
@Test
public void checkReturnedDateTimeValueInNotUTCTimeZone() throws SQLException {
log.warn("make sure you have set the timezone in server into CST+8.");
statement.executeUpdate("INSERT VERTEX testNode (theString, theInt, theDouble, theTrueBool, theFalseBool, theDate, theTime, theDatetime) " + "VALUES \"testNode_9\":(\"Summer\", 19, 93.65, true, false, date(\"1950-01-26\"), time(\"17:23:30.153\"), datetime(\"1950-07-15T01:06:20.456\"));");
NebulaResultSet resultSet = (NebulaResultSet) statement.executeQuery("MATCH (v:testNode) RETURN id(v) AS id ,v.testNode.theDate as theDate, v.testNode.theTime as theTime, v.testNode.theDatetime as theDatetime ORDER BY id ASC");
resultSet.absolute(7);
try {
assertEquals(Date.valueOf("1950-01-26"), resultSet.getDate("theDate"));
assertEquals(Time.valueOf("09:23:30"), resultSet.getTime("theTime"));
DateTimeWrapper theDatetime = resultSet.getDateTime("theDatetime");
assertEquals(1950, theDatetime.getYear());
assertEquals(7, theDatetime.getMonth());
assertEquals(14, theDatetime.getDay());
assertEquals(17, theDatetime.getHour());
assertEquals(6, theDatetime.getMinute());
assertEquals(20, theDatetime.getSecond());
} catch (AssertionFailedError e) {
log.error("error occurs here, maybe time zone in server is not CST+8");
statement.executeUpdate("DELETE VERTEX \"testNode_9\"");
}
}
use of org.opentest4j.AssertionFailedError in project invesdwin-util by invesdwin.
the class ExpressionParserTest method testIfParametersOperator.
@Test
public void testIfParametersOperator() {
for (final Op op : Op.values()) {
if (op == Op.NOT || op == Op.CROSSES_ABOVE || op == Op.CROSSES_BELOW) {
continue;
}
try {
String opStr = op.toString();
if (Characters.isAsciiAlpha(opStr.charAt(0))) {
opStr = " " + opStr + " ";
}
final IExpression parsed = new ExpressionParser("if(random" + opStr + "random,1,0)") {
@Override
protected IParsedExpression simplify(final IParsedExpression expression) {
return expression;
}
}.parse();
Assertions.checkEquals("if((random " + op + " random), 1, 0)", parsed.toString());
final IExpression parsedAgain = new ExpressionParser(parsed.toString()) {
@Override
protected IParsedExpression simplify(final IParsedExpression expression) {
return expression;
}
}.parse();
Assertions.checkEquals(parsed.toString(), parsedAgain.toString());
} catch (final Throwable t) {
if (t instanceof AssertionFailedError) {
throw t;
} else {
throw new RuntimeException("At: " + op, t);
}
}
}
}
Aggregations