Author: mes
Date: 2010-10-27 16:38:07 -0700 (Wed, 27 Oct 2010)
New Revision: 22533
Added:
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/HasAnnotatedMethod.java
Modified:
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/AbstractGUITunableHandlerTest.java
Log:
added unit tests
Modified:
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/AbstractGUITunableHandlerTest.java
===================================================================
---
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/AbstractGUITunableHandlerTest.java
2010-10-27 23:05:24 UTC (rev 22532)
+++
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/AbstractGUITunableHandlerTest.java
2010-10-27 23:38:07 UTC (rev 22533)
@@ -29,6 +29,7 @@
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import org.cytoscape.work.Tunable;
@@ -39,32 +40,53 @@
public class AbstractGUITunableHandlerTest {
private static class SimpleGUITunableHandler extends
AbstractGUITunableHandler {
- SimpleGUITunableHandler(final Field field, final Object
instance, final Tunable tunable) {
+ SimpleGUITunableHandler(final Method getter, final Method
setter,
+ final Object instance, final Tunable
tunable) {
+ super(getter, setter, instance, tunable);
+ }
+
+ SimpleGUITunableHandler(final Field field, final Object
instance,
+ final Tunable tunable) {
super(field, instance, tunable);
}
- public void handle() {
- }
+ public void handle() { }
}
- private SimpleGUITunableHandler handler;
+ private SimpleGUITunableHandler fieldHandler;
+ private SimpleGUITunableHandler methodHandler;
@Before
public void initialise() throws Exception {
final HasAnnotatedField hasAnnotatedField = new
HasAnnotatedField();
final Field annotatedIntField =
hasAnnotatedField.getClass().getField("annotatedInt");
final Tunable annotatedIntTunable =
annotatedIntField.getAnnotation(Tunable.class);
+ fieldHandler = new SimpleGUITunableHandler(annotatedIntField,
hasAnnotatedField, annotatedIntTunable);
- handler = new SimpleGUITunableHandler(annotatedIntField,
hasAnnotatedField, annotatedIntTunable);
+ final HasAnnotatedMethod hasAnnotatedMethod = new
HasAnnotatedMethod();
+ final Method setter =
hasAnnotatedMethod.getClass().getMethod("setAnnotatedInt", int.class);
+ final Method getter =
hasAnnotatedMethod.getClass().getMethod("getAnnotatedInt");
+ final Tunable annotatedMethodTunable =
getter.getAnnotation(Tunable.class);
+ methodHandler = new SimpleGUITunableHandler(getter, setter,
hasAnnotatedMethod, annotatedMethodTunable);
}
@Test
- public void testConstructor() throws Exception {
- assertEquals("Unexpected return value from getState()!", "42",
handler.getState());
+ public void testFieldConstructor() throws Exception {
+ assertEquals("Unexpected return value from getState()!", "42",
fieldHandler.getState());
}
@Test
- public void testGetJPanel() throws Exception {
- assertNotNull("getJPanel() must *not* return null!",
handler.getJPanel());
+ public void testFieldGetJPanel() throws Exception {
+ assertNotNull("getJPanel() must *not* return null!",
fieldHandler.getJPanel());
}
+
+ @Test
+ public void testMethodConstructor() throws Exception {
+ assertEquals("Unexpected return value from getState()!", "47",
methodHandler.getState());
+ }
+
+ @Test
+ public void testMethodGetJPanel() throws Exception {
+ assertNotNull("getJPanel() must *not* return null!",
methodHandler.getJPanel());
+ }
}
Added:
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/HasAnnotatedMethod.java
===================================================================
---
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/HasAnnotatedMethod.java
(rev 0)
+++
core3/work-swing-api/trunk/src/test/java/org/cytoscape/work/swing/HasAnnotatedMethod.java
2010-10-27 23:38:07 UTC (rev 22533)
@@ -0,0 +1,42 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.work.swing;
+
+
+import org.cytoscape.work.Tunable;
+
+
+public class HasAnnotatedMethod {
+ @Tunable(description="An annotated field", groups={"group1"},
dependsOn="other=false",
+
params="input=true;alignments=horizontal;displayState=uncollapsed;groupTitles=hidden,displayed")
+ public int getAnnotatedInt() { return value; }
+
+ public void setAnnotatedInt(int x) { value = x; }
+
+ private int value = 47;
+}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.