com.vividsolutions.jts.util.AssertionFailedException Java Examples

The following examples show how to use com.vividsolutions.jts.util.AssertionFailedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Assert.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 *  Throws an <code>AssertionFailedException</code> with the given message if
 *  the given assertion is not true.
 *
 *@param  assertion                  a condition that is supposed to be true
 *@param  message                    a description of the assertion
 *@throws  AssertionFailedException  if the condition is false
 */
public static void isTrue(boolean assertion, String message) {
  if (!assertion) {
    if (message == null) {
      throw new AssertionFailedException();
    }
    else {
      throw new AssertionFailedException(message);
    }
  }
}
 
Example #2
Source File: STRtreeTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testDisallowedInserts() {
  STRtree t = new STRtree(5);
  t.insert(new Envelope(0, 0, 0, 0), new Object());
  t.insert(new Envelope(0, 0, 0, 0), new Object());
  t.query(new Envelope());
  try {
    t.insert(new Envelope(0, 0, 0, 0), new Object());
    assertTrue(false);
  }
  catch (AssertionFailedException e) {
    assertTrue(true);
  }
}
 
Example #3
Source File: Assert.java    From jts with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 *  Throws an <code>AssertionFailedException</code> with the given message if
 *  the given objects are not equal, according to the <code>equals</code>
 *  method.
 *
 *@param  expectedValue              the correct value
 *@param  actualValue                the value being checked
 *@param  message                    a description of the assertion
 *@throws  AssertionFailedException  if the two objects are not equal
 */
public static void equals(Object expectedValue, Object actualValue, String message) {
  if (!actualValue.equals(expectedValue)) {
    throw new AssertionFailedException("Expected " + expectedValue + " but encountered "
         + actualValue + (message != null ? ": " + message : ""));
  }
}
 
Example #4
Source File: Assert.java    From jts with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 *  Always throws an <code>AssertionFailedException</code> with the given
 *  message.
 *
 *@param  message                    a description of the assertion
 *@throws  AssertionFailedException  thrown always
 */
public static void shouldNeverReachHere(String message) {
  throw new AssertionFailedException("Should never reach here"
       + (message != null ? ": " + message : ""));
}