1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.resources.setup; |
35 |
|
|
36 |
|
import static info.magnolia.test.hamcrest.NodeMatchers.hasProperty; |
37 |
|
import static org.hamcrest.core.AllOf.allOf; |
38 |
|
import static org.hamcrest.core.Is.is; |
39 |
|
import static org.junit.Assert.*; |
40 |
|
|
41 |
|
import info.magnolia.context.MgnlContext; |
42 |
|
import info.magnolia.module.ModuleVersionHandler; |
43 |
|
import info.magnolia.module.ModuleVersionHandlerTestCase; |
44 |
|
import info.magnolia.module.model.Version; |
45 |
|
import info.magnolia.repository.RepositoryConstants; |
46 |
|
|
47 |
|
import java.util.Arrays; |
48 |
|
import java.util.List; |
49 |
|
|
50 |
|
import javax.jcr.Node; |
51 |
|
import javax.jcr.Session; |
52 |
|
|
53 |
|
import org.junit.Before; |
54 |
|
import org.junit.Test; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (60) |
Complexity: 14 |
Complexity Density: 0.3 |
|
56 |
|
public class ResourcesModuleVersionHandlerTest extends ModuleVersionHandlerTestCase { |
57 |
|
|
58 |
|
private Session configSession; |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
60 |
9 |
@Before... |
61 |
|
@Override |
62 |
|
public void setUp() throws Exception { |
63 |
9 |
super.setUp(); |
64 |
9 |
this.configSession = MgnlContext.getJCRSession(RepositoryConstants.CONFIG); |
65 |
9 |
setupConfigNode("/server/filters"); |
66 |
9 |
setupConfigNode("/server/filters/servlets"); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
9 |
@Override... |
70 |
|
protected String getModuleDescriptorPath() { |
71 |
9 |
return "/META-INF/magnolia/resources.xml"; |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
9 |
@Override... |
75 |
|
protected List<String> getModuleDescriptorPathsForTests() { |
76 |
9 |
return Arrays.asList("/META-INF/magnolia/core.xml", "/META-INF/magnolia/resource-loader.xml"); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
9 |
@Override... |
80 |
|
protected String[] getExtraWorkspaces() { |
81 |
9 |
return new String[] { "resources" }; |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
9 |
@Override... |
85 |
|
protected ModuleVersionHandler newModuleVersionHandlerForTests() { |
86 |
9 |
return new ResourcesModuleVersionHandler(); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
89 |
1 |
@Test... |
90 |
|
public void testUpgradeTo201BootstrapsCommands() throws Exception { |
91 |
|
|
92 |
1 |
setupConfigNode("/modules/resources"); |
93 |
|
|
94 |
|
|
95 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0.0")); |
96 |
|
|
97 |
|
|
98 |
1 |
assertTrue(configSession.nodeExists("/modules/resources/commands/resources")); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
101 |
1 |
@Test... |
102 |
|
public void testUpgradeTo201RemovesVersionCommand() throws Exception { |
103 |
|
|
104 |
1 |
setupConfigNode("/modules/resources/commands/resources/versionResources/version"); |
105 |
|
|
106 |
|
|
107 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0.0")); |
108 |
|
|
109 |
|
|
110 |
1 |
assertFalse(configSession.nodeExists("/modules/resources/commands/resources/versionResources/version")); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
113 |
1 |
@Test... |
114 |
|
public void testUpgradeFrom201WhenExtractCommentCommandClassIsInResources() throws Exception { |
115 |
|
|
116 |
1 |
setupConfigProperty("/modules/resources/commands/resources/versionResources/extractComment", "class", "info.magnolia.module.resources.commands.ExtractCommentCommand"); |
117 |
|
|
118 |
|
|
119 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0.1")); |
120 |
|
|
121 |
|
|
122 |
1 |
final String commandClass = configSession.getNode("/modules/resources/commands/resources/versionResources/extractComment").getProperty("class").getString(); |
123 |
1 |
assertEquals("info.magnolia.commands.impl.ExtractCommentCommand", commandClass); |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
126 |
1 |
@Test... |
127 |
|
public void testUpgradeFrom201WhenExtractCommentCommandClassIsInAdmininterface() throws Exception { |
128 |
|
|
129 |
1 |
setupConfigProperty("/modules/resources/commands/resources/versionResources/extractComment", "class", "info.magnolia.module.admininterface.commands.ExtractCommentCommand"); |
130 |
|
|
131 |
|
|
132 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0.1")); |
133 |
|
|
134 |
|
|
135 |
1 |
final String commandClass = configSession.getNode("/modules/resources/commands/resources/versionResources/extractComment").getProperty("class").getString(); |
136 |
1 |
assertEquals("info.magnolia.commands.impl.ExtractCommentCommand", commandClass); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
139 |
1 |
@Test... |
140 |
|
public void testUpgradeFrom201WhenCustomExtractCommentCommandClass() throws Exception { |
141 |
|
|
142 |
1 |
final String customCommand = "my.package.name.CustomExtractCommentCommand"; |
143 |
1 |
setupConfigProperty("/modules/resources/commands/resources/versionResources/extractComment", "class", customCommand); |
144 |
|
|
145 |
|
|
146 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.0.1")); |
147 |
|
|
148 |
|
|
149 |
1 |
final String commandClass = configSession.getNode("/modules/resources/commands/resources/versionResources/extractComment").getProperty("class").getString(); |
150 |
1 |
assertEquals(customCommand, commandClass); |
151 |
|
} |
152 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
153 |
1 |
@Test... |
154 |
|
public void testUpgradeFrom15() throws Exception { |
155 |
|
|
156 |
1 |
this.setupConfigNode("/modules/resources/renderers/textResource/contextAttributes/cms/"); |
157 |
|
|
158 |
|
|
159 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("1.5")); |
160 |
|
|
161 |
|
|
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
164 |
1 |
@Test... |
165 |
|
public void upgradeTo24InstallsMappingForNewResourceServlet() throws Exception { |
166 |
|
|
167 |
1 |
this.setupConfigNode("/server/filters/servlets/ClasspathSpoolServlet"); |
168 |
|
|
169 |
|
|
170 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.3")); |
171 |
|
|
172 |
|
|
173 |
1 |
assertFalse(configSession.itemExists("/server/filters/servlets/ClasspathSpoolServlet")); |
174 |
1 |
assertTrue(configSession.itemExists("/server/filters/servlets/ResourcesServlet")); |
175 |
1 |
assertTrue(configSession.itemExists("/server/filters/servlets/ResourcesServlet/mappings/-.resources--")); |
176 |
|
|
177 |
1 |
Node servletNode = configSession.getNode("/server/filters/servlets/ResourcesServlet"); |
178 |
1 |
assertThat(servletNode, allOf( |
179 |
|
hasProperty("class", "info.magnolia.cms.filters.ServletDispatchingFilter"), |
180 |
|
hasProperty("enabled", is(true)), |
181 |
|
hasProperty("servletClass", "info.magnolia.module.resources.ResourcesServlet"), |
182 |
|
hasProperty("servletName", "ResourcesServlet"))); |
183 |
|
|
184 |
1 |
Node mappingNode = configSession.getNode("/server/filters/servlets/ResourcesServlet/mappings/-.resources--"); |
185 |
1 |
assertThat(mappingNode, hasProperty("pattern", "/.resources/*")); |
186 |
|
} |
187 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
188 |
1 |
@Test... |
189 |
|
public void upgradeTo242ChangesJavascriptContentType() throws Exception { |
190 |
|
|
191 |
1 |
this.setupConfigProperty("/modules/resources/templates/js", "contentType", "application/x-javascript"); |
192 |
1 |
this.setupConfigProperty("/modules/resources/templates/processedJs", "contentType", "application/x-javascript"); |
193 |
|
|
194 |
|
|
195 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.4")); |
196 |
|
|
197 |
|
|
198 |
1 |
assertEquals("application/javascript", configSession.getNode("/modules/resources/templates/js").getProperty("contentType").getString()); |
199 |
1 |
assertEquals("application/javascript", configSession.getNode("/modules/resources/templates/processedJs").getProperty("contentType").getString()); |
200 |
|
} |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
202 |
1 |
@Test... |
203 |
|
public void upgradeFrom241RemoveAppLauncherConfigForInPlaceTemplating() throws Exception { |
204 |
|
|
205 |
1 |
setupConfigNode(ResourcesModuleVersionHandler.INPLACE_TEMPLATING_APP_LAUNCHER_CONFIG); |
206 |
|
|
207 |
|
|
208 |
1 |
executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("2.4.1")); |
209 |
|
|
210 |
|
|
211 |
1 |
assertFalse(configSession.itemExists(ResourcesModuleVersionHandler.INPLACE_TEMPLATING_APP_LAUNCHER_CONFIG)); |
212 |
|
} |
213 |
|
|
214 |
|
} |