1. Project Clover database Fri Apr 29 2016 13:24:33 CEST
  2. Package info.magnolia.module.blossom.suite

File MassiveTest.java

 

Code metrics

0
18
8
4
138
76
8
0.44
2.25
2
1

Classes

Class Line # Actions
MassiveTest 63 15 0% 3 0
1.0100%
MassiveTest.TestTemplate 102 2 0% 3 4
0.220%
MassiveTest.TestComponent 123 1 0% 2 2
0.3333333433.3%
MassiveTest.TestDialogFactory 136 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /**
2    * This file Copyright (c) 2010-2016 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.module.blossom.suite;
35   
36    import static org.junit.Assert.*;
37   
38    import info.magnolia.content2bean.Content2BeanException;
39    import info.magnolia.module.blossom.annotation.Available;
40    import info.magnolia.module.blossom.annotation.DialogFactory;
41    import info.magnolia.module.blossom.annotation.TabFactory;
42    import info.magnolia.module.blossom.annotation.Template;
43    import info.magnolia.module.blossom.annotation.TemplateDescription;
44    import info.magnolia.objectfactory.Components;
45    import info.magnolia.registry.RegistrationException;
46    import info.magnolia.rendering.template.TemplateDefinition;
47    import info.magnolia.rendering.template.registry.TemplateDefinitionRegistry;
48    import info.magnolia.ui.dialog.config.DialogBuilder;
49    import info.magnolia.ui.form.config.TabBuilder;
50   
51    import javax.jcr.Node;
52    import javax.jcr.RepositoryException;
53   
54    import org.junit.Test;
55    import org.springframework.stereotype.Controller;
56    import org.springframework.web.bind.annotation.RequestMapping;
57   
58    /**
59    * Test case that starts up the module and tests a wide range of functionality.
60    *
61    * @since 1.2
62    */
 
63    public class MassiveTest extends AbstractBlossomTestCase {
64   
 
65  1 toggle @Override
66    protected String getRootWebApplicationConfigLocation() {
67  1 return "classpath:info/magnolia/module/blossom/suite/MassiveTest-test.xml";
68    }
69   
 
70  1 toggle @Override
71    protected String getDispatcherServletConfigLocation() {
72  1 return "classpath:info/magnolia/module/blossom/suite/MassiveTest-DispatcherServlet-test.xml";
73    }
74   
 
75  1 toggle @Test
76    public void testMassively() throws RepositoryException, Content2BeanException, RegistrationException {
77   
78  1 TemplateDefinition testTemplate = Components.getComponent(TemplateDefinitionRegistry.class).getTemplateDefinition("testTemplate");
79  1 assertNotNull(testTemplate);
80  1 assertEquals("Test Template", testTemplate.getTitle());
81  1 assertEquals("Test Template Description", testTemplate.getDescription());
82  1 assertTrue(testTemplate.getTemplateAvailability().getClass().getName().startsWith("info.magnolia.module.blossom"));
83   
84    // TestTemplate doesn't get a dialog since it has no methods annotated to drive a dialog
85  1 assertDialogIsNotRegistered("blossom-template-dialog:" + TestTemplate.class.getName());
86   
87  1 assertDialogIsRegistered("test-template-dialog");
88   
89  1 TemplateDefinition testComponent = Components.getComponent(TemplateDefinitionRegistry.class).getTemplateDefinition("testComponent");
90  1 assertNotNull(testComponent);
91  1 assertEquals("Test Component", testComponent.getTitle());
92  1 assertEquals("Test Component Description", testComponent.getDescription());
93   
94  1 assertDialogIsRegistered("blossom-template-dialog:" + TestComponent.class.getName());
95   
96  1 assertDialogIsRegistered("test-dialog");
97    }
98   
99    @Template(title = "Test Template", id = "testTemplate")
100    @TemplateDescription("Test Template Description")
101    @Controller
 
102    public static class TestTemplate {
103   
 
104  0 toggle @RequestMapping("/testTemplate")
105    public String testTemplate() {
106  0 return "testTemplate.jsp";
107    }
108   
 
109  0 toggle @Available
110    public boolean isAvailable(Node node) {
111  0 return true;
112    }
113   
 
114  2 toggle @DialogFactory("test-template-dialog")
115    public void templateDialog(DialogBuilder dialog) {
116   
117    }
118    }
119   
120    @Template(title = "Test Component", id = "testComponent")
121    @TemplateDescription("Test Component Description")
122    @Controller
 
123    public static class TestComponent {
124   
 
125  0 toggle @RequestMapping("/testComponent")
126    public String testComponent() {
127  0 return "testComponent.jsp";
128    }
129   
 
130  2 toggle @TabFactory("Content")
131    public void contentTab(TabBuilder tab) {
132    }
133    }
134   
135    @DialogFactory("test-dialog")
 
136    public static class TestDialogFactory {
137    }
138    }