1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.display.internal

File ConfiguredDocumentDisplayer.java

 
testDisplayMacroWhenSectionSpecified: Failed to lookup default document displayer.
testIncludeMacroWhenSectionSpecified: Failed to lookup default document displayer.
verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection: Failed to lookup default document displayer.
webRssDisplay: Failed to lookup default document displayer.
testIncludeMacroWithNewContextShowsPassingOnRestrictedFlag: Failed to lookup default document displayer.
webRssFiltersHiddenDocuments: Failed to lookup default document displayer.
testDisplayMacroWhenDisplayingDocumentWithRelativeReferences: Failed to lookup default document displayer.
testIncludeMacroWhenIncludingDocumentWithRelativeReferences: Failed to lookup default document displayer.
 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

0
8
2
1
100
43
4
0.5
4
2
2

Classes

Class Line # Actions
ConfiguredDocumentDisplayer 45 8 0% 4 4
0.660%
 

Contributing tests

This file is covered by 37 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.display.internal;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.apache.commons.lang.exception.ExceptionUtils;
27    import org.slf4j.Logger;
28    import org.xwiki.bridge.DocumentModelBridge;
29    import org.xwiki.component.annotation.Component;
30    import org.xwiki.component.manager.ComponentLookupException;
31    import org.xwiki.component.manager.ComponentManager;
32    import org.xwiki.rendering.block.XDOM;
33   
34    /**
35    * This is just a wrapper for the document displayer specified in the configuration. If there is no
36    * {@link DocumentDisplayer} component registered with the {@link DisplayConfiguration#getDocumentDisplayerHint()} hint
37    * then the default document displayer is used instead.
38    *
39    * @version $Id: 4c986125e78f8eb63c6d6229b6d807446b98a934 $
40    * @since 3.2M3
41    */
42    Test failure here @Component
43    @Named("configured")
44    @Singleton
 
45    public class ConfiguredDocumentDisplayer implements DocumentDisplayer
46    {
47    /**
48    * The object used for logging.
49    */
50    @Inject
51    private Logger logger;
52   
53    /**
54    * The display configuration.
55    */
56    @Inject
57    private DisplayConfiguration displayConfiguration;
58   
59    /**
60    * The component manager.
61    */
62    @Inject
63    private ComponentManager componentManager;
64   
 
65  27032 toggle @Override
66    public XDOM display(DocumentModelBridge data, DocumentDisplayerParameters parameters)
67    {
68  27032 Test failure here return getDocumentDisplayer().display(data, parameters);
69    }
70   
71    /**
72    * Tries to lookup the document displayer with the configured hint, falling back on the default document displayer.
73    * <p>
74    * Note: There are two reasons why we don't do this in the component initialization phase:
75    * <ul>
76    * <li>it would trigger an infinite recursion if XWikiDocument class initializes the document displayer in the
77    * constructor (or field initialization) because accessing the configuration triggers the load of the
78    * XWiki.XWikiPreferences document which would trigger displayer initialization which would trigger the load of the
79    * XWiki.XWikiPreferences document and so on..</li>
80    * <li>we want to support the live change of the configured document displayer</li>
81    * </ul>
82    *
83    * @return the configured document displayer
84    */
 
85  27026 toggle private DocumentDisplayer getDocumentDisplayer()
86    {
87  27031 String documentDisplayerHint = displayConfiguration.getDocumentDisplayerHint();
88  27032 try {
89  27032 return componentManager.getInstance(DocumentDisplayer.class, documentDisplayerHint);
90    } catch (ComponentLookupException e) {
91  0 logger.warn("Failed to lookup document displayer with hint [{}] (Root cause: [{}]). "
92    + "Using default document displayer.", documentDisplayerHint, ExceptionUtils.getRootCauseMessage(e));
93  0 try {
94  0 Test failure here return componentManager.getInstance(DocumentDisplayer.class);
95    } catch (ComponentLookupException ex) {
96  0 Test failure here throw new RuntimeException("Failed to lookup default document displayer.", ex);
97    }
98    }
99    }
100    }