public class ClassicSingleton {
private static ClassicSingleton instance=new ClassicSingleton();

private ClassicSingleton() {

}
public static ClassicSingleton getInstance() {
return instance;
}
}

import java.util.logging.Logger;

import junit.framework.Assert;
import junit.framework.TestCase;


public class SingletonTest extends TestCase {
private ClassicSingleton sone=null;
private ClassicSingleton stwo=null;
private static Logger logger=Logger.getAnonymousLogger();

public SingletonTest(String name) {
super(name);
}

public void setUp() {
logger.info("getting singleton...");
sone=ClassicSingleton.getInstance();
logger.info("...got singleton: "+sone);

logger.info("getting singleton...");
stwo=ClassicSingleton.getInstance();
logger.info("...got singleton: "+stwo);
}
public void testUnique() {
logger.info("checking singleton for equality");
Assert.assertEquals(true, sone==stwo);
}
}