1   package org.apache.maven.doxia.site.decoration.inheritance;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.IOException;
23  import java.io.Reader;
24  
25  import junit.framework.TestCase;
26  
27  import org.apache.maven.doxia.site.decoration.Banner;
28  import org.apache.maven.doxia.site.decoration.Body;
29  import org.apache.maven.doxia.site.decoration.DecorationModel;
30  import org.apache.maven.doxia.site.decoration.LinkItem;
31  import org.apache.maven.doxia.site.decoration.Logo;
32  import org.apache.maven.doxia.site.decoration.Menu;
33  import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
34  import org.codehaus.plexus.util.IOUtil;
35  import org.codehaus.plexus.util.ReaderFactory;
36  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
37  
38  /**
39   * Test the inheritance assembler.
40   *
41   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
42   * @version $Id: DecorationModelInheritenceAssemblerTest.java 736629 2009-01-22 12:58:34Z vsiveton $
43   */
44  public class DecorationModelInheritenceAssemblerTest
45      extends TestCase
46  {
47      private DecorationModelInheritanceAssembler assembler = new DefaultDecorationModelInheritanceAssembler();
48  
49      private static final String NAME = "Name";
50  
51      public void testInheritence()
52          throws IOException, XmlPullParserException
53      {
54          DecorationModel childModel = readModel( "child.xml" );
55          DecorationModel parentModel = readModel( "parent.xml" );
56  
57          assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
58                                              "http://maven.apache.org" );
59          DecorationModel mergedModel = readModel( "merged.xml" );
60  
61          assertEquals( "Check result", mergedModel, childModel );
62      }
63  
64      public void testPathsResolvedWhenEmpty()
65          throws IOException, XmlPullParserException
66      {
67          // Test an empty model avoids NPEs
68          DecorationModel childModel = readModel( "empty.xml" );
69          DecorationModel parentModel = readModel( "empty.xml" );
70  
71          assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
72                                              "http://maven.apache.org" );
73          DecorationModel mergedModel = readModel( "empty.xml" );
74  
75          assertEquals( "Check result", mergedModel, childModel );
76      }
77  
78      public void testPathsNotResolvedForExternalUrls()
79          throws IOException, XmlPullParserException
80      {
81          DecorationModel parentModel = readModel( "external-urls.xml" );
82          DecorationModel childModel = readModel( "empty.xml" );
83  
84          assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
85                                              "http://maven.apache.org" );
86  
87          assertEquals( "check left banner href", "http://jakarta.apache.org/", childModel.getBannerLeft().getHref() );
88          assertEquals( "check left banner image", "http://jakarta.apache.org/images/jakarta-logo.gif",
89                        childModel.getBannerLeft().getSrc() );
90  
91          assertEquals( "check right banner href", "http://jakarta.apache.org/commons/sandbox",
92                        childModel.getBannerRight().getHref() );
93          assertEquals( "check right banner image", "http://jakarta.apache.org/commons/images/logo.png",
94                        childModel.getBannerRight().getSrc() );
95  
96          Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
97          assertEquals( "check powered by logo href", "http://tomcat.apache.org/", poweredBy.getHref() );
98          assertEquals( "check powered by logo image", "http://tomcat.apache.org/logo.gif", poweredBy.getImg() );
99  
100         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
101         assertEquals( "check breadcrumb href", "http://www.apache.org/", breadcrumb.getHref() );
102 
103         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
104         assertEquals( "check link href", "http://www.bouncycastle.org", link.getHref() );
105 
106         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
107         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
108         assertEquals( "check menu item href", "http://www.apache.org/special/", menuItem.getHref() );
109     }
110 
111     public void testPathsResolvedForRelativeUrls()
112         throws IOException, XmlPullParserException
113     {
114         DecorationModel parentModel = readModel( "relative-urls.xml" );
115         DecorationModel childModel = readModel( "empty.xml" );
116 
117         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/",
118                                             "http://maven.apache.org" );
119 
120         assertEquals( "check left banner href", "../banner/left", childModel.getBannerLeft().getHref() );
121         assertEquals( "check left banner image", "../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc() );
122 
123         assertEquals( "check right banner href", "../banner/right/", childModel.getBannerRight().getHref() );
124         assertEquals( "check right banner image", "../commons/images/logo.png", childModel.getBannerRight().getSrc() );
125 
126         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
127         assertEquals( "check powered by logo href", "../tomcat", poweredBy.getHref() );
128         assertEquals( "check powered by logo image", "../tomcat/logo.gif", poweredBy.getImg() );
129 
130         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
131         assertEquals( "check breadcrumb href", "../apache", breadcrumb.getHref() );
132 
133         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
134         assertEquals( "check link href", "../bouncycastle/", link.getHref() );
135 
136         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
137         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
138         assertEquals( "check menu item href", "../special/", menuItem.getHref() );
139     }
140 
141     public void testPathsResolvedForSubsiteUrls()
142         throws IOException, XmlPullParserException
143     {
144         DecorationModel parentModel = readModel( "subsite-urls.xml" );
145         DecorationModel childModel = readModel( "empty.xml" );
146 
147         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/",
148                                             "http://maven.apache.org" );
149 
150         assertEquals( "check left banner href", "../banner/left", childModel.getBannerLeft().getHref() );
151         assertEquals( "check left banner image", "../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc() );
152 
153         assertEquals( "check right banner href", "../banner/right/", childModel.getBannerRight().getHref() );
154         assertEquals( "check right banner image", "../commons/images/logo.png", childModel.getBannerRight().getSrc() );
155 
156         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
157         assertEquals( "check powered by logo href", "../tomcat", poweredBy.getHref() );
158         assertEquals( "check powered by logo image", "../tomcat/logo.gif", poweredBy.getImg() );
159 
160         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
161         assertEquals( "check breadcrumb href", "../apache", breadcrumb.getHref() );
162 
163         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
164         assertEquals( "check link href", "../bouncycastle/", link.getHref() );
165 
166         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
167         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
168         assertEquals( "check menu item href", "../special/", menuItem.getHref() );
169     }
170 
171     public void testPathsResolvedForRelativeUrlsDepthOfTwo()
172         throws IOException, XmlPullParserException
173     {
174         DecorationModel parentModel = readModel( "relative-urls.xml" );
175         DecorationModel childModel = readModel( "empty.xml" );
176 
177         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/core",
178                                             "http://maven.apache.org" );
179 
180         assertEquals( "check left banner href", "../../banner/left", childModel.getBannerLeft().getHref() );
181         assertEquals( "check left banner image", "../../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc() );
182 
183         assertEquals( "check right banner href", "../../banner/right/", childModel.getBannerRight().getHref() );
184         assertEquals( "check right banner image", "../../commons/images/logo.png",
185                       childModel.getBannerRight().getSrc() );
186 
187         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
188         assertEquals( "check powered by logo href", "../../tomcat", poweredBy.getHref() );
189         assertEquals( "check powered by logo image", "../../tomcat/logo.gif", poweredBy.getImg() );
190 
191         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
192         assertEquals( "check breadcrumb href", "../../apache", breadcrumb.getHref() );
193 
194         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
195         assertEquals( "check link href", "../../bouncycastle/", link.getHref() );
196 
197         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
198         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
199         assertEquals( "check menu item href", "../../special/", menuItem.getHref() );
200     }
201 
202     public void testPathsResolvedForReverseRelativeUrls()
203         throws IOException, XmlPullParserException
204     {
205         DecorationModel parentModel = readModel( "relative-urls.xml" );
206         DecorationModel childModel = readModel( "empty.xml" );
207 
208         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/",
209                                             "http://maven.apache.org/doxia/" );
210 
211         assertEquals( "check left banner href", "doxia/banner/left", childModel.getBannerLeft().getHref() );
212         assertEquals( "check left banner image", "doxia/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc() );
213 
214         assertEquals( "check right banner href", "doxia/banner/right/", childModel.getBannerRight().getHref() );
215         assertEquals( "check right banner image", "doxia/commons/images/logo.png",
216                       childModel.getBannerRight().getSrc() );
217 
218         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
219         assertEquals( "check powered by logo href", "doxia/tomcat", poweredBy.getHref() );
220         assertEquals( "check powered by logo image", "doxia/tomcat/logo.gif", poweredBy.getImg() );
221 
222         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
223         assertEquals( "check breadcrumb href", "doxia/apache", breadcrumb.getHref() );
224 
225         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
226         assertEquals( "check link href", "doxia/bouncycastle/", link.getHref() );
227 
228         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
229         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
230         assertEquals( "check menu item href", "doxia/special/", menuItem.getHref() );
231     }
232 
233     public void testPathsResolvedForReverseRelativeUrlsDepthOfTwo()
234         throws IOException, XmlPullParserException
235     {
236         DecorationModel parentModel = readModel( "relative-urls.xml" );
237         DecorationModel childModel = readModel( "empty.xml" );
238 
239         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/",
240                                             "http://maven.apache.org/doxia/core/" );
241 
242         assertEquals( "check left banner href", "doxia/core/banner/left", childModel.getBannerLeft().getHref() );
243         assertEquals( "check left banner image", "doxia/core/images/jakarta-logo.gif",
244                       childModel.getBannerLeft().getSrc() );
245 
246         assertEquals( "check right banner href", "doxia/core/banner/right/", childModel.getBannerRight().getHref() );
247         assertEquals( "check right banner image", "doxia/core/commons/images/logo.png",
248                       childModel.getBannerRight().getSrc() );
249 
250         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
251         assertEquals( "check powered by logo href", "doxia/core/tomcat", poweredBy.getHref() );
252         assertEquals( "check powered by logo image", "doxia/core/tomcat/logo.gif", poweredBy.getImg() );
253 
254         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
255         assertEquals( "check breadcrumb href", "doxia/core/apache", breadcrumb.getHref() );
256 
257         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
258         assertEquals( "check link href", "doxia/core/bouncycastle/", link.getHref() );
259 
260         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
261         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
262         assertEquals( "check menu item href", "doxia/core/special/", menuItem.getHref() );
263     }
264 
265     public void testPathsResolvedForUnrelatedRelativeUrls()
266         throws IOException, XmlPullParserException
267     {
268         DecorationModel parentModel = readModel( "relative-urls.xml" );
269         DecorationModel childModel = readModel( "empty.xml" );
270 
271         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org",
272                                             "http://jakarta.apache.org" );
273 
274         assertEquals( "check left banner href", "http://jakarta.apache.org/banner/left",
275                       childModel.getBannerLeft().getHref() );
276         assertEquals( "check left banner image", "http://jakarta.apache.org/images/jakarta-logo.gif",
277                       childModel.getBannerLeft().getSrc() );
278 
279         assertEquals( "check right banner href", "http://jakarta.apache.org/banner/right/",
280                       childModel.getBannerRight().getHref() );
281         assertEquals( "check right banner image", "http://jakarta.apache.org/commons/images/logo.png",
282                       childModel.getBannerRight().getSrc() );
283 
284         Logo poweredBy = (Logo) childModel.getPoweredBy().get( 0 );
285         assertEquals( "check powered by logo href", "http://jakarta.apache.org/tomcat", poweredBy.getHref() );
286         assertEquals( "check powered by logo image", "http://jakarta.apache.org/tomcat/logo.gif", poweredBy.getImg() );
287 
288         LinkItem breadcrumb = (LinkItem) childModel.getBody().getBreadcrumbs().get( 0 );
289         assertEquals( "check breadcrumb href", "http://jakarta.apache.org/apache", breadcrumb.getHref() );
290 
291         LinkItem link = (LinkItem) childModel.getBody().getLinks().get( 0 );
292         assertEquals( "check link href", "http://jakarta.apache.org/bouncycastle/", link.getHref() );
293 
294         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
295         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
296         assertEquals( "check menu item href", "http://jakarta.apache.org/special/", menuItem.getHref() );
297     }
298 
299     public void testNullParent()
300         throws IOException, XmlPullParserException
301     {
302         DecorationModel childModel = readModel( "empty.xml" );
303 
304         assembler.assembleModelInheritance( NAME, childModel, null, "http://maven.apache.org/doxia",
305                                             "http://maven.apache.org" );
306         DecorationModel mergedModel = readModel( "empty.xml" );
307 
308         assertEquals( "Check result", mergedModel, childModel );
309     }
310 
311     public void testFullyPopulatedChild()
312         throws IOException, XmlPullParserException
313     {
314         DecorationModel childModel = readModel( "fully-populated-child.xml" );
315         DecorationModel parentModel = readModel( "fully-populated-child.xml" );
316 
317         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://foo.apache.org/doxia",
318                                             "http://foo.apache.org" );
319         DecorationModel mergedModel = readModel( "fully-populated-child.xml" );
320 
321         assertEquals( "Check result", mergedModel, childModel );
322     }
323 
324     public void testFullyPopulatedParentAndEmptyChild()
325         throws IOException, XmlPullParserException
326     {
327         DecorationModel childModel = readModel( "empty.xml" );
328         DecorationModel parentModel = readModel( "fully-populated-child.xml" );
329 
330         assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
331                                             "http://maven.apache.org" );
332         DecorationModel mergedModel = readModel( "fully-populated-merged.xml" );
333 
334         assertEquals( "Check result", mergedModel, childModel );
335     }
336 
337     public void testResolvingAllExternalUrls()
338         throws IOException, XmlPullParserException
339     {
340         DecorationModel model = readModel( "external-urls.xml" );
341 
342         assembler.resolvePaths( model, "http://foo.com/" );
343         DecorationModel mergedModel = readModel( "external-urls.xml" );
344 
345         assertEquals( "Check result", mergedModel, model );
346     }
347 
348     public void testResolvingAllRelativeUrls()
349         throws IOException, XmlPullParserException
350     {
351         DecorationModel model = readModel( "relative-urls.xml" );
352 
353         assembler.resolvePaths( model, "http://foo.com/" );
354 
355         DecorationModel resolvedModel = readModel( "relative-urls-resolved.xml" );
356 
357         assertEquals( "Check result", resolvedModel, model );
358     }
359 
360     public void testResolvingAllSiteUrls()
361         throws IOException, XmlPullParserException
362     {
363         DecorationModel model = readModel( "subsite-urls.xml" );
364 
365         assembler.resolvePaths( model, "http://maven.apache.org/" );
366 
367         DecorationModel resolvedModel = readModel( "relative-urls-resolved.xml" );
368         assertEquals( "Check result", resolvedModel, model );
369     }
370 
371 /* [MSITE-62] This is to test the ../ relative paths, which I am inclined not to use
372     public void testResolvingAllSiteChildUrls()
373         throws IOException, XmlPullParserException
374     {
375         DecorationModel model = readModel( "subsite-urls.xml" );
376 
377         assembler.resolvePaths( model, "http://maven.apache.org/foo" );
378 
379         DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
380         assertEquals( "Check result", resolvedModel, model );
381     }
382 
383     public void testResolvingAllSiteChildUrlsMultipleLevels()
384         throws IOException, XmlPullParserException
385     {
386         DecorationModel model = readModel( "subsite-urls.xml" );
387 
388         assembler.resolvePaths( model, "http://maven.apache.org/banner/right" );
389 
390         DecorationModel resolvedModel = readModel( "subsite-relative-urls-multiple-resolved.xml" );
391         assertEquals( "Check result", resolvedModel, model );
392     }
393 
394     public void testResolvingAllSiteChildFilesystemUrls()
395         throws IOException, XmlPullParserException
396     {
397         DecorationModel model = readModel( "subsite-urls-file.xml" );
398 
399         assembler.resolvePaths( model, "file://localhost/www/maven.apache.org/foo" );
400 
401         DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
402         assertEquals( "Check result", resolvedModel, model );
403     }
404 
405 */
406 
407     public void testResolvingEmptyDescriptor()
408         throws IOException, XmlPullParserException
409     {
410         DecorationModel model = readModel( "empty.xml" );
411         assembler.resolvePaths( model, "http://maven.apache.org" );
412         DecorationModel mergedModel = readModel( "empty.xml" );
413 
414         assertEquals( "Check result", mergedModel, model );
415     }
416 
417     public void testDuplicateParentElements()
418     {
419         DecorationModel model = new DecorationModel();
420         model.setBody( new Body() );
421         model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
422         model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
423 
424         model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
425         model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
426 
427         DecorationModel child = new DecorationModel();
428         assembler.assembleModelInheritance( NAME, child, model, "http://maven.apache.org/doxia",
429                                             "http://maven.apache.org" );
430 
431         assertEquals( "Check size", 1, child.getBody().getLinks().size() );
432         assertEquals( "Check item", createLinkItem( "Foo", "http://foo.apache.org" ),
433                       child.getBody().getLinks().get( 0 ) );
434 
435         assertEquals( "Check size", 1, child.getPoweredBy().size() );
436         assertEquals( "Check item", createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ),
437                       child.getPoweredBy().get( 0 ) );
438     }
439 
440     public void testDuplicateChildElements()
441     {
442         DecorationModel model = new DecorationModel();
443         model.setBody( new Body() );
444         model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
445         model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
446 
447         model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
448         model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
449 
450         DecorationModel parent = new DecorationModel();
451         assembler.assembleModelInheritance( NAME, model, parent, "http://maven.apache.org/doxia",
452                                             "http://maven.apache.org" );
453 
454         assertEquals( "Check size", 1, model.getBody().getLinks().size() );
455         assertEquals( "Check item", createLinkItem( "Foo", "http://foo.apache.org" ),
456                       model.getBody().getLinks().get( 0 ) );
457 
458         assertEquals( "Check size", 1, model.getPoweredBy().size() );
459         assertEquals( "Check item", createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ),
460                       model.getPoweredBy().get( 0 ) );
461     }
462 
463     public void testBreadcrumbWithoutHref()
464     {
465         DecorationModel model = new DecorationModel();
466         model.setBody( new Body() );
467         model.getBody().addBreadcrumb( createLinkItem( "Foo", null ) );
468         assembler.resolvePaths( model, "http://foo.apache.org" );
469         assertEquals( "Check size", 1, model.getBody().getBreadcrumbs().size() );
470         assertEquals( "Check item", createLinkItem( "Foo", "" ), model.getBody().getBreadcrumbs().get( 0 ) );
471     }
472 
473     public void testBannerWithoutHref()
474     {
475         DecorationModel model = new DecorationModel();
476         model.setBody( new Body() );
477 
478         Banner banner = createBanner( "Left", null, "/images/src.gif", "alt" );
479 
480         model.setBannerLeft( banner );
481 
482         assembler.resolvePaths( model, "http://foo.apache.org" );
483 
484         assertEquals( "Check banner", createBanner( "Left", null, "images/src.gif", "alt" ), model.getBannerLeft() );
485     }
486 
487     public void testLogoWithoutImage()
488     {
489         // This should actually be validated in the model, it doesn't really make sense
490         DecorationModel model = new DecorationModel();
491         model.setBody( new Body() );
492         model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", null ) );
493         assembler.resolvePaths( model, "http://foo.apache.org" );
494         assertEquals( "Check size", 1, model.getPoweredBy().size() );
495         assertEquals( "Check item", createLogo( "Foo", "http://foo.apache.org", null ), model.getPoweredBy().get( 0 ) );
496     }
497 
498     private static Banner createBanner( String name, String href, String src, String alt )
499     {
500         Banner banner = new Banner();
501         banner.setName( name );
502         banner.setHref( href );
503         banner.setSrc( src );
504         banner.setAlt( alt );
505         return banner;
506     }
507 
508     private Logo createLogo( String name, String href, String img )
509     {
510         Logo logo = new Logo();
511         logo.setHref( href );
512         logo.setImg( img );
513         logo.setName( name );
514         return logo;
515     }
516 
517     private static LinkItem createLinkItem( String name, String href )
518     {
519         LinkItem item = new LinkItem();
520         item.setName( name );
521         item.setHref( href );
522         return item;
523     }
524 
525     private DecorationModel readModel( String name )
526         throws IOException, XmlPullParserException
527     {
528         Reader reader = null;
529         try
530         {
531             reader = ReaderFactory.newXmlReader( getClass().getResourceAsStream( "/" + name ) );
532             return new DecorationXpp3Reader().read( reader );
533         }
534         finally
535         {
536             IOUtil.close( reader );
537         }
538     }
539 }