本文整理汇总了Java中org.junit.Assert.fail方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.fail方法的具体用法?Java Assert.fail怎么用?Java Assert.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.Assert
的用法示例。
在下文中一共展示了Assert.fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertCorrectCommandResultAndConsoleOutput
import org.junit.Assert; //导入方法依赖的package包/类
/**
* Checks if the {@link CommandResult} and the console output is correct.
*
* @param consoleOutput the redirected console output
* @throws NoSuchFieldException if reflection did not work
* @throws SecurityException if reflection did not work
* @throws IllegalArgumentException if reflection did not work
* @throws IllegalAccessException if reflection did not work
*/
private void assertCorrectCommandResultAndConsoleOutput(String consoleOutput)
throws NoSuchFieldException,
SecurityException,
IllegalArgumentException,
IllegalAccessException {
Pair<ICommand, CommandResult> latestPairInHistory = TestUtils.getLatestPairOfCommandAndCommandResultInCommandHistory();
TestUtils.assertCorrectCommandType(latestPairInHistory.getFirst(), LoadLearningAlgorithmsCommand.class);
TestUtils.assertCorrectSuccessfulCommandResult(latestPairInHistory.getSecond());
@SuppressWarnings("unchecked")
List<CommandResult> addAlgorithmCommandResultList = (List<CommandResult>) latestPairInHistory.getSecond().getResult();
if (addAlgorithmCommandResultList.isEmpty()) {
Assert.fail(ERROR_EMPTY_LIST_OF_COMMAND_RESULTS);
}
TestUtils.assertCorrectFailedEmptyCommandResult(addAlgorithmCommandResultList.get(0), ParameterValidationFailedException.class);
TestUtils.assertCorrectSuccessfulCommandResultWhichIsNotEmpty(addAlgorithmCommandResultList.get(1), ILearningAlgorithm.class);
assertCorrectFailedCommandResultAndConsoleOutputForAddingLearningAlgorithmsWithCorrectAndWrongParameters(consoleOutput,
addAlgorithmCommandResultList);
}
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:31,代码来源:LoadLearningAlgorithmsCommandTest.java
示例2: testTtls
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testTtls() {
long ttls[] = {100, 1, EphemeralType.MAX_TTL};
for (long ttl : ttls) {
long ephemeralOwner = EphemeralType.ttlToEphemeralOwner(ttl);
Assert.assertEquals(EphemeralType.TTL, EphemeralType.get(ephemeralOwner));
Assert.assertEquals(ttl, EphemeralType.getTTL(ephemeralOwner));
}
EphemeralType.validateTTL(CreateMode.PERSISTENT_WITH_TTL, 100);
EphemeralType.validateTTL(CreateMode.PERSISTENT_SEQUENTIAL_WITH_TTL, 100);
try {
EphemeralType.validateTTL(CreateMode.EPHEMERAL, 100);
Assert.fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException dummy) {
// expected
}
}
示例3: test175
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test175() throws Throwable {
if (debug)
System.out.format("%n%s%n", "RegressionTest0.test175");
Relationship relationship0 = new Relationship();
Column column1 = relationship0.getPk();
String str2 = relationship0.getSchema();
Boolean b3 = relationship0.getDataTypeCategoryAgree();
Boolean b4 = relationship0.isEstimatedFk();
relationship0.setEstimatedFk(true);
Connection connection7 = null;
try {
relationship0.setSlowFeatures(connection7);
Assert.fail("Expected exception of type java.lang.NullPointerException");
} catch (NullPointerException e) {
}
Assert.assertNull(column1);
Assert.assertNull(str2);
Assert.assertNull(b3);
Assert.assertTrue("'" + b4 + "' != '" + false + "'", b4.equals(false));
}
示例4: testDoFinalArguments
import org.junit.Assert; //导入方法依赖的package包/类
@Test(timeout=120000)
public void testDoFinalArguments() throws Exception {
Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null);
OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding");
Assert.assertTrue(cipher != null);
cipher.init(OpensslCipher.ENCRYPT_MODE, key, iv);
// Require direct buffer
ByteBuffer output = ByteBuffer.allocate(1024);
try {
cipher.doFinal(output);
Assert.fail("Output buffer should be direct buffer.");
} catch (IllegalArgumentException e) {
GenericTestUtils.assertExceptionContains(
"Direct buffer is required", e);
}
}
示例5: testMeta
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testMeta() {
MetaEntity baseMeta = module.getJpaMetaProvider().getMeta(baseClass);
MetaEntity childMeta = module.getJpaMetaProvider().getMeta(childClass);
Assert.assertSame(baseMeta, childMeta.getSuperType());
Assert.assertEquals(1, childMeta.getDeclaredAttributes().size());
Assert.assertEquals(2, baseMeta.getAttributes().size());
Assert.assertEquals(3, childMeta.getAttributes().size());
Assert.assertNotNull(baseMeta.getAttribute("id"));
Assert.assertNotNull(baseMeta.getAttribute("stringValue"));
try {
Assert.assertNull(baseMeta.getAttribute("intValue"));
Assert.fail();
} catch (Exception e) {
// ok
}
Assert.assertNotNull(childMeta.getAttribute("id"));
Assert.assertNotNull(childMeta.getAttribute("stringValue"));
Assert.assertNotNull(childMeta.getAttribute("intValue"));
}
示例6: testRenameFileAsExistingFile
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testRenameFileAsExistingFile() throws Exception {
if (!renameSupported()) return;
Path src = getTestRootPath(fSys, "test/hadoop/file");
createFile(src);
Path dst = getTestRootPath(fSys, "test/new/existingFile");
createFile(dst);
// Fails without overwrite option
try {
rename(src, dst, false, true, false, Rename.NONE);
Assert.fail("Expected exception was not thrown");
} catch (IOException e) {
Assert.assertTrue(unwrapException(e) instanceof FileAlreadyExistsException);
}
// Succeeds with overwrite option
rename(src, dst, true, false, true, Rename.OVERWRITE);
}
示例7: caseGlobTargetMissingMultiLevel
import org.junit.Assert; //导入方法依赖的package包/类
private void caseGlobTargetMissingMultiLevel(boolean sync) {
try {
Path listFile = new Path("/tmp1/listing");
Path target = new Path("/tmp/target");
addEntries(listFile, "/tmp/*/*");
createFiles("/tmp/multifile/file3", "/tmp/multifile/file4", "/tmp/multifile/file5");
createFiles("/tmp/singledir1/dir3/file7", "/tmp/singledir1/dir3/file8",
"/tmp/singledir1/dir3/file9");
runTest(listFile, target, sync);
checkResult(listFile, 6);
} catch (IOException e) {
LOG.error("Exception encountered while testing build listing", e);
Assert.fail("build listing failure");
} finally {
TestDistCpUtils.delete(fs, "/tmp");
TestDistCpUtils.delete(fs, "/tmp1");
}
}
示例8: test_jsonBody
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void test_jsonBody() {
MappingBuilder mockReq = post(urlPathMatching("/action"));
ResponseDefinitionBuilder mockResp = aResponse();
mockReq.withRequestBody(equalTo("{\"id\":1,\"name\":\"user1\"}"));
httpMock.stubFor(mockReq.willReturn(mockResp));
HttpClient httpClient = null;
try {
String url = baseUrl();
httpClient = HttpClient.post(url);
httpClient.setRequestBody(new JsonBody(new User(1, "user1"), CharsetUtils.UTF_8));
httpClient.execute();
Assert.assertEquals(httpClient.getResponseCode(), 200);
} catch (IOException ex) {
Assert.fail(ex.getMessage());
}
}
示例9: testValidateResponseNonJsonErrorMessage
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testValidateResponseNonJsonErrorMessage() throws IOException {
String msg = "stream";
InputStream is = new ByteArrayInputStream(msg.getBytes());
HttpURLConnection conn = Mockito.mock(HttpURLConnection.class);
Mockito.when(conn.getErrorStream()).thenReturn(is);
Mockito.when(conn.getResponseMessage()).thenReturn("msg");
Mockito.when(conn.getResponseCode()).thenReturn(
HttpURLConnection.HTTP_BAD_REQUEST);
try {
HttpExceptionUtils.validateResponse(conn, HttpURLConnection.HTTP_CREATED);
Assert.fail();
} catch (IOException ex) {
Assert.assertTrue(ex.getMessage().contains("msg"));
Assert.assertTrue(ex.getMessage().contains("" +
HttpURLConnection.HTTP_BAD_REQUEST));
}
}
示例10: testRMAppSubmitDuplicateApplicationId
import org.junit.Assert; //导入方法依赖的package包/类
@Test (timeout = 30000)
public void testRMAppSubmitDuplicateApplicationId() throws Exception {
ApplicationId appId = MockApps.newAppID(0);
asContext.setApplicationId(appId);
RMApp appOrig = rmContext.getRMApps().get(appId);
Assert.assertTrue("app name matches but shouldn't", "testApp1" != appOrig.getName());
// our testApp1 should be rejected and original app with same id should be left in place
try {
appMonitor.submitApplication(asContext, "test");
Assert.fail("Exception is expected when applicationId is duplicate.");
} catch (YarnException e) {
Assert.assertTrue("The thrown exception is not the expectd one.",
e.getMessage().contains("Cannot add a duplicate!"));
}
// make sure original app didn't get removed
RMApp app = rmContext.getRMApps().get(appId);
Assert.assertNotNull("app is null", app);
Assert.assertEquals("app id doesn't match", appId, app.getApplicationId());
Assert.assertEquals("app state doesn't match", RMAppState.FINISHED, app.getState());
}
示例11: mmapReadIntTest
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void mmapReadIntTest() throws IOException {
File tmpFile = storeInTempFile(new ByteArrayInputStream(BLOB));
try {
RandomAccessObject obj =
new RandomAccessObject.RandomAccessMmapObject(new RandomAccessFile(tmpFile, "r"), "r");
readIntTest(obj);
try {
obj.readInt();
Assert.fail("Should've thrown an BufferUnderflowException");
} catch (BufferUnderflowException expected) {
}
} finally {
tmpFile.delete();
}
}
示例12: raisedIfHeaderContainsNewLine
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void raisedIfHeaderContainsNewLine() {
try {
new CorsConfiguration("host1\nhost2");
Assert.fail();
}
catch (IllegalArgumentException ex) {
Assert.assertEquals("corsheader", ex.getMessage());
}
}
示例13: testSourceListingAndSourcePath
import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testSourceListingAndSourcePath() {
try {
OptionsParser.parse(new String[] {
"-f",
"hdfs://localhost:8020/source/first",
"hdfs://localhost:8020/source/first",
"hdfs://localhost:8020/target/"});
Assert.fail("Both source listing & source paths allowed");
} catch (IllegalArgumentException ignore) {}
}
示例14: having
import org.junit.Assert; //导入方法依赖的package包/类
@When("^I click on element having (id|name|class|xpath|css) \"([^\"]*)\" on row containing \"([^\"]*)\" at table with (id|name|class|xpath|css) \"([^\"]*)\"$")
public void clickElementHavingOnRow(String type, String element, String text, String tableType, String tableElement) {
WebElement table = getWebElement(tableType, tableElement);
List<WebElement> rows = table.findElements(By.tagName("tr"));
WebElement row = findTextAtRow(text, rows);
if(row != null){
WebElement el = row.findElement(TypeEnum.getBy(type, element));
el.click();
}else {
Assert.fail(String.format("Didn't found %s on row",text));
}
}
示例15: cliquer
import org.junit.Assert; //导入方法依赖的package包/类
@Override
public void cliquer(String type, String selector) {
this.logger.info("cliquer type:" + type + " selector:" + selector);
try {
By locator = BySelec.get(type, selector);
wait.until(ExpectedConditions.elementToBeClickable(locator)).click();
} catch (TimeoutException e) {
e.printStackTrace();
String pathScreenShot = takeScreenShot();
Assert.fail("Cliquer impossible ! (type" + type + ", selector" + selector + ") pathScreenShot=" + pathScreenShot);
}
}