Ensure that the given object is not null, if it is fail the test - Java XML

Java examples for XML:JAXB

Description

Ensure that the given object is not null, if it is fail the test

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        Object object1 = "java2s.com";
        assertNotNull(object1);// ww w. ja  v a 2 s  .  c  om
    }

    /**
     * Ensure that the given object is not null, if it is fail the test
     * 
     * @param object1
     *            The object to test
     */
    public static void assertNotNull(Object object1) {
        if (object1 == null) {
            throw new RuntimeException("TEST FAILS: " + object1
                    + " must not be null");
        }
    }
}

Related Tutorials