Code example for Observable

Methods: countObservershasChanged

0
	/** 
	 * @tests java.util.Observable#Observable() 
	 */ 
	public void test_Constructor() { 
		// Test for method java.util.Observable() 
                Observable ov = new Observable();
                assertTrue("Wrong initial values.", !ov.hasChanged());
                assertEquals("Wrong initial values.", 0, ov.countObservers());
	} 
 
	/** 
	 * @tests java.util.Observable#addObserver(java.util.Observer) 
	 */ 
	public void test_addObserverLjava_util_Observer() { 
		// Test for method void 
		// java.util.Observable.addObserver(java.util.Observer) 
		TestObserver test = new TestObserver();
		observable.addObserver(test);
		assertEquals("Failed to add observer", 1, observable.countObservers());
		observable.addObserver(test);