1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.application;
20
21 import java.util.List;
22 import java.util.Map;
23 import java.util.TimeZone;
24
25 import javax.el.ValueExpression;
26 import javax.faces.FactoryFinder;
27 import javax.faces.application.ResourceDependency;
28 import javax.faces.component.UIComponent;
29 import javax.faces.component.UIComponentBase;
30 import javax.faces.component.UIOutput;
31 import javax.faces.component.UIPanel;
32 import javax.faces.context.FacesContext;
33 import javax.faces.convert.Converter;
34 import javax.faces.convert.DateTimeConverter;
35 import javax.faces.event.ComponentSystemEvent;
36 import javax.faces.event.ComponentSystemEventListener;
37 import javax.faces.event.ListenerFor;
38 import javax.faces.event.PostAddToViewEvent;
39 import javax.faces.render.RenderKitFactory;
40 import javax.faces.render.Renderer;
41 import javax.faces.render.RendererWrapper;
42
43 import org.apache.myfaces.component.ComponentResourceContainer;
44 import org.apache.myfaces.config.RuntimeConfig;
45 import org.apache.myfaces.renderkit.html.HtmlScriptRenderer;
46 import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
47 import org.apache.myfaces.test.el.MockExpressionFactory;
48 import org.apache.myfaces.test.mock.MockPropertyResolver;
49 import org.apache.myfaces.test.mock.MockRenderKit;
50 import org.apache.myfaces.test.mock.MockRenderKitFactory;
51 import org.apache.myfaces.test.mock.MockServletContext;
52 import org.apache.myfaces.test.mock.MockVariableResolver;
53 import org.junit.Assert;
54 import org.junit.Test;
55
56 public class ApplicationImplAnnotationTest extends AbstractJsfConfigurableMockTestCase
57 {
58
59
60
61 public ApplicationImplAnnotationTest()
62 {
63 }
64
65 @Override
66 protected void setFactories() throws Exception
67 {
68 ((MockServletContext)servletContext).addInitParameter(
69 "javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE", "true");
70 super.setFactories();
71 FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
72 ApplicationFactoryImpl.class.getName());
73 FactoryFinder.setFactory(
74 FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
75 "org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl");
76 }
77
78 @Override
79 protected void setUpExternalContext() throws Exception
80 {
81 super.setUpExternalContext();
82
83 RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
84 new MockPropertyResolver());
85 RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
86 new MockVariableResolver());
87 RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
88 new MockExpressionFactory());
89 }
90
91 @Override
92 protected void setUpApplication() throws Exception
93 {
94 super.setUpApplication();
95
96 application.addComponent(UIOutput.COMPONENT_TYPE, UIOutput.class
97 .getName());
98 application.addComponent(UIPanel.COMPONENT_TYPE, UIPanel.class
99 .getName());
100 application.addComponent(ComponentResourceContainer.COMPONENT_TYPE,
101 ComponentResourceContainer.class.getName());
102 }
103
104 @Override
105 protected void setUpRenderKit() throws Exception
106 {
107 RenderKitFactory renderKitFactory = (RenderKitFactory)
108 FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
109 renderKit = new MockRenderKit();
110 renderKit.addRenderer("javax.faces.Output", "javax.faces.resource.Script", new HtmlScriptRenderer());
111 renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
112 }
113
114 @Override
115 public void tearDown() throws Exception
116 {
117 RuntimeConfig.getCurrentInstance(externalContext).purge();
118 super.tearDown();
119 }
120
121
122
123
124
125 public static class UITestComponentA extends UIComponentBase
126 {
127 public static final String COMPONENT_TYPE = "javax.faces.TestComponentA";
128 public static final String COMPONENT_FAMILY = "javax.faces.TestComponentA";
129 public static final String DEFAULT_RENDERER_TYPE = "javax.faces.TestComponentA";
130
131 public UITestComponentA()
132 {
133 setRendererType(DEFAULT_RENDERER_TYPE);
134 }
135
136 @Override
137 public String getFamily()
138 {
139 return COMPONENT_FAMILY;
140 }
141 }
142
143 @ListenerFor(systemEventClass=PostAddToViewEvent.class,
144 sourceClass=UIComponentBase.class)
145 @ResourceDependency(library = "testLib", name = "testResource.js")
146 public static class TestRendererA extends Renderer implements ComponentSystemEventListener
147 {
148 public void processEvent(ComponentSystemEvent event)
149 {
150 FacesContext.getCurrentInstance().getAttributes().put("oam.test.TestRendererA", Boolean.TRUE);
151 }
152 }
153
154 public static class FakeTestRendererWrapper extends RendererWrapper implements ComponentSystemEventListener
155 {
156 private Renderer delegate;
157
158 public FakeTestRendererWrapper(Renderer delegate)
159 {
160 this.delegate = delegate;
161 }
162
163 @Override
164 public Renderer getWrapped()
165 {
166 return delegate;
167 }
168
169 public void processEvent(ComponentSystemEvent event)
170 {
171
172
173
174
175 FacesContext.getCurrentInstance().getAttributes().put("oam.test.FakeTestRendererWrapper", Boolean.TRUE);
176 }
177 }
178
179 @ListenerFor(systemEventClass=PostAddToViewEvent.class,
180 sourceClass=UIComponentBase.class)
181 public static class TestRendererWrapper extends RendererWrapper implements ComponentSystemEventListener
182 {
183 private Renderer delegate;
184
185 public TestRendererWrapper(Renderer delegate)
186 {
187 this.delegate = delegate;
188 }
189
190 @Override
191 public Renderer getWrapped()
192 {
193 return delegate;
194 }
195
196 public void processEvent(ComponentSystemEvent event)
197 {
198 FacesContext.getCurrentInstance().getAttributes().put("oam.test.TestRendererWrapper", Boolean.TRUE);
199 }
200 }
201
202 public static class TestRendererWrapper2 extends RendererWrapper
203 {
204 private Renderer delegate;
205
206 public TestRendererWrapper2(Renderer delegate)
207 {
208 this.delegate = delegate;
209 }
210
211 @Override
212 public Renderer getWrapped()
213 {
214 return delegate;
215 }
216 }
217
218
219 @Test
220 public void testCreateComponentRenderer() throws Exception
221 {
222 facesContext.getViewRoot().setRenderKitId(
223 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
224 facesContext.getRenderKit().addRenderer(
225 UITestComponentA.COMPONENT_FAMILY,
226 UITestComponentA.DEFAULT_RENDERER_TYPE, new TestRendererA());
227
228 application.addComponent(UITestComponentA.COMPONENT_TYPE,
229 UITestComponentA.class.getName());
230
231 UITestComponentA comp = (UITestComponentA) application.createComponent(facesContext,
232 UITestComponentA.COMPONENT_TYPE,
233 UITestComponentA.DEFAULT_RENDERER_TYPE);
234
235 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
236 Assert.assertEquals(1,componentResources.size());
237 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
238 Assert.assertEquals("testResource.js",attrMap.get("name"));
239 Assert.assertEquals("testLib",attrMap.get("library"));
240 }
241
242
243
244
245
246
247
248
249 @Test
250 public void testCreateComponentRendererWrapper1() throws Exception
251 {
252 facesContext.getViewRoot().setRenderKitId(
253 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
254 facesContext.getRenderKit().addRenderer(
255 UITestComponentA.COMPONENT_FAMILY,
256 UITestComponentA.DEFAULT_RENDERER_TYPE, new FakeTestRendererWrapper(new TestRendererA()));
257
258 application.addComponent(UITestComponentA.COMPONENT_TYPE,
259 UITestComponentA.class.getName());
260
261 UITestComponentA comp = (UITestComponentA) application.createComponent(facesContext,
262 UITestComponentA.COMPONENT_TYPE,
263 UITestComponentA.DEFAULT_RENDERER_TYPE);
264
265 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
266 Assert.assertEquals(1,componentResources.size());
267 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
268 Assert.assertEquals("testResource.js",attrMap.get("name"));
269 Assert.assertEquals("testLib",attrMap.get("library"));
270
271
272 facesContext.getViewRoot().getChildren().add(comp);
273
274 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
275 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
276
277 facesContext.getAttributes().remove("oam.test.TestRendererWrapper");
278 facesContext.getAttributes().remove("oam.test.TestRendererA");
279
280 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
281 comp.pushComponentToEL(facesContext, comp);
282 Object state = comp.saveState(facesContext);
283 comp.popComponentFromEL(facesContext);
284 facesContext.getViewRoot().popComponentFromEL(facesContext);
285
286 UITestComponentA comp2 = new UITestComponentA();
287
288 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
289 comp.pushComponentToEL(facesContext, comp);
290 comp2.restoreState(facesContext, state);
291 comp.popComponentFromEL(facesContext);
292 facesContext.getViewRoot().popComponentFromEL(facesContext);
293
294 facesContext.getViewRoot().getChildren().clear();
295
296
297 facesContext.getViewRoot().getChildren().add(comp2);
298
299 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
300 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
301 }
302
303
304
305
306
307
308
309 @Test
310 public void testCreateComponentRendererWrapper2() throws Exception
311 {
312 facesContext.getViewRoot().setRenderKitId(
313 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
314 facesContext.getRenderKit().addRenderer(
315 UITestComponentA.COMPONENT_FAMILY,
316 UITestComponentA.DEFAULT_RENDERER_TYPE, new TestRendererWrapper2(new TestRendererA()));
317
318 application.addComponent(UITestComponentA.COMPONENT_TYPE,
319 UITestComponentA.class.getName());
320
321 UITestComponentA comp = (UITestComponentA) application.createComponent(facesContext,
322 UITestComponentA.COMPONENT_TYPE,
323 UITestComponentA.DEFAULT_RENDERER_TYPE);
324
325 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
326 Assert.assertEquals(1,componentResources.size());
327 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
328 Assert.assertEquals("testResource.js",attrMap.get("name"));
329 Assert.assertEquals("testLib",attrMap.get("library"));
330
331
332 facesContext.getViewRoot().getChildren().add(comp);
333
334 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
335
336 facesContext.getAttributes().remove("oam.test.TestRendererA");
337
338 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
339 comp.pushComponentToEL(facesContext, comp);
340 Object state = comp.saveState(facesContext);
341 comp.popComponentFromEL(facesContext);
342 facesContext.getViewRoot().popComponentFromEL(facesContext);
343
344 UITestComponentA comp2 = new UITestComponentA();
345
346 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
347 comp.pushComponentToEL(facesContext, comp);
348 comp2.restoreState(facesContext, state);
349 comp.popComponentFromEL(facesContext);
350 facesContext.getViewRoot().popComponentFromEL(facesContext);
351
352 facesContext.getViewRoot().getChildren().clear();
353
354
355 facesContext.getViewRoot().getChildren().add(comp2);
356
357 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
358 }
359
360
361
362
363
364 @Test
365 public void testCreateComponentRendererWrapper3() throws Exception
366 {
367 facesContext.getViewRoot().setRenderKitId(
368 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
369 facesContext.getRenderKit().addRenderer(
370 UITestComponentA.COMPONENT_FAMILY,
371 UITestComponentA.DEFAULT_RENDERER_TYPE,
372 new FakeTestRendererWrapper(new TestRendererWrapper2(new TestRendererA())));
373
374 application.addComponent(UITestComponentA.COMPONENT_TYPE,
375 UITestComponentA.class.getName());
376
377 UITestComponentA comp = (UITestComponentA) application.createComponent(facesContext,
378 UITestComponentA.COMPONENT_TYPE,
379 UITestComponentA.DEFAULT_RENDERER_TYPE);
380
381 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
382 Assert.assertEquals(1,componentResources.size());
383 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
384 Assert.assertEquals("testResource.js",attrMap.get("name"));
385 Assert.assertEquals("testLib",attrMap.get("library"));
386
387
388 facesContext.getViewRoot().getChildren().add(comp);
389
390 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
391 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
392
393 facesContext.getAttributes().remove("oam.test.TestRendererWrapper");
394 facesContext.getAttributes().remove("oam.test.TestRendererA");
395
396 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
397 comp.pushComponentToEL(facesContext, comp);
398 Object state = comp.saveState(facesContext);
399 comp.popComponentFromEL(facesContext);
400 facesContext.getViewRoot().popComponentFromEL(facesContext);
401
402 UITestComponentA comp2 = new UITestComponentA();
403
404 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
405 comp.pushComponentToEL(facesContext, comp);
406 comp2.restoreState(facesContext, state);
407 comp.popComponentFromEL(facesContext);
408 facesContext.getViewRoot().popComponentFromEL(facesContext);
409
410 facesContext.getViewRoot().getChildren().clear();
411
412
413 facesContext.getViewRoot().getChildren().add(comp2);
414
415 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
416 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
417 }
418
419
420
421
422
423 @Test
424 public void testCreateComponentRendererWrapper4() throws Exception
425 {
426 facesContext.getViewRoot().setRenderKitId(
427 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
428 facesContext.getRenderKit().addRenderer(
429 UITestComponentA.COMPONENT_FAMILY,
430 UITestComponentA.DEFAULT_RENDERER_TYPE,
431 new TestRendererWrapper(new FakeTestRendererWrapper(
432 new TestRendererWrapper2(new TestRendererA()))) );
433
434 application.addComponent(UITestComponentA.COMPONENT_TYPE,
435 UITestComponentA.class.getName());
436
437 UITestComponentA comp = (UITestComponentA) application.createComponent(facesContext,
438 UITestComponentA.COMPONENT_TYPE,
439 UITestComponentA.DEFAULT_RENDERER_TYPE);
440
441 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
442 Assert.assertEquals(1,componentResources.size());
443 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
444 Assert.assertEquals("testResource.js",attrMap.get("name"));
445 Assert.assertEquals("testLib",attrMap.get("library"));
446
447
448 facesContext.getViewRoot().getChildren().add(comp);
449
450 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
451 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper"));
452 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
453
454 facesContext.getAttributes().remove("oam.test.TestRendererWrapper");
455 facesContext.getAttributes().remove("oam.test.TestRendererA");
456
457 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
458 comp.pushComponentToEL(facesContext, comp);
459 Object state = comp.saveState(facesContext);
460 comp.popComponentFromEL(facesContext);
461 facesContext.getViewRoot().popComponentFromEL(facesContext);
462
463 UITestComponentA comp2 = new UITestComponentA();
464
465 facesContext.getViewRoot().pushComponentToEL(facesContext, facesContext.getViewRoot());
466 comp.pushComponentToEL(facesContext, comp);
467 comp2.restoreState(facesContext, state);
468 comp.popComponentFromEL(facesContext);
469 facesContext.getViewRoot().popComponentFromEL(facesContext);
470
471 facesContext.getViewRoot().getChildren().clear();
472
473
474 facesContext.getViewRoot().getChildren().add(comp2);
475
476 Assert.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper"));
477 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper"));
478 Assert.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA"));
479 }
480
481 @ResourceDependency(name = "testResource.js")
482 public static class UITestComponentB extends UIComponentBase
483 {
484 public static final String COMPONENT_TYPE = "javax.faces.TestComponentB";
485 public static final String COMPONENT_FAMILY = "javax.faces.TestComponentB";
486 public static final String DEFAULT_RENDERER_TYPE = "javax.faces.TestComponentB";
487
488 public UITestComponentB()
489 {
490 setRendererType(DEFAULT_RENDERER_TYPE);
491 }
492
493 @Override
494 public String getFamily()
495 {
496 return COMPONENT_FAMILY;
497 }
498 }
499
500 @Test
501 public void testCreateComponentAnnotation() throws Exception
502 {
503 application.addComponent(UITestComponentB.COMPONENT_TYPE,
504 UITestComponentB.class.getName());
505
506 UITestComponentB comp = (UITestComponentB) application.createComponent(UITestComponentB.COMPONENT_TYPE);
507
508 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
509 Assert.assertEquals(1,componentResources.size());
510 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
511 Assert.assertEquals("testResource.js",attrMap.get("name"));
512 }
513
514 @Test
515 public void testCreateComponentRendererAnnotation() throws Exception
516 {
517 facesContext.getViewRoot().setRenderKitId(
518 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
519 facesContext.getRenderKit().addRenderer(
520 UITestComponentB.COMPONENT_FAMILY,
521 UITestComponentB.DEFAULT_RENDERER_TYPE, new TestRendererA());
522
523 application.addComponent(UITestComponentB.COMPONENT_TYPE,
524 UITestComponentB.class.getName());
525
526 UITestComponentB comp = (UITestComponentB) application.createComponent(facesContext,
527 UITestComponentB.COMPONENT_TYPE,
528 UITestComponentB.DEFAULT_RENDERER_TYPE);
529
530 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
531 Assert.assertEquals(2,componentResources.size());
532 for (UIComponent component : componentResources)
533 {
534 if ("testResource.js".equals(component.getAttributes().get("name")))
535 {
536
537 }
538 else
539 {
540 Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
541 }
542 }
543 }
544
545 @Test
546 public void testCreateComponentValueExpression1() throws Exception
547 {
548
549 ValueExpression expr = application.getExpressionFactory().createValueExpression(
550 facesContext.getELContext(), "#{testComponent}", Object.class);
551
552 application.addComponent(UITestComponentB.COMPONENT_TYPE,
553 UITestComponentB.class.getName());
554
555 UITestComponentB comp = (UITestComponentB) application.createComponent(
556 expr, facesContext, UITestComponentB.COMPONENT_TYPE);
557
558 List<UIComponent> componentResources =
559 facesContext.getViewRoot().getComponentResources(facesContext, "head");
560 Assert.assertEquals(1,componentResources.size());
561 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
562 Assert.assertEquals("testResource.js",attrMap.get("name"));
563 }
564
565 @Test
566 public void testCreateComponentValueExpression2() throws Exception
567 {
568
569 ValueExpression expr = application.getExpressionFactory().createValueExpression(
570 facesContext.getELContext(), "#{testComponent}", Object.class);
571
572 expr.setValue(facesContext.getELContext(), new UITestComponentB());
573 application.addComponent(UITestComponentB.COMPONENT_TYPE,
574 UITestComponentB.class.getName());
575
576 UITestComponentB comp = (UITestComponentB) application.createComponent(
577 expr, facesContext, UITestComponentB.COMPONENT_TYPE);
578
579 List<UIComponent> componentResources =
580 facesContext.getViewRoot().getComponentResources(facesContext, "head");
581 Assert.assertEquals(1,componentResources.size());
582 Map<String,Object> attrMap = componentResources.get(0).getAttributes();
583 Assert.assertEquals("testResource.js",attrMap.get("name"));
584 }
585
586 @Test
587 public void testCreateComponentValueExpression3() throws Exception
588 {
589
590 ValueExpression expr = application.getExpressionFactory().createValueExpression(
591 facesContext.getELContext(), "#{testComponent}", Object.class);
592
593 facesContext.getViewRoot().setRenderKitId(
594 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
595 facesContext.getRenderKit().addRenderer(
596 UITestComponentB.COMPONENT_FAMILY,
597 UITestComponentB.DEFAULT_RENDERER_TYPE, new TestRendererA());
598
599 application.addComponent(UITestComponentB.COMPONENT_TYPE,
600 UITestComponentB.class.getName());
601
602 UITestComponentB comp = (UITestComponentB) application.createComponent(expr, facesContext,
603 UITestComponentB.COMPONENT_TYPE,
604 UITestComponentB.DEFAULT_RENDERER_TYPE);
605
606 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
607 Assert.assertEquals(2,componentResources.size());
608 for (UIComponent component : componentResources)
609 {
610 if ("testResource.js".equals(component.getAttributes().get("name")))
611 {
612
613 }
614 else
615 {
616 Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
617 }
618 }
619 }
620
621 @Test
622 public void testCreateComponentValueExpression4() throws Exception
623 {
624
625 ValueExpression expr = application.getExpressionFactory().createValueExpression(
626 facesContext.getELContext(), "#{testComponent}", Object.class);
627
628 expr.setValue(facesContext.getELContext(), new UITestComponentB());
629
630 facesContext.getViewRoot().setRenderKitId(
631 MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
632 facesContext.getRenderKit().addRenderer(
633 UITestComponentB.COMPONENT_FAMILY,
634 UITestComponentB.DEFAULT_RENDERER_TYPE, new TestRendererA());
635
636 application.addComponent(UITestComponentB.COMPONENT_TYPE,
637 UITestComponentB.class.getName());
638
639 UITestComponentB comp = (UITestComponentB) application.createComponent(expr, facesContext,
640 UITestComponentB.COMPONENT_TYPE,
641 UITestComponentB.DEFAULT_RENDERER_TYPE);
642
643 List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
644 Assert.assertEquals(2,componentResources.size());
645 for (UIComponent component : componentResources)
646 {
647 if ("testResource.js".equals(component.getAttributes().get("name")))
648 {
649
650 }
651 else
652 {
653 Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
654 }
655 }
656 }
657
658 @Test
659 public void testDatetimeconverterDefaultTimezoneIsSystemTimezoneInitParameter()
660 {
661 application.addConverter(java.util.Date.class, "javax.faces.convert.DateTimeConverter");
662 Converter converter = application.createConverter(java.util.Date.class);
663 Assert.assertEquals(((DateTimeConverter) converter).getTimeZone(), TimeZone.getDefault());
664 }
665
666 }