~ubuntu-branches/ubuntu/trusty/libswingx-java/trusty

« back to all changes in this revision

Viewing changes to src/test/org/jdesktop/swingx/hyperlink/HyperlinkActionTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-11-02 00:17:00 UTC
  • mfrom: (4.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091102001700-j5k1sy0wdtsp63re
Tags: 1:1.0-1
* New upstream release.
* New "libswingx-java-doc" package:
  - contains API javadoc documentation
* Bump Standards-Version to 3.8.3
  - Change section to "java"
  - Rename debian/README.Debian-source to debian/README.source
  - Describe quilt patch system in debian/README.source
* Bump debhelper version to >= 7
* Remove unused Depends on ${shlibs:Depends}
* Default JRE:
  - Build-Depends on default-jdk
  - Use /usr/lib/jvm/default-java as JAVA_HOME
* Add myself to Uploaders
* Use DEP5 format for debian/copyright
* Maven POMs:
  - Add a Build-Depends-Indep dependency on maven-repo-helper
  - Use mh_installpoms and mh_installjar to install the POM and the jar to the
    Maven repository
  - Remove unneeded dependencies in pom.diff patch
* Maven ant helper (build system):
  - Add a Build-Depends dependency on maven-ant-helper
  - Update debian/build.xml to use /usr/share/maven-ant-helper/maven-build.xml
  - Build classpath is now defined in debian/build.properties

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 28.03.2006
 
3
 *
 
4
 */
 
5
package org.jdesktop.swingx.hyperlink;
 
6
 
 
7
import java.awt.event.ActionEvent;
 
8
 
 
9
import javax.swing.Action;
 
10
 
 
11
import junit.framework.TestCase;
 
12
 
 
13
import org.jdesktop.swingx.hyperlink.AbstractHyperlinkAction;
 
14
import org.jdesktop.test.PropertyChangeReport;
 
15
import org.junit.runner.RunWith;
 
16
import org.junit.runners.JUnit4;
 
17
import org.junit.Test;
 
18
import org.junit.Before;
 
19
import org.junit.After;
 
20
 
 
21
 
 
22
/**
 
23
 * 
 
24
 * @author Jeanette Winzenburg, Berlin
 
25
 */
 
26
@RunWith(JUnit4.class)
 
27
public class HyperlinkActionTest extends TestCase {
 
28
 
 
29
    
 
30
    private PropertyChangeReport report;
 
31
 
 
32
    @Before
 
33
    public void setUpJ4() throws Exception {
 
34
        setUp();
 
35
    }
 
36
    
 
37
    @After
 
38
    public void tearDownJ4() throws Exception {
 
39
        tearDown();
 
40
    }
 
41
    
 
42
 
 
43
    /**
 
44
     * test if auto-installed visited property is respected.
 
45
     *
 
46
     */
 
47
    @Test
 
48
    public void testConstructorsAndCustomTargetInstall() {
 
49
        Object target = new Object();
 
50
        final boolean visitedIsTrue = true;
 
51
        AbstractHyperlinkAction linkAction = new AbstractHyperlinkAction<Object>(target) {
 
52
 
 
53
            public void actionPerformed(ActionEvent e) {
 
54
                // TODO Auto-generated method stub
 
55
                
 
56
            }
 
57
 
 
58
            @Override
 
59
            protected void installTarget() {
 
60
                super.installTarget();
 
61
                setVisited(visitedIsTrue);
 
62
            }
 
63
            
 
64
            
 
65
            
 
66
        };
 
67
        assertEquals(visitedIsTrue, linkAction.isVisited());
 
68
        
 
69
    }
 
70
    /**
 
71
     * test constructors with parameters
 
72
     *
 
73
     */
 
74
    @Test
 
75
    public void testConstructors() {
 
76
        Object target = new Object();
 
77
        AbstractHyperlinkAction<Object> linkAction = new AbstractHyperlinkAction<Object>(target) {
 
78
 
 
79
            public void actionPerformed(ActionEvent e) {
 
80
                // TODO Auto-generated method stub
 
81
                
 
82
            }
 
83
            
 
84
        };
 
85
        assertEquals(target, linkAction.getTarget());
 
86
        assertFalse(linkAction.isVisited());
 
87
    }
 
88
    /**
 
89
     * test visited/target properties of LinkAction.
 
90
     *
 
91
     */
 
92
    @Test
 
93
    public void testLinkAction() {
 
94
       AbstractHyperlinkAction<Object> linkAction = new AbstractHyperlinkAction<Object>(null) {
 
95
 
 
96
        public void actionPerformed(ActionEvent e) {
 
97
            // TODO Auto-generated method stub
 
98
            
 
99
        }
 
100
           
 
101
       };
 
102
       linkAction.addPropertyChangeListener(report);
 
103
       
 
104
       boolean visited = linkAction.isVisited();
 
105
       assertFalse(visited);
 
106
       linkAction.setVisited(!visited);
 
107
       assertEquals(!visited, linkAction.isVisited());
 
108
       assertEquals(1, report.getEventCount(AbstractHyperlinkAction.VISITED_KEY));
 
109
       
 
110
       report.clear();
 
111
       // testing target property
 
112
       assertNull(linkAction.getTarget());
 
113
       Object target = new Object();
 
114
       linkAction.setTarget(target);
 
115
       assertEquals(target, linkAction.getTarget());
 
116
       assertEquals(1, report.getEventCount("target"));
 
117
       // testing documented default side-effects of un/installTarget
 
118
       assertEquals(target.toString(), linkAction.getName());
 
119
       assertFalse(linkAction.isVisited());
 
120
       assertEquals(1, report.getEventCount(Action.NAME));
 
121
       assertEquals(1, report.getEventCount(AbstractHyperlinkAction.VISITED_KEY));
 
122
       // fired the expected events only.
 
123
       assertEquals(3, report.getEventCount());
 
124
    }
 
125
 
 
126
    @Override
 
127
    protected void setUp() throws Exception {
 
128
        super.setUp();
 
129
        report = new PropertyChangeReport();
 
130
    }
 
131
 
 
132
    
 
133
}