@Test public void singletonCreatesOnlyOneInstance() { SingletonDBConnection testSingle2 = null; SingletonDBConnection testSingle3 = null; testSingle2 = SingletonDBConnection.getInstance(); testSingle3 = SingletonDBConnection.getInstance(); Assert.assertNotNull("Shouldn't be NULL", testSingle2); Assert.assertNotNull("Shouldn't be NULL", testSingle3); Assert.assertSame("Should be the same object", testSingle2, testSingle3); }
@Test public void singletonCreatesSomeInstance() { SingletonDBConnection testSingle1 = null; testSingle1 = SingletonDBConnection.getInstance(); Assert.assertNotNull("Shouldn't be NULL", testSingle1); }