View Javadoc
1 /* 2 * Scope: a generic MVC framework. 3 * Copyright (c) 2000-2002, The Scope team 4 * All rights reserved. 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * Neither the name "Scope" nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * 36 * $Id: TestBasicModel.java,v 1.4 2002/09/12 19:09:34 ludovicc Exp $ 37 */ 38 package test.model.basic; 39 40 import java.util.*; 41 import junit.framework.TestCase; 42 43 import org.scopemvc.core.*; 44 import org.scopemvc.model.basic.*; 45 46 /*** 47 * <P> 48 * 49 * </P> 50 * 51 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A> 52 * @created 05 September 2002 53 * @version $Revision: 1.4 $ $Date: 2002/09/12 19:09:34 $ 54 */ 55 public final class TestBasicModel extends TestCase implements ModelChangeListener { 56 57 private BasicTestModel model1; 58 private boolean modelChanged; 59 private String modelChangedName; 60 61 62 /*** 63 * Constructor for the TestBasicModel object 64 * 65 * @param inName Name of the test 66 */ 67 public TestBasicModel(String inName) { 68 super(inName); 69 } 70 71 72 // ------------------------------ model change event ------------------------------- 73 74 /*** 75 * A unit test for JUnit 76 * 77 * @throws Exception Any abnormal exception 78 */ 79 public void testSimpleModelChangeEvent() throws Exception { 80 81 model1.addModelChangeListener(this); 82 model1.setName("model1x"); 83 84 assertTrue(modelChanged); 85 assertTrue(modelChangedName.lastIndexOf("name") != -1); 86 } 87 88 89 /*** 90 * A unit test for JUnit 91 * 92 * @throws Exception Any abnormal exception 93 */ 94 public void testSubModelChangeEvent() throws Exception { 95 96 model1.addModelChangeListener(this); 97 BasicTestModel model2 = new BasicTestModel("model2"); 98 model1.setSubModel(model2); 99 100 assertTrue(modelChanged); 101 assertTrue(modelChangedName.lastIndexOf("subModel") != -1); 102 103 modelChanged = false; 104 modelChangedName = ""; 105 model2.setName("model2x"); 106 107 assertTrue(modelChanged); 108 assertTrue(modelChangedName.lastIndexOf("subModel.name") != -1); 109 } 110 111 112 /*** 113 * A unit test for JUnit 114 * 115 * @throws Exception Any abnormal exception 116 */ 117 public void testActivation() throws Exception { 118 119 model1.deactivate(); 120 121 model1.addModelChangeListener(this); 122 BasicTestModel model2 = new BasicTestModel("model2"); 123 model1.setSubModel(model2); 124 125 assertTrue(!modelChanged); 126 127 model1.activate(); 128 129 modelChanged = false; 130 modelChangedName = ""; 131 model2.setName("model2x"); 132 133 assertTrue(modelChanged); 134 assertTrue(modelChangedName.lastIndexOf("subModel.name") != -1); 135 } 136 137 138 /*** 139 * TODO: document the method 140 * 141 * @param inEvent TODO: Describe the Parameter 142 */ 143 public void modelChanged(ModelChangeEvent inEvent) { 144 modelChanged = true; 145 modelChangedName = inEvent.toString(); 146 } 147 148 149 /*** 150 * The JUnit setup method 151 */ 152 protected void setUp() { 153 model1 = new BasicTestModel("model1"); 154 modelChanged = false; 155 modelChangedName = ""; 156 } 157 }

This page was automatically generated by Maven