当前位置: 首页>>代码示例>>Java>>正文


Java Assert.fail方法代码示例

本文整理汇总了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
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:20,代码来源:EphemeralTypeTest.java

示例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));
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:22,代码来源:RegressionTest.java

示例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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestOpensslCipher.java

示例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"));
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:23,代码来源:AbstractInheritanceTest.java

示例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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:FSMainOperationsBaseTest.java

示例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");
    }
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestFileBasedCopyListing.java

示例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());
	}
}
 
开发者ID:haducloc,项目名称:appslandia-sweetsop,代码行数:23,代码来源:HttpPostTest.java

示例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));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestHttpExceptionUtils.java

示例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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestAppManager.java

示例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();
  }
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:19,代码来源:RandomAccessObjectTest.java

示例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());
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:11,代码来源:CorsConfigurationTest.java

示例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) {}
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestOptionsParser.java

示例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));
    }
}
 
开发者ID:entelgy-brasil,项目名称:zucchini,代码行数:14,代码来源:ClickStep.java

示例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);
    }
}
 
开发者ID:Nonorc,项目名称:saladium,代码行数:13,代码来源:SaladiumDriver.java


注:本文中的org.junit.Assert.fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。