1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/friendpackage/test/implpkg/AccessorTest.java Sat Jun 14 09:50:27 2008 +0200
1.3 @@ -0,0 +1,59 @@
1.4 +/*
1.5 + * Sun Public License Notice
1.6 + *
1.7 + * The contents of this file are subject to the Sun Public License
1.8 + * Version 1.0 (the "License"). You may not use this file except in
1.9 + * compliance with the License. A copy of the License is available at
1.10 + * http://www.sun.com/
1.11 + *
1.12 + * The Original Code is NetBeans. The Initial Developer of the Original
1.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1999-2006 Sun
1.14 + * Microsystems, Inc. All Rights Reserved.
1.15 + */
1.16 +
1.17 +package implpkg;
1.18 +
1.19 +import javax.swing.event.ChangeEvent;
1.20 +import junit.framework.TestCase;
1.21 +import junit.framework.*;
1.22 +import apipkg.Item;
1.23 +import javax.swing.event.ChangeListener;
1.24 +
1.25 +/**
1.26 + *
1.27 + * @author Jaroslav Tulach
1.28 + */
1.29 +public class AccessorTest extends TestCase
1.30 +implements ChangeListener {
1.31 +
1.32 + private int cnt;
1.33 +
1.34 + public AccessorTest(String testName) {
1.35 + super(testName);
1.36 + }
1.37 +
1.38 + protected void setUp() throws Exception {
1.39 + }
1.40 +
1.41 + protected void tearDown() throws Exception {
1.42 + }
1.43 +
1.44 + public void testGetTheItemAttachListenerChangeValue() {
1.45 + Item item = Accessor.DEFAULT.newItem();
1.46 + assertNotNull("Some item is really created", item);
1.47 +
1.48 + Accessor.DEFAULT.addChangeListener(item, this);
1.49 +
1.50 + item.setValue(10);
1.51 + assertEquals("Value is 10", 10, item.getValue());
1.52 + cnt = 0;
1.53 + item.setValue(7);
1.54 + assertEquals("Now it is 7", 7, item.getValue());
1.55 +
1.56 + assertEquals("There was one change", 1, cnt);
1.57 + }
1.58 +
1.59 + public void stateChanged(ChangeEvent e) {
1.60 + cnt++;
1.61 + }
1.62 +}