assert True - Java java.lang

Java examples for java.lang:Assert

Description

assert True

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        boolean condition = true;
        assertTrue(condition);/*from ww w  .  ja v a2s.  c  o m*/
    }

    public static void assertTrue(final String message,
            final boolean condition) {
        if (!condition) {
            fail(message);
        }
    }

    public static void assertTrue(final boolean condition) {
        assertTrue(null, condition);
    }

    public static void fail(final Object message) {
        if (message == null) {
            throw new AssertionError();
        }

        throw new AssertionError(message);
    }
}

Related Tutorials