package com.google.common.base; import static org.junit.Assert.*; import org.junit.Test; public class TestObjects { @Test public void _equalTest() { Integer i1 = new Integer(5); Integer i2 = new Integer(5); Integer i3 = new Integer(6); assertTrue(Objects.equal(i1, i1)); assertTrue(Objects.equal(i1, i2)); assertFalse(Objects.equal(i1, i3)); } @Test public void firstNonNullTest() { Integer i1 = null; Integer i2 = null; boolean exception = false; Integer result; try { Objects.firstNonNull(i1, i2); } catch(NullPointerException e) { exception = true; } assertTrue(exception); i2 = new Integer(5); result = Objects.firstNonNull(i1, i2); assertTrue(Objects.equal(i2, result)); } @Test public void toStringHelperTest() { Integer i = new Integer(4); String result = Objects.toStringHelper(i).add("x", 1).toString(); System.out.println(result); assertEquals("Integer{x=1}", result); } }