1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package javax.faces.component; 20 21 import javax.faces.context.FacesContext; 22 import javax.faces.render.Renderer; 23 24 import org.apache.myfaces.Assert; 25 import org.apache.myfaces.TestRunner; 26 import org.apache.shale.test.base.AbstractJsfTestCase; 27 import org.easymock.classextension.EasyMock; 28 import org.easymock.classextension.IMocksControl; 29 30 /** 31 * @author Mathias Broekelmann (latest modification by $Author: lu4242 $) 32 * @version $Revision: 823343 $ $Date: 2009-10-08 16:59:45 -0500 (Thu, 08 Oct 2009) $ 33 */ 34 public class UIDataTest extends AbstractJsfTestCase 35 { 36 public UIDataTest(String name) 37 { 38 super(name); 39 } 40 41 private IMocksControl _mocksControl; 42 private UIData _testImpl; 43 44 protected void setUp() throws Exception 45 { 46 super.setUp(); 47 _mocksControl = EasyMock.createControl(); 48 _testImpl = new UIData(); 49 } 50 51 /** 52 * Test method for 53 * {@link javax.faces.component.UIData#setValueExpression(java.lang.String, javax.el.ValueExpression)}. 54 */ 55 public void testValueExpression() 56 { 57 assertSetValueExpressionException(IllegalArgumentException.class, "rowIndex"); 58 assertSetValueExpressionException(NullPointerException.class, null); 59 } 60 61 private void assertSetValueExpressionException(Class<? extends Throwable> expected, final String name) 62 { 63 Assert.assertException(expected, new TestRunner() 64 { 65 public void run() throws Throwable 66 { 67 _testImpl.setValueExpression(name, null); 68 } 69 }); 70 } 71 72 /** 73 * Test method for {@link javax.faces.component.UIData#getClientId(javax.faces.context.FacesContext)}. 74 */ 75 public void testGetClientId() 76 { 77 _testImpl.setId("xxx"); 78 Renderer renderer = _mocksControl.createMock(Renderer.class); 79 renderKit.addRenderer(UIData.COMPONENT_FAMILY, UIData.COMPONENT_TYPE, renderer ); 80 assertEquals("xxx", _testImpl.getClientId(facesContext)); 81 _testImpl.setRowIndex(99); 82 assertEquals("xxx:99", _testImpl.getClientId(facesContext)); 83 } 84 85 /** 86 * Test method for 87 * {@link javax.faces.component.UIData#invokeOnComponent(javax.faces.context.FacesContext, java.lang.String, javax.faces.component.ContextCallback)}. 88 * Tests, if invokeOnComponent also checks the facets of the h:column children (MYFACES-2370) 89 */ 90 public void testInvokeOnComponentFacesContextStringContextCallback() 91 { 92 /** 93 * Concrete class of ContextCallback needed to test invokeOnComponent. 94 * @author Jakob Korherr 95 */ 96 final class MyContextCallback implements ContextCallback 97 { 98 99 private boolean invoked = false; 100 101 public void invokeContextCallback(FacesContext context, 102 UIComponent target) 103 { 104 this.invoked = true; 105 } 106 107 } 108 109 UIComponent facet = new UIOutput(); 110 facet.setId("facet"); 111 UIColumn column = new UIColumn(); 112 column.setId("column"); 113 column.getFacets().put("header", facet); 114 _testImpl.setId("uidata"); 115 _testImpl.getChildren().add(column); 116 117 MyContextCallback callback = new MyContextCallback(); 118 _testImpl.invokeOnComponent(facesContext, facet.getClientId(facesContext), callback); 119 // the callback should have been invoked 120 assertTrue(callback.invoked); 121 } 122 123 /** 124 * Test method for {@link javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)}. 125 */ 126 public void testBroadcastFacesEvent() 127 { 128 // TODO 129 } 130 131 /** 132 * Test method for {@link javax.faces.component.UIData#encodeBegin(javax.faces.context.FacesContext)}. 133 */ 134 public void testEncodeBeginFacesContext() 135 { 136 // TODO 137 } 138 139 /** 140 * Test method for {@link javax.faces.component.UIData#encodeEnd(javax.faces.context.FacesContext)}. 141 */ 142 public void testEncodeEndFacesContext() 143 { 144 // TODO 145 } 146 147 /** 148 * Test method for {@link javax.faces.component.UIData#queueEvent(javax.faces.event.FacesEvent)}. 149 */ 150 public void testQueueEventFacesEvent() 151 { 152 // TODO 153 } 154 155 /** 156 * Test method for {@link javax.faces.component.UIData#processDecodes(javax.faces.context.FacesContext)}. 157 */ 158 public void testProcessDecodesFacesContext() 159 { 160 // TODO 161 } 162 163 /** 164 * Test method for {@link javax.faces.component.UIData#processValidators(javax.faces.context.FacesContext)}. 165 */ 166 public void testProcessValidatorsFacesContext() 167 { 168 // TODO 169 } 170 171 /** 172 * Test method for {@link javax.faces.component.UIData#processUpdates(javax.faces.context.FacesContext)}. 173 */ 174 public void testProcessUpdatesFacesContext() 175 { 176 // TODO 177 } 178 179 /** 180 * Test method for {@link javax.faces.component.UIData#saveState(javax.faces.context.FacesContext)}. 181 */ 182 public void testSaveState() 183 { 184 // TODO 185 } 186 187 /** 188 * Test method for 189 * {@link javax.faces.component.UIData#restoreState(javax.faces.context.FacesContext, java.lang.Object)}. 190 */ 191 public void testRestoreState() 192 { 193 // TODO 194 } 195 196 /** 197 * Test method for {@link javax.faces.component.UIData#UIData()}. 198 */ 199 public void testUIData() 200 { 201 // TODO 202 } 203 204 /** 205 * Test method for {@link javax.faces.component.UIData#setFooter(javax.faces.component.UIComponent)}. 206 */ 207 public void testSetFooter() 208 { 209 // TODO 210 } 211 212 /** 213 * Test method for {@link javax.faces.component.UIData#getFooter()}. 214 */ 215 public void testGetFooter() 216 { 217 // TODO 218 } 219 220 /** 221 * Test method for {@link javax.faces.component.UIData#setHeader(javax.faces.component.UIComponent)}. 222 */ 223 public void testSetHeader() 224 { 225 // TODO 226 } 227 228 /** 229 * Test method for {@link javax.faces.component.UIData#getHeader()}. 230 */ 231 public void testGetHeader() 232 { 233 // TODO 234 } 235 236 /** 237 * Test method for {@link javax.faces.component.UIData#isRowAvailable()}. 238 */ 239 public void testIsRowAvailable() 240 { 241 // TODO 242 } 243 244 /** 245 * Test method for {@link javax.faces.component.UIData#getRowCount()}. 246 */ 247 public void testGetRowCount() 248 { 249 // TODO 250 } 251 252 /** 253 * Test method for {@link javax.faces.component.UIData#getRowData()}. 254 */ 255 public void testGetRowData() 256 { 257 // TODO 258 } 259 260 /** 261 * Test method for {@link javax.faces.component.UIData#getRowIndex()}. 262 */ 263 public void testGetRowIndex() 264 { 265 // TODO 266 } 267 268 /** 269 * Test method for {@link javax.faces.component.UIData#setRowIndex(int)}. 270 */ 271 public void testSetRowIndex() 272 { 273 // TODO 274 } 275 276 /** 277 * Test method for {@link javax.faces.component.UIData#getDataModel()}. 278 */ 279 public void testGetDataModel() 280 { 281 // TODO 282 } 283 284 /** 285 * Test method for {@link javax.faces.component.UIData#setDataModel(javax.faces.model.DataModel)}. 286 */ 287 public void testSetDataModel() 288 { 289 // TODO 290 } 291 292 /** 293 * Test method for {@link javax.faces.component.UIData#setValue(java.lang.Object)}. 294 */ 295 public void testSetValue() 296 { 297 // TODO 298 } 299 300 /** 301 * Test method for {@link javax.faces.component.UIData#setRows(int)}. 302 */ 303 public void testSetRows() 304 { 305 // TODO 306 } 307 308 /** 309 * Test method for {@link javax.faces.component.UIData#setFirst(int)}. 310 */ 311 public void testSetFirst() 312 { 313 // TODO 314 } 315 316 /** 317 * Test method for {@link javax.faces.component.UIData#getValue()}. 318 */ 319 public void testGetValue() 320 { 321 // TODO 322 } 323 324 /** 325 * Test method for {@link javax.faces.component.UIData#getVar()}. 326 */ 327 public void testGetVar() 328 { 329 // TODO 330 } 331 332 /** 333 * Test method for {@link javax.faces.component.UIData#setVar(java.lang.String)}. 334 */ 335 public void testSetVar() 336 { 337 // TODO 338 } 339 340 /** 341 * Test method for {@link javax.faces.component.UIData#getRows()}. 342 */ 343 public void testGetRows() 344 { 345 // TODO 346 } 347 348 /** 349 * Test method for {@link javax.faces.component.UIData#getFirst()}. 350 */ 351 public void testGetFirst() 352 { 353 // TODO 354 } 355 356 /** 357 * Test method for {@link javax.faces.component.UIData#getFamily()}. 358 */ 359 public void testGetFamily() 360 { 361 // TODO 362 } 363 364 }