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 org.apache.myfaces.trinidad.component;
20  
21  import javax.faces.component.NamingContainer;
22  import javax.faces.component.UIComponent;
23  import javax.faces.component.UIForm;
24  import javax.faces.component.UIViewRoot;
25  
26  import junit.framework.Test;
27  import junit.framework.TestCase;
28  import junit.framework.TestSuite;
29  
30  import org.apache.myfaces.trinidad.component.UIXPanel;
31  
32  public class FindComponentTest extends TestCase
33  {
34    public static final Test suite()
35    {
36      return new TestSuite(FindComponentTest.class);
37    }
38    
39    public static void main(String[] args) throws Throwable
40    {
41      junit.textui.TestRunner.run(suite());
42    }
43  
44    public FindComponentTest(
45      String testName)
46    {
47      super(testName);
48    }
49  
50    static private class TestNamingContainer extends UIXPanel
51                                             implements NamingContainer
52    {
53      @Override
54      public UIComponent findComponent(String expr)
55      {
56        addToTrace(getId());
57        addToTrace(expr);
58        return super.findComponent(expr);
59      }
60  
61      public static void clearTrace()
62      {
63        _trace = new StringBuffer();
64      }
65  
66      // Append to the current trace log (or clear if null)
67      public static void addToTrace(String text)
68      {
69        _trace.append('/');
70        _trace.append(text);
71      }
72  
73      // Retrieve the current trace log
74      public static String getTrace()
75      {
76        return _trace.toString();
77      }
78  
79      // Accumulated trace log
80      private static StringBuffer _trace = new StringBuffer();
81    }
82  
83    
84    // Test nested NamingContainer callbacks
85    @SuppressWarnings("unchecked")
86    public void testNested()
87    {
88      TestNamingContainer a = new TestNamingContainer(); a.setId("a");
89      TestNamingContainer b = new TestNamingContainer(); b.setId("b");
90      TestNamingContainer d = new TestNamingContainer(); d.setId("d");
91      UIXPanel e = new UIXPanel(); e.setId("e");
92      UIXPanel g = new UIXPanel(); g.setId("g");
93      a.getChildren().add(b);
94      b.getChildren().add(d);
95      b.getChildren().add(g);
96      d.getChildren().add(e);
97      
98      TestNamingContainer.clearTrace();
99      assertTrue(a == a.findComponent("a"));
100     assertEquals("/a/a", TestNamingContainer.getTrace());
101     
102     TestNamingContainer.clearTrace();
103     assertTrue(a == a.findComponent(":a"));
104     assertEquals("/a/:a", TestNamingContainer.getTrace());
105     
106     TestNamingContainer.clearTrace();
107     assertTrue(b == a.findComponent("b"));
108     assertEquals("/a/b", TestNamingContainer.getTrace());
109     
110     TestNamingContainer.clearTrace();
111     assertTrue(b == a.findComponent(":b"));
112     assertEquals("/a/:b", TestNamingContainer.getTrace());
113     
114     TestNamingContainer.clearTrace();
115     assertTrue(d == a.findComponent("b:d"));
116     assertEquals("/a/b:d/b/d", TestNamingContainer.getTrace());
117     
118     TestNamingContainer.clearTrace();
119     assertTrue(d == a.findComponent(":b:d"));
120     assertEquals("/a/:b:d/b/d", TestNamingContainer.getTrace());
121     
122     TestNamingContainer.clearTrace();
123     assertTrue(e == a.findComponent("b:d:e"));
124     assertEquals("/a/b:d:e/b/d:e/d/e", TestNamingContainer.getTrace());
125     
126     TestNamingContainer.clearTrace();
127     assertTrue(e == a.findComponent(":b:d:e"));
128     assertEquals("/a/:b:d:e/b/d:e/d/e", TestNamingContainer.getTrace());
129     
130     TestNamingContainer.clearTrace();
131     assertTrue(g == a.findComponent("b:g"));
132     assertEquals("/a/b:g/b/g", TestNamingContainer.getTrace());
133     
134     TestNamingContainer.clearTrace();
135     assertTrue(g == a.findComponent(":b:g"));
136     assertEquals("/a/:b:g/b/g", TestNamingContainer.getTrace());
137   }
138 
139 
140   @SuppressWarnings("unchecked")
141   public void testRelativeSearch()
142   {
143     // Set up a component hierarchy as follows (component ids in quotes):
144     // "a" - UIViewRoot at head of hierarchy
145     // "a" has children "b" and "c"
146     // "b" has children "d" and "g"
147     // "d" has children "e" and "f"
148     // "c" has children "h" and "i"
149     // Components "b" and "d" implement NamingContainer
150     UIViewRoot a = new UIViewRoot(); a.setId("a");
151     UIForm b = new UIForm(); b.setId("b");
152     UIXPanel c = new UIXPanel(); c.setId("c");
153     TestNamingContainer d = new TestNamingContainer(); d.setId("d");
154     UIXPanel e = new UIXPanel(); e.setId("e");
155     UIXPanel f = new UIXPanel(); f.setId("f");
156     UIXPanel g = new UIXPanel(); g.setId("g");
157     UIXPanel h = new UIXPanel(); h.setId("h");
158     UIXPanel i = new UIXPanel(); i.setId("i");
159     a.getChildren().add(b);
160     a.getChildren().add(c);
161     b.getChildren().add(d);
162     b.getChildren().add(g);
163     c.getChildren().add(h);
164     c.getChildren().add(i);
165     d.getChildren().add(e);
166     d.getChildren().add(f);
167     
168     // Positive relative searches from "a"
169     assertTrue(a == a.findComponent("a"));
170     assertTrue(b == a.findComponent("b"));
171     assertTrue(c == a.findComponent("c"));
172     assertTrue(d == a.findComponent("b:d"));
173     assertTrue(e == a.findComponent("b:d:e"));
174     assertTrue(f == a.findComponent("b:d:f"));
175     assertTrue(g == a.findComponent("b:g"));
176     assertTrue(h == a.findComponent("h"));
177     assertTrue(i == a.findComponent("i"));
178     
179     // Negative relative searches from "a"
180     assertNull(a.findComponent("d"));
181     assertNull(a.findComponent("e"));
182     assertNull(a.findComponent("f"));
183     assertNull(a.findComponent("g"));
184     
185     // Positive relative searches from "b"
186     assertTrue(b == b.findComponent("b"));
187     assertTrue(d == b.findComponent("d"));
188     assertTrue(e == b.findComponent("d:e"));
189     assertTrue(f == b.findComponent("d:f"));
190     assertTrue(g == b.findComponent("g"));
191     
192     // Negative relative searches from "b"
193     assertNull(b.findComponent("a"));
194     assertNull(b.findComponent("c"));
195     assertNull(b.findComponent("e"));
196     assertNull(b.findComponent("f"));
197     assertNull(b.findComponent("h"));
198     assertNull(b.findComponent("i"));
199     
200     // Positive relative searches from "c"
201     assertTrue(a == c.findComponent("a"));
202     assertTrue(b == c.findComponent("b"));
203     assertTrue(c == c.findComponent("c"));
204     assertTrue(d == c.findComponent("b:d"));
205     assertTrue(e == c.findComponent("b:d:e"));
206     assertTrue(f == c.findComponent("b:d:f"));
207     assertTrue(g == c.findComponent("b:g"));
208     assertTrue(h == c.findComponent("h"));
209     assertTrue(i == c.findComponent("i"));
210     
211     // Negative relative searches from "c"
212     assertNull(c.findComponent("d"));
213     assertNull(c.findComponent("e"));
214     assertNull(c.findComponent("f"));
215     assertNull(c.findComponent("g"));
216     
217     // Positive relative searches from "d"
218     assertTrue(d == d.findComponent("d"));
219     assertTrue(e == d.findComponent("e"));
220     assertTrue(f == d.findComponent("f"));
221     
222     // Negative relative searches from "d"
223     assertNull(d.findComponent("a"));
224     assertNull(d.findComponent("b"));
225     assertNull(d.findComponent("c"));
226     assertNull(d.findComponent("g"));
227     assertNull(d.findComponent("h"));
228     assertNull(d.findComponent("i"));
229     
230     // Positive relative searches from "e"
231     assertTrue(d == e.findComponent("d"));
232     assertTrue(e == e.findComponent("e"));
233     assertTrue(f == e.findComponent("f"));
234     
235     // Negative relative searches from "e"
236     assertNull(e.findComponent("a"));
237     assertNull(e.findComponent("b"));
238     assertNull(e.findComponent("c"));
239     assertNull(e.findComponent("g"));
240     assertNull(e.findComponent("h"));
241     assertNull(e.findComponent("i"));
242     
243     // Positive relative searches from "f"
244     assertTrue(d == f.findComponent("d"));
245     assertTrue(e == f.findComponent("e"));
246     assertTrue(f == f.findComponent("f"));
247     
248     // Negative relative searches from "f"
249     assertNull(f.findComponent("a"));
250     assertNull(f.findComponent("b"));
251     assertNull(f.findComponent("c"));
252     assertNull(f.findComponent("g"));
253     assertNull(f.findComponent("h"));
254     assertNull(f.findComponent("i"));
255     
256     // Positive relative searches from "g"
257     assertTrue(b == g.findComponent("b"));
258     assertTrue(d == g.findComponent("d"));
259     assertTrue(e == g.findComponent("d:e"));
260     assertTrue(f == g.findComponent("d:f"));
261     assertTrue(g == g.findComponent("g"));
262     
263     // Negative relative searches from "g"
264     assertNull(g.findComponent("a"));
265     assertNull(g.findComponent("c"));
266     assertNull(g.findComponent("e"));
267     assertNull(g.findComponent("f"));
268     assertNull(g.findComponent("h"));
269     assertNull(g.findComponent("i"));
270     
271     // Positive relative searches from "h"
272     assertTrue(a == h.findComponent("a"));
273     assertTrue(b == h.findComponent("b"));
274     assertTrue(c == h.findComponent("c"));
275     assertTrue(d == h.findComponent("b:d"));
276     assertTrue(e == h.findComponent("b:d:e"));
277     assertTrue(f == h.findComponent("b:d:f"));
278     assertTrue(g == h.findComponent("b:g"));
279     assertTrue(h == h.findComponent("h"));
280     assertTrue(i == h.findComponent("i"));
281     
282     // Negative relative searches from "h"
283     assertNull(h.findComponent("d"));
284     assertNull(h.findComponent("e"));
285     assertNull(h.findComponent("f"));
286     assertNull(h.findComponent("g"));
287     
288     // Positive relative searches from "i"
289     assertTrue(a == i.findComponent("a"));
290     assertTrue(b == i.findComponent("b"));
291     assertTrue(c == i.findComponent("c"));
292     assertTrue(d == i.findComponent("b:d"));
293     assertTrue(e == i.findComponent("b:d:e"));
294     assertTrue(f == i.findComponent("b:d:f"));
295     assertTrue(g == i.findComponent("b:g"));
296     assertTrue(h == i.findComponent("h"));
297     assertTrue(i == i.findComponent("i"));
298     
299     // Negative relative searches from "i"
300     assertNull(i.findComponent("d"));
301     assertNull(i.findComponent("e"));
302     assertNull(i.findComponent("f"));
303     assertNull(i.findComponent("g"));
304     
305     // Absolute searches from "a"
306     assertTrue(a == a.findComponent(":a"));
307     assertTrue(b == a.findComponent(":b"));
308     assertTrue(c == a.findComponent(":c"));
309     assertTrue(d == a.findComponent(":b:d"));
310     assertTrue(e == a.findComponent(":b:d:e"));
311     assertTrue(f == a.findComponent(":b:d:f"));
312     assertTrue(g == a.findComponent(":b:g"));
313     assertTrue(h == a.findComponent(":h"));
314     assertTrue(i == a.findComponent(":i"));
315     
316     // Absolute searches from "b"
317     assertTrue(a == b.findComponent(":a"));
318     assertTrue(b == b.findComponent(":b"));
319     assertTrue(c == b.findComponent(":c"));
320     assertTrue(d == b.findComponent(":b:d"));
321     assertTrue(e == b.findComponent(":b:d:e"));
322     assertTrue(f == b.findComponent(":b:d:f"));
323     assertTrue(g == b.findComponent(":b:g"));
324     assertTrue(h == b.findComponent(":h"));
325     assertTrue(i == b.findComponent(":i"));
326     
327     // Absolute searches from "c"
328     assertTrue(a == c.findComponent(":a"));
329     assertTrue(b == c.findComponent(":b"));
330     assertTrue(c == c.findComponent(":c"));
331     assertTrue(d == c.findComponent(":b:d"));
332     assertTrue(e == c.findComponent(":b:d:e"));
333     assertTrue(f == c.findComponent(":b:d:f"));
334     assertTrue(g == c.findComponent(":b:g"));
335     assertTrue(h == c.findComponent(":h"));
336     assertTrue(i == c.findComponent(":i"));
337     
338     // Absolute searches from "d"
339     assertTrue(a == d.findComponent(":a"));
340     assertTrue(b == d.findComponent(":b"));
341     assertTrue(c == d.findComponent(":c"));
342     assertTrue(d == d.findComponent(":b:d"));
343     assertTrue(e == d.findComponent(":b:d:e"));
344     assertTrue(f == d.findComponent(":b:d:f"));
345     assertTrue(g == d.findComponent(":b:g"));
346     assertTrue(h == d.findComponent(":h"));
347     assertTrue(i == d.findComponent(":i"));
348     
349     // Absolute searches from "e"
350     assertTrue(a == e.findComponent(":a"));
351     assertTrue(b == e.findComponent(":b"));
352     assertTrue(c == e.findComponent(":c"));
353     assertTrue(d == e.findComponent(":b:d"));
354     assertTrue(e == e.findComponent(":b:d:e"));
355     assertTrue(f == e.findComponent(":b:d:f"));
356     assertTrue(g == e.findComponent(":b:g"));
357     assertTrue(h == e.findComponent(":h"));
358     assertTrue(i == e.findComponent(":i"));
359     
360     // Absolute searches from "f"
361     assertTrue(a == f.findComponent(":a"));
362     assertTrue(b == f.findComponent(":b"));
363     assertTrue(c == f.findComponent(":c"));
364     assertTrue(d == f.findComponent(":b:d"));
365     assertTrue(e == f.findComponent(":b:d:e"));
366     assertTrue(f == f.findComponent(":b:d:f"));
367     assertTrue(g == f.findComponent(":b:g"));
368     assertTrue(h == f.findComponent(":h"));
369     assertTrue(i == f.findComponent(":i"));
370     
371     // Absolute searches from "g"
372     assertTrue(a == g.findComponent(":a"));
373     assertTrue(b == g.findComponent(":b"));
374     assertTrue(c == g.findComponent(":c"));
375     assertTrue(d == g.findComponent(":b:d"));
376     assertTrue(e == g.findComponent(":b:d:e"));
377     assertTrue(f == g.findComponent(":b:d:f"));
378     assertTrue(g == g.findComponent(":b:g"));
379     assertTrue(h == g.findComponent(":h"));
380     assertTrue(i == g.findComponent(":i"));
381     
382     // Absolute searches from "h"
383     assertTrue(a == h.findComponent(":a"));
384     assertTrue(b == h.findComponent(":b"));
385     assertTrue(c == h.findComponent(":c"));
386     assertTrue(d == h.findComponent(":b:d"));
387     assertTrue(e == h.findComponent(":b:d:e"));
388     assertTrue(f == h.findComponent(":b:d:f"));
389     assertTrue(g == h.findComponent(":b:g"));
390     assertTrue(h == h.findComponent(":h"));
391     assertTrue(i == h.findComponent(":i"));
392     
393     // Absolute searches from "i"
394     assertTrue(a == i.findComponent(":a"));
395     assertTrue(b == i.findComponent(":b"));
396     assertTrue(c == i.findComponent(":c"));
397     assertTrue(d == i.findComponent(":b:d"));
398     assertTrue(e == i.findComponent(":b:d:e"));
399     assertTrue(f == i.findComponent(":b:d:f"));
400     assertTrue(g == i.findComponent(":b:g"));
401     assertTrue(h == i.findComponent(":h"));
402     assertTrue(i == i.findComponent(":i"));
403   }
404 
405   @SuppressWarnings("unchecked")
406   public void testAbsoluteSearch()
407   {
408     // Set up a component hierarchy as follows (component ids in quotes):
409     // "a" - UIViewRoot at head of hierarchy
410     // "a" has children "b" and "c"
411     // "b" has children "d" and "g"
412     // "d" has children "e" and "f"
413     // "c" has children "h" and "i"
414     // Components "b" and "d" implement NamingContainer
415     UIViewRoot a = new UIViewRoot(); a.setId("a");
416     UIForm b = new UIForm(); b.setId("b");
417     UIXPanel c = new UIXPanel(); c.setId("c");
418     TestNamingContainer d = new TestNamingContainer(); d.setId("d");
419     UIXPanel e = new UIXPanel(); e.setId("e");
420     UIXPanel f = new UIXPanel(); f.setId("f");
421     UIXPanel g = new UIXPanel(); g.setId("g");
422     UIXPanel h = new UIXPanel(); h.setId("h");
423     UIXPanel i = new UIXPanel(); i.setId("i");
424     a.getChildren().add(b);
425     a.getChildren().add(c);
426     b.getChildren().add(d);
427     b.getChildren().add(g);
428     c.getChildren().add(h);
429     c.getChildren().add(i);
430     d.getChildren().add(e);
431     d.getChildren().add(f);
432         
433     // Absolute searches from "a"
434     assertTrue(a == a.findComponent(":a"));
435     assertTrue(b == a.findComponent(":b"));
436     assertTrue(c == a.findComponent(":c"));
437     assertTrue(d == a.findComponent(":b:d"));
438     assertTrue(e == a.findComponent(":b:d:e"));
439     assertTrue(f == a.findComponent(":b:d:f"));
440     assertTrue(g == a.findComponent(":b:g"));
441     assertTrue(h == a.findComponent(":h"));
442     assertTrue(i == a.findComponent(":i"));
443     
444     // Absolute searches from "b"
445     assertTrue(a == b.findComponent(":a"));
446     assertTrue(b == b.findComponent(":b"));
447     assertTrue(c == b.findComponent(":c"));
448     assertTrue(d == b.findComponent(":b:d"));
449     assertTrue(e == b.findComponent(":b:d:e"));
450     assertTrue(f == b.findComponent(":b:d:f"));
451     assertTrue(g == b.findComponent(":b:g"));
452     assertTrue(h == b.findComponent(":h"));
453     assertTrue(i == b.findComponent(":i"));
454     
455     // Absolute searches from "c"
456     assertTrue(a == c.findComponent(":a"));
457     assertTrue(b == c.findComponent(":b"));
458     assertTrue(c == c.findComponent(":c"));
459     assertTrue(d == c.findComponent(":b:d"));
460     assertTrue(e == c.findComponent(":b:d:e"));
461     assertTrue(f == c.findComponent(":b:d:f"));
462     assertTrue(g == c.findComponent(":b:g"));
463     assertTrue(h == c.findComponent(":h"));
464     assertTrue(i == c.findComponent(":i"));
465     
466     // Absolute searches from "d"
467     assertTrue(a == d.findComponent(":a"));
468     assertTrue(b == d.findComponent(":b"));
469     assertTrue(c == d.findComponent(":c"));
470     assertTrue(d == d.findComponent(":b:d"));
471     assertTrue(e == d.findComponent(":b:d:e"));
472     assertTrue(f == d.findComponent(":b:d:f"));
473     assertTrue(g == d.findComponent(":b:g"));
474     assertTrue(h == d.findComponent(":h"));
475     assertTrue(i == d.findComponent(":i"));
476     
477     // Absolute searches from "e"
478     assertTrue(a == e.findComponent(":a"));
479     assertTrue(b == e.findComponent(":b"));
480     assertTrue(c == e.findComponent(":c"));
481     assertTrue(d == e.findComponent(":b:d"));
482     assertTrue(e == e.findComponent(":b:d:e"));
483     assertTrue(f == e.findComponent(":b:d:f"));
484     assertTrue(g == e.findComponent(":b:g"));
485     assertTrue(h == e.findComponent(":h"));
486     assertTrue(i == e.findComponent(":i"));
487     
488     // Absolute searches from "f"
489     assertTrue(a == f.findComponent(":a"));
490     assertTrue(b == f.findComponent(":b"));
491     assertTrue(c == f.findComponent(":c"));
492     assertTrue(d == f.findComponent(":b:d"));
493     assertTrue(e == f.findComponent(":b:d:e"));
494     assertTrue(f == f.findComponent(":b:d:f"));
495     assertTrue(g == f.findComponent(":b:g"));
496     assertTrue(h == f.findComponent(":h"));
497     assertTrue(i == f.findComponent(":i"));
498     
499     // Absolute searches from "g"
500     assertTrue(a == g.findComponent(":a"));
501     assertTrue(b == g.findComponent(":b"));
502     assertTrue(c == g.findComponent(":c"));
503     assertTrue(d == g.findComponent(":b:d"));
504     assertTrue(e == g.findComponent(":b:d:e"));
505     assertTrue(f == g.findComponent(":b:d:f"));
506     assertTrue(g == g.findComponent(":b:g"));
507     assertTrue(h == g.findComponent(":h"));
508     assertTrue(i == g.findComponent(":i"));
509     
510     // Absolute searches from "h"
511     assertTrue(a == h.findComponent(":a"));
512     assertTrue(b == h.findComponent(":b"));
513     assertTrue(c == h.findComponent(":c"));
514     assertTrue(d == h.findComponent(":b:d"));
515     assertTrue(e == h.findComponent(":b:d:e"));
516     assertTrue(f == h.findComponent(":b:d:f"));
517     assertTrue(g == h.findComponent(":b:g"));
518     assertTrue(h == h.findComponent(":h"));
519     assertTrue(i == h.findComponent(":i"));
520     
521     // Absolute searches from "i"
522     assertTrue(a == i.findComponent(":a"));
523     assertTrue(b == i.findComponent(":b"));
524     assertTrue(c == i.findComponent(":c"));
525     assertTrue(d == i.findComponent(":b:d"));
526     assertTrue(e == i.findComponent(":b:d:e"));
527     assertTrue(f == i.findComponent(":b:d:f"));
528     assertTrue(g == i.findComponent(":b:g"));
529     assertTrue(h == i.findComponent(":h"));
530     assertTrue(i == i.findComponent(":i"));
531   }
532     
533   @SuppressWarnings("unchecked")
534   public void testExceptions()
535   {
536     // Set up a component hierarchy as follows (component ids in quotes):
537     // "a" - UIViewRoot at head of hierarchy
538     // "a" has children "b" and "c"
539     // "b" has children "d" and "g"
540     // "d" has children "e" and "f"
541     // "c" has children "h" and "i"
542     // Components "b" and "d" implement NamingContainer
543     UIViewRoot a = new UIViewRoot(); a.setId("a");
544     UIForm b = new UIForm(); b.setId("b");
545     UIXPanel c = new UIXPanel(); c.setId("c");
546     TestNamingContainer d = new TestNamingContainer(); d.setId("d");
547     UIXPanel e = new UIXPanel(); e.setId("e");
548     UIXPanel f = new UIXPanel(); f.setId("f");
549     UIXPanel g = new UIXPanel(); g.setId("g");
550     UIXPanel h = new UIXPanel(); h.setId("h");
551     UIXPanel i = new UIXPanel(); i.setId("i");
552     a.getChildren().add(b);
553     a.getChildren().add(c);
554     b.getChildren().add(d);
555     b.getChildren().add(g);
556     c.getChildren().add(h);
557     c.getChildren().add(i);
558     d.getChildren().add(e);
559     d.getChildren().add(f);
560 
561     // Cases that should throw exceptions
562     try
563     {
564       a.findComponent(null);
565       fail("Should have thrown NullPointerException");
566     }
567     catch (NullPointerException ex)
568     {
569       ; // Expected result
570     }
571     
572     try
573     {
574       a.findComponent("a:c:h");
575       fail("Should have thrown IllegalArgumentException");
576     }
577     catch (IllegalArgumentException ex)
578     {
579       ; // Expected result
580     }
581     
582     try
583     {
584       a.findComponent("a:c:i");
585       fail("Should have thrown IllegalArgumentException");
586     } catch (IllegalArgumentException ex)
587     {
588       ; // Expected result
589     }
590     
591     try
592     {
593       a.findComponent(":a:c:h");
594       fail("Should have thrown IllegalArgumentException");
595     }
596     catch (IllegalArgumentException ex)
597     {
598       ; // Expected result
599     }
600     
601     try
602     {
603       a.findComponent(":a:c:i");
604       fail("Should have thrown IllegalArgumentException");
605     }
606     catch (IllegalArgumentException ex)
607     {
608       ; // Expected result
609     }
610     
611     try
612     {
613       a.findComponent("c:h");
614       fail("Should have thrown IllegalArgumentException");
615     }
616     catch (IllegalArgumentException ex)
617     {
618       ; // Expected result
619     }
620     
621     try
622     {
623       a.findComponent("c:i");
624       fail("Should have thrown IllegalArgumentException");
625     }
626     catch (IllegalArgumentException ex)
627     {
628       ; // Expected result
629     }
630     
631     try
632     {
633       a.findComponent(":c:h");
634       fail("Should have thrown IllegalArgumentException");
635     }
636     catch (IllegalArgumentException ex)
637     {
638       ; // Expected result
639     }
640     
641     try
642     {
643       a.findComponent(":c:i");
644       fail("Should have thrown IllegalArgumentException");
645     }
646     catch (IllegalArgumentException ex)
647     {
648       ; // Expected result
649     }
650   }
651 }