samples/friendpackage/test/org/apidesign/friendpackage/impl/AccessorTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 06 Oct 2013 22:05:14 +0200
changeset 407 e1439046d96e
parent 128 8ef997796d0a
permissions -rw-r--r--
Looks like scala change URLs of its releases
     1 /*
     2  *                 Sun Public License Notice
     3  * 
     4  * The contents of this file are subject to the Sun Public License
     5  * Version 1.0 (the "License"). You may not use this file except in
     6  * compliance with the License. A copy of the License is available at
     7  * http://www.sun.com/
     8  * 
     9  * The Original Code is NetBeans. The Initial Developer of the Original
    10  * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. 
    11  * All Rights Reserved.
    12  */
    13 
    14 package org.apidesign.friendpackage.impl;
    15 
    16 import javax.swing.event.ChangeEvent;
    17 import javax.swing.event.ChangeListener;
    18 import junit.framework.TestCase;
    19 import org.apidesign.friendpackage.api.Item;
    20 
    21 /**
    22  *
    23  * @author Jaroslav Tulach
    24  */
    25 public class AccessorTest extends TestCase 
    26 implements ChangeListener {
    27 
    28     private int cnt;
    29     
    30     public AccessorTest(String testName) {
    31         super(testName);
    32     }
    33 
    34     public void testGetTheItemAttachListenerChangeValue() {
    35         // BEGIN: design.less.friend.use
    36         Item item = Accessor.getDefault().newItem();
    37         assertNotNull("Some item is really created", item);
    38         
    39         Accessor.getDefault().addChangeListener(item, this);
    40         // END: design.less.friend.use
    41         
    42         item.setValue(10);
    43         assertEquals("Value is 10", 10, item.getValue());
    44         cnt = 0;
    45         item.setValue(7);
    46         assertEquals("Now it is 7", 7, item.getValue());
    47         
    48         assertEquals("There was one change", 1, cnt);
    49     }
    50 
    51     public void stateChanged(ChangeEvent e) {
    52         cnt++;
    53     }
    54 }