Example usage for java.lang AssertionError AssertionError

List of usage examples for java.lang AssertionError AssertionError

Introduction

In this page you can find the example usage for java.lang AssertionError AssertionError.

Prototype

public AssertionError(double detailMessage) 

Source Link

Document

Constructs an AssertionError with its detail message derived from the specified double, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification.

Usage

From source file:com.appsimobile.appsii.SimpleJsonTest.java

public void testPathParsing() throws ResponseParserException {
    StringBuilder sb = new StringBuilder();

    String testData = AssetUtils.readAssetToString(getContext().getAssets(),
            "parser_test_data/parser_json_object_test_restaurant.json", sb);

    JSONObject jsonObject;//from   www . jav a  2s .co  m
    try {
        jsonObject = new JSONObject(testData);
    } catch (JSONException e) {
        AssertionError error = new AssertionError("Unexpected error");
        error.initCause(e);
        throw error;
    }

    final SimpleJson simpleJson = new SimpleJson(jsonObject);

    SimpleJson test = simpleJson.childForPath("id");
    assertEquals(simpleJson, test);

    SimpleJson location = simpleJson.childForPath("location.lat");
    assertNotNull(location);
    assertNotSame(simpleJson, location);

    SimpleJson test2 = simpleJson.childForPath("location.long");
    assertTrue(location == test2);

    SimpleJson streetName1 = simpleJson.childForPath("location.streetname.id");
    SimpleJson streetName2 = location.childForPath("streetname.id");

    assertTrue(streetName1 == streetName2);

    assertEquals("E-sites cafe", simpleJson.getString("name"));
    assertEquals("4814", location.getString("zipcode"));
    assertEquals("4814", simpleJson.getString("location.zipcode"));
    assertEquals("NL", simpleJson.getString("location.country.code"));
    assertNull(simpleJson.getString("location.country.codexxx"));

    try {
        assertEquals("", simpleJson.getString("xxx_does_not_exist.zipcode"));
        assertTrue(false);
    } catch (ResponseParserException ignore) {
        // expected to get here
    }

    double latitude = simpleJson.getDouble("location.lat", Double.MIN_VALUE);
    assertEquals(51.5906127, latitude);

    double longitude = simpleJson.getDouble("location.long", Double.MIN_VALUE);
    assertEquals(4.7622492, longitude);

}

From source file:com.cpjit.swagger4j.util.ReflectUtils.java

private ReflectUtils() {
    throw new AssertionError("?? " + ReflectUtils.class.getName());
}

From source file:com.feilong.core.util.comparator.BeanComparatorUtil.java

/** Don't let anyone instantiate this class. */
private BeanComparatorUtil() {
    //AssertionError?. ?????. ???.
    //see Effective Java 2nd
    throw new AssertionError("No " + getClass().getName() + " instances for you!");
}

From source file:com.discovery.darchrow.io.ReaderUtil.java

/** Don't let anyone instantiate this class. */
private ReaderUtil() {
    //AssertionError?. ?????. ???.
    //see Effective Java 2nd
    throw new AssertionError("No " + getClass().getName() + " instances for you!");
}

From source file:com.ev.launch.Initializer.java

private Initializer() {
    throw new AssertionError("Constructur invokation not allowed!");
}

From source file:com.googlecode.vfsjfilechooser2.utils.SwingCommonsUtilities.java

private SwingCommonsUtilities() {
    throw new AssertionError("Trying to instanciate SwingCommonsUtilities");
}

From source file:com.tc.util.TCPropertyStoreTest.java

private void loadDefaults(String propFile, TCPropertyStore propertyStore) {
    InputStream in = TCPropertiesImpl.class.getResourceAsStream(propFile);
    if (in == null) {
        throw new AssertionError("TC Property file " + propFile + " not Found");
    }/*from ww w .  ja  va2 s  .c o m*/
    try {
        propertyStore.load(in);
    } catch (IOException e) {
        throw new AssertionError(e);
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:com.progressiveaccess.cmlspeech.base.Cli.java

/** Dummy constructor. */
private Cli() {
    throw new AssertionError("Instantiating utility class...");
}

From source file:com.hoccer.tools.TestHelper.java

public static void blockUntilTrue(String pFailMessage, long pTimeout, TestHelper.Condition pCon)
        throws Exception {
    long start = System.currentTimeMillis();
    while (System.currentTimeMillis() - start < pTimeout) {

        if (pCon.isSatisfied()) {
            return;
        }/*from   w w w  .  j a  v a 2  s . c o  m*/
        Thread.sleep(20);
    }
    throw new AssertionError(pFailMessage);
}

From source file:com.hpe.caf.worker.testing.validation.Base64PropertyValidator.java

@Override
protected boolean isValid(Object testedPropertyValue, Object validatorPropertyValue) {
    if (validatorPropertyValue == null) {
        return testedPropertyValue == null;
    }// w  ww . jav  a 2  s . c  o  m

    if (testedPropertyValue == null) {
        return false;
    }

    if (!(testedPropertyValue instanceof byte[]) || !(validatorPropertyValue instanceof String)) {
        throw new AssertionError(
                "Unexpected types provided to Base64PropertyValidator. Expected byte array testedPropertyValue and String validatorPropertyValue. Provided were "
                        + testedPropertyValue.getClass().getSimpleName() + " and "
                        + validatorPropertyValue.getClass().getSimpleName() + ". Values: "
                        + testedPropertyValue.toString() + ", " + validatorPropertyValue.toString());
    }

    byte[] testedPropertyValueBytes = (byte[]) testedPropertyValue;

    if (validatorPropertyValue.toString().equals("*")) {
        return testedPropertyValueBytes.length > 0;
    }

    boolean areEqual = Arrays.equals(testedPropertyValueBytes,
            Base64.decodeBase64(validatorPropertyValue.toString()));

    if (!areEqual) {
        String actual = Base64.encodeBase64String(testedPropertyValueBytes);
        System.err.println("Unexpected result. Actual value: " + actual + ", expected value: "
                + validatorPropertyValue.toString());
    }

    return areEqual;
}