jtulach@0: /* jtulach@0: * Sun Public License Notice jtulach@0: * jtulach@0: * The contents of this file are subject to the Sun Public License jtulach@0: * Version 1.0 (the "License"). You may not use this file except in jtulach@0: * compliance with the License. A copy of the License is available at jtulach@0: * http://www.sun.com/ jtulach@0: * jtulach@0: * The Original Code is NetBeans. The Initial Developer of the Original jtulach@0: * Code is Sun Microsystems, Inc. Portions Copyright 1999-2006 Sun jtulach@0: * Microsystems, Inc. All Rights Reserved. jtulach@0: */ jtulach@0: jtulach@0: package implpkg; jtulach@0: jtulach@0: import javax.swing.event.ChangeEvent; jtulach@0: import junit.framework.TestCase; jtulach@0: import junit.framework.*; jtulach@0: import apipkg.Item; jtulach@0: import javax.swing.event.ChangeListener; jtulach@0: jtulach@0: /** jtulach@0: * jtulach@0: * @author Jaroslav Tulach jtulach@0: */ jtulach@0: public class AccessorTest extends TestCase jtulach@0: implements ChangeListener { jtulach@0: jtulach@0: private int cnt; jtulach@0: jtulach@0: public AccessorTest(String testName) { jtulach@0: super(testName); jtulach@0: } jtulach@0: jtulach@0: protected void setUp() throws Exception { jtulach@0: } jtulach@0: jtulach@0: protected void tearDown() throws Exception { jtulach@0: } jtulach@0: jtulach@0: public void testGetTheItemAttachListenerChangeValue() { jtulach@3: // BEGIN: design.less.friend.use jtulach@0: Item item = Accessor.DEFAULT.newItem(); jtulach@0: assertNotNull("Some item is really created", item); jtulach@0: jtulach@0: Accessor.DEFAULT.addChangeListener(item, this); jtulach@3: // END: design.less.friend.use jtulach@0: jtulach@0: item.setValue(10); jtulach@0: assertEquals("Value is 10", 10, item.getValue()); jtulach@0: cnt = 0; jtulach@0: item.setValue(7); jtulach@0: assertEquals("Now it is 7", 7, item.getValue()); jtulach@0: jtulach@0: assertEquals("There was one change", 1, cnt); jtulach@0: } jtulach@0: jtulach@0: public void stateChanged(ChangeEvent e) { jtulach@0: cnt++; jtulach@0: } jtulach@0: }