1 /*
2 * Scope: a generic MVC framework.
3 * Copyright (c) 2000-2002, Steve Meyfroidt
4 * All rights reserved.
5 * Email: smeyfroi@users.sourceforge.net
6 *
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name "Scope" nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 *
37 * $Id: TestSUnboundPanel.java,v 1.5 2002/08/05 13:19:26 ludovicc Exp $
38 */
39
40
41 package test.view.swing;
42
43
44 import javax.swing.JPanel;
45 import junit.framework.TestCase;
46 import org.apache.commons.logging.LogFactory;import org.apache.commons.logging.Log;
47 import org.scopemvc.core.Selector;
48 import org.scopemvc.view.swing.SCheckBox;
49 import org.scopemvc.view.swing.SUnboundPanel;
50
51
52 /***
53 *
54 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net>Steve Meyfroidt</A>
55 * @version $Revision: 1.5 $ $Date: 2002/08/05 13:19:26 $
56 */
57 public final class TestSUnboundPanel extends TestCase {
58
59
60 private static final Log LOG = LogFactory.getLog(TestSUnboundPanel.class);
61
62
63 private SCheckBox checkbox1;
64 private SCheckBox checkbox2;
65 private SwingDummyController controller;
66 private SUnboundPanel view;
67 private SwingDummyModel model;
68
69
70 public TestSUnboundPanel(String inName) {
71 super(inName);
72 }
73
74
75 protected void setUp() throws Exception {
76
77 checkbox1 = new SCheckBox();
78 checkbox2 = new SCheckBox();
79
80 view = new SUnboundPanel();
81 view.add(checkbox1);
82 JPanel p = new JPanel();
83 p.add(checkbox2);
84 view.add(p);
85
86 controller = new SwingDummyController();
87 controller.setView(view);
88 controller.startup(); // does showView()
89
90 model = new SwingDummyModel();
91 }
92
93
94 protected void tearDown() {
95 controller.shutdown();
96 }
97
98
99 public void testUnbound() throws Exception {
100 SuiteViewSwing.waitForAWT();
101 assertNull(view.getBoundModel());
102 }
103
104
105 public void testBind1() throws Exception {
106 checkbox1.setSelector(Selector.fromString("booleanProperty"));
107 assertEquals(Selector.fromString("booleanProperty"), checkbox1.getSelector());
108 checkbox2.setSelector(Selector.fromString("booleanProperty"));
109 assertEquals(Selector.fromString("booleanProperty"), checkbox2.getSelector());
110
111 controller.setModel(model);
112 SuiteViewSwing.waitForAWT();
113 assertNull(view.getBoundModel());
114
115 assertNull(checkbox1.getBoundModel());
116 assertNull(checkbox2.getBoundModel());
117 }
118 }
119
This page was automatically generated by Maven