當前位置: 首頁>>代碼示例>>Java>>正文


Java ComparisonFailure類代碼示例

本文整理匯總了Java中junit.framework.ComparisonFailure的典型用法代碼示例。如果您正苦於以下問題:Java ComparisonFailure類的具體用法?Java ComparisonFailure怎麽用?Java ComparisonFailure使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ComparisonFailure類屬於junit.framework包,在下文中一共展示了ComparisonFailure類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertMatches

import junit.framework.ComparisonFailure; //導入依賴的package包/類
private static void assertMatches(String message, String expected, String actual) {
  int posInExpected = 0;
  int posInActual = 0;
  while (posInExpected < expected.length()) {
    int placeholderPos = expected.indexOf(PLATFORM_SPECIFIC_PLACEHOLDER, posInExpected);
    if (placeholderPos < 0) {
      if (posInExpected == 0 ? actual.equals(expected) : actual.substring(posInActual).endsWith(expected.substring(posInExpected))) {
        return;
      }
      else {
        throw new ComparisonFailure(message, expected, actual);
      }
    }
    String fixedSubstring = expected.substring(posInExpected, placeholderPos);
    int matchedPosInActual = actual.indexOf(fixedSubstring, posInActual);
    if (matchedPosInActual < 0 || posInExpected == 0 && matchedPosInActual > 0) {
      throw new ComparisonFailure(message, expected, actual);
    }
    posInExpected = placeholderPos + PLATFORM_SPECIFIC_PLACEHOLDER.length();
    posInActual = matchedPosInActual + fixedSubstring.length();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:RichCopyTest.java

示例2: assertTranslation

import junit.framework.ComparisonFailure; //導入依賴的package包/類
protected void assertTranslation(String hql, Map replacements) {
	ComparisonFailure cf = null;
	try {
		assertTranslation( hql, replacements, false, null );
	}
	catch ( ComparisonFailure e ) {
		e.printStackTrace();
		cf = e;
	}
	if ("false".equals(System.getProperty("org.hibernate.test.hql.SkipScalarQuery","false"))) {
		// Run the scalar translation anyway, even if there was a comparison failure.
		assertTranslation( hql, replacements, true, null );
	}
	if (cf != null)
		throw cf;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:17,代碼來源:QueryTranslatorTestCase.java

示例3: testGetMobileNetworkTypeWith4G

import junit.framework.ComparisonFailure; //導入依賴的package包/類
@Test
@TargetApi(24)
public void testGetMobileNetworkTypeWith4G() throws Exception {
    setFinalStatic(Build.VERSION.class.getField("SDK_INT"), 24);
    try {

        TelephonyManager mockedTelephonyManager = mock(TelephonyManager.class);
        when(mockedTelephonyManager.getDataNetworkType()).thenReturn(TelephonyManager.NETWORK_TYPE_LTE);

        NetworkMonitor mockedNetworkMonitor = mock(NetworkMonitor.class);
        when(mockedNetworkMonitor.getTelephonyManager()).thenReturn(mockedTelephonyManager);
        when(mockedNetworkMonitor.getMobileNetworkType()).thenCallRealMethod();

        assertEquals("4G", mockedNetworkMonitor.getMobileNetworkType());
    } catch (NullPointerException | ComparisonFailure e){
        
    }
}
 
開發者ID:ibm-bluemix-mobile-services,項目名稱:bms-clientsdk-android-core,代碼行數:19,代碼來源:NetworkMonitorTests.java

示例4: testGroupCipher

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * Test if group cipher can handle high amounts of tasks and still work properly
 *
 * @throws Exception
 */
public void testGroupCipher() throws Exception {
    if(CipherSuiteTestsUtility.logReport)
        appendHeader("GroupCipherTest", outputs);
    ComparisonFailure ex = null;
    //initialise input
    byte[] plaintext = CipherTestVectors.getByteInput();
    //start test
    byte[][] result = uut.encrypt(plaintext, keyList);
    for (int i = 0; i < result.length; ++i) {
        byte[] decrypted = uut.tryDecrypt(result[i], keyList);
        try {
            Assert.assertEquals(CipherSuiteTestsUtility.PLAINSIZE, decrypted.length);
            Assert.assertEquals(CipherTestVectors.testInput, new String(decrypted, CipherSuiteTestsUtility.charEncoding).trim());
        } catch (ComparisonFailure e) {
            if(CipherSuiteTestsUtility.logReport) {
                appendDataSplit(outputs);
                appendGroupInfo(keyList.get(i), result[i], decrypted, true);
            }
            ex = e;
        }
    }
    if (ex != null) throw ex;
}
 
開發者ID:timberdoodle,項目名稱:TimberdoodleApp,代碼行數:29,代碼來源:CipherStressTests.java

示例5: testMacCollisions

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * Check the mac collisions in the test input
 * @throws Exception
 */
public void testMacCollisions() throws Exception  {
    if(CipherSuiteTestsUtility.logReport)
        appendHeader("Mac collisions",outputs);
    ComparisonFailure ex = null;
    byte[][] input = CipherSuiteTestsUtility.getSubArraysFromPacketArray(encryptedInput, CipherSuiteTestsUtility.macOffset, CipherSuiteTestsUtility.macLength);
    for(int j = 0; j < stressTestAmount - 1; j ++)
       for(int k = j+1; k < stressTestAmount; k++)
           try {
               assertFalse(bytesEqual(input[j], input[k], 0));
           } catch (ComparisonFailure e){
               if(CipherSuiteTestsUtility.logReport) {
                   appendDataSplit(outputs);
                   appendGroupInfo(keyList.get(j), encryptedInput[j], new byte[1], true);
                   appendGroupInfo(keyList.get(k), encryptedInput[k], new byte[1], true);
               }
               ex = e;
           }
    if(ex != null) throw ex;
}
 
開發者ID:timberdoodle,項目名稱:TimberdoodleApp,代碼行數:24,代碼來源:CipherStressTests.java

示例6: testEqualMacKeys

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * Check if any generated mac keys are equal
 */
public void testEqualMacKeys() {
    if(CipherSuiteTestsUtility.logReport)
        appendHeader("Mac key equals", outputs);
    ComparisonFailure ex = null;
    List<SecretKey> keys = CipherSuiteTestsUtility.getSpecificKeysFromGroupKeyList(keyList, false);
    for(int j = 0; j < stressTestAmount - 1; j ++)
        for(int k = j+1; k < stressTestAmount; k++)
            try {
                assertFalse(bytesEqual(keys.get(j).getEncoded(), keys.get(k).getEncoded(), 0));
            } catch (ComparisonFailure e){
                if(CipherSuiteTestsUtility.logReport) {
                    appendDataSplit(outputs);
                    appendMacKeyInfo(keys.get(j), j, outputs);
                    appendMacKeyInfo(keys.get(k), k, outputs);
                }
                ex = e;
            }
    if(ex != null) throw ex;
}
 
開發者ID:timberdoodle,項目名稱:TimberdoodleApp,代碼行數:23,代碼來源:CipherStressTests.java

示例7: assertExprReturns

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * Executes a scalar expression, and asserts that the result is within
 * delta of the expected result.
 *
 * @param expr MDX scalar expression
 * @param expected Expected value
 * @param delta Maximum allowed deviation from expected value
 */
public void assertExprReturns(
    String expr, double expected, double delta)
{
    Object value = getTestContext().executeExprRaw(expr).getValue();

    try {
        double actual = ((Number) value).doubleValue();
        if (Double.isNaN(expected) && Double.isNaN(actual)) {
            return;
        }
        Assert.assertEquals(
            null,
            expected,
            actual,
            delta);
    } catch (ClassCastException ex) {
        String msg = "Actual value \"" + value + "\" is not a number.";
        throw new ComparisonFailure(
            msg, Double.toString(expected), String.valueOf(value));
    }
}
 
開發者ID:OSBI,項目名稱:mondrian,代碼行數:30,代碼來源:FunctionTest.java

示例8: assertEqualsGeneratedSourceWithResource

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * {@link Processor} が生成したソースをクラスパス上のリソースと比較・検証します.
 * 
 * @param expectedResource
 *            生成されたソースに期待される內容を持つリソースのパス
 * @param className
 *            生成されたクラスの完全限定名
 * @throws IllegalStateException
 *             {@link #compile()} が呼び出されていない場合
 * @throws IOException
 *             入出力例外が発生した場合
 * @throws SourceNotGeneratedException
 *             ソースが生成されなかった場合
 * @throws ComparisonFailure
 *             生成されたソースが期待される內容と一致しなかった場合
 */
protected void assertEqualsGeneratedSourceWithResource(
        final String expectedResource, final String className)
        throws IllegalStateException, IOException,
        SourceNotGeneratedException, ComparisonFailure {
    assertNotEmpty("expectedResource", expectedResource);
    assertNotEmpty("className", className);
    assertCompiled();
    final URL url = Thread
        .currentThread()
        .getContextClassLoader()
        .getResource(expectedResource);
    if (url == null) {
        throw new FileNotFoundException(expectedResource);
    }
    assertEqualsGeneratedSourceWithResource(url, className);
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:33,代碼來源:AptinaTestCase.java

示例9: assertRewriteFails

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/**
 * @param msg Message that should be reported to the template ns.author. Null means don't care.
 */
private void assertRewriteFails(@Nullable String msg, String... inputs) {
  try {
    rewrite(inputs);
    fail();
  } catch (SoyAutoescapeException ex) {
    // Find the root cause; during contextualization, we re-wrap exceptions on the path to a
    // template.
    while (ex.getCause() instanceof SoyAutoescapeException) {
      ex = (SoyAutoescapeException) ex.getCause();
    }
    if (msg != null && !msg.equals(ex.getMessage())) {
      throw (ComparisonFailure) new ComparisonFailure("", msg, ex.getMessage()).initCause(ex);
    }
  }
}
 
開發者ID:google,項目名稱:closure-templates,代碼行數:19,代碼來源:ContextualAutoescaperTest.java

示例10: assertEpsilonEquals

import junit.framework.ComparisonFailure; //導入依賴的package包/類
protected void assertEpsilonEquals(MapLayer expected, MapLayer actual) {
	if (!Objects.equals(expected.getClass(), actual.getClass())) {
		throw new ComparisonFailure("Not same type", expected.getClass().toString(), //$NON-NLS-1$
				actual.getClass().toString());
	}
	if (!Objects.equals(actual.getGeoId(), expected.getGeoId())) {
		throw new ComparisonFailure("Not same GeoId", expected.getGeoId().toString(), //$NON-NLS-1$
				actual.getGeoId().toString());
	}
	if (!Objects.equals(expected.getClass(), actual.getClass())) {
		throw new ComparisonFailure("Not same hashCode", expected.hashKey().toString(), //$NON-NLS-1$
				actual.getClass().toString());
	}
	if (!Objects.equals(expected, actual)) {
		throw new ComparisonFailure("Not same objects", expected.toString(), //$NON-NLS-1$
				actual.toString());
	}
}
 
開發者ID:gallandarakhneorg,項目名稱:afc,代碼行數:19,代碼來源:AbstractGisTest.java

示例11: get

import junit.framework.ComparisonFailure; //導入依賴的package包/類
private static String get(final Throwable assertion, final Map staticMap, final String fieldName) throws IllegalAccessException, NoSuchFieldException
{
	String actual;
	if(assertion instanceof ComparisonFailure)
	{
		actual = (String) ((Field) staticMap.get(ComparisonFailure.class)).get(assertion);
	}
	else if(assertion instanceof org.junit.ComparisonFailure)
	{
		actual = (String) ((Field) staticMap.get(org.junit.ComparisonFailure.class)).get(assertion);
	}
	else
	{
		Field field = assertion.getClass().getDeclaredField(fieldName);
		field.setAccessible(true);
		actual = (String) field.get(assertion);
	}
	return actual;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:20,代碼來源:ComparisonFailureData.java

示例12: assertEvent

import junit.framework.ComparisonFailure; //導入依賴的package包/類
private static void assertEvent(MockEventListener mockEventListener,
		EventType eventType, String value) {
	Event event = mockEventListener.pop();
	if (event == null) {
		throw new AssertionFailedError(
				"Event expected, but no more events available");
	}
	if (event.eventType != eventType) {
		throw new ComparisonFailure("Wrong Event Type", eventType.name(),
				event.eventType.name());
	}
	if (value == null) {
		if (event.value != null) {
			throw new ComparisonFailure("Wrong Event Value", value,
					event.value);
		}
	} else if (!value.equals(event.value)) {
		throw new ComparisonFailure("Wrong Event Value", value, event.value);
	}
}
 
開發者ID:ibauersachs,項目名稱:jmork,代碼行數:21,代碼來源:MorkParserTest.java

示例13: intercept

import junit.framework.ComparisonFailure; //導入依賴的package包/類
public void intercept(IMethodInvocation invocation) throws Throwable {
    try {
        invocation.proceed();
    } catch (Throwable t) {
        if (!annotation.type().isInstance(t)) {
            throw new WrongExceptionThrownError(annotation.type(), t);
        }
        if (!annotation.message().equals(t.getMessage())) {
            throw new ComparisonFailure("Unexpected message for exception.", annotation.message(), t.getMessage());
        }
        return;
    }

    throw new WrongExceptionThrownError(annotation.type(), null);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:16,代碼來源:FailsWithMessageExtension.java

示例14: assertExactlyOrdered

import junit.framework.ComparisonFailure; //導入依賴的package包/類
private void assertExactlyOrdered(List<String> proposals, List<String> required,
		CommaSeparatedValuesExpectationImpl expectation) {
	assertContainingMatchAllOrdered(proposals, required, expectation);

	// assert same length:
	if (proposals.size() != required.size())
		throw new ComparisonFailure(
				"Ambiguity: All required proposal (right side) could match the ones the system provides." +
						" But, at least two required labels matched the same proposal." +
						" Your requirement on the right side is to sloppy. Please provide more specific labels." +
						" See the full proposal display strings in the comparison",
				required.stream().collect(
						Collectors.joining(",")),
				proposals.stream().collect(Collectors.joining(",")));
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:16,代碼來源:ContentAssistXpectMethod.java

示例15: assertExactly

import junit.framework.ComparisonFailure; //導入依賴的package包/類
/** Unordered comparison: same number of required and proposed */
private void assertExactly(List<String> proposals, List<String> required,
		ICommaSeparatedValuesExpectation expectation) {

	// ensure, that there are not more proposals then required/expected
	// assert same length:
	if (proposals.size() != required.size())
		throw new ComparisonFailure(
				"System provides " + proposals.size() + " proposals, expected have been " + required.size() + ".",
				required.stream().collect(Collectors.joining(",")), proposals.stream().collect(
						Collectors.joining(",")));

	// ensure, that all required match a proposal.
	assertContainingMatchAll(proposals, required, expectation);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:16,代碼來源:ContentAssistXpectMethod.java


注:本文中的junit.framework.ComparisonFailure類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。