1 package com.atlassian.plugin.webresource;
2
3 import com.atlassian.plugin.util.PluginUtils;
4 import junit.framework.TestCase;
5
6 public class TestDefaultResourceBatchingConfiguration extends TestCase
7 {
8 private DefaultResourceBatchingConfiguration batchingConfiguration;
9
10 @Override
11 public void setUp() throws Exception
12 {
13 super.setUp();
14
15 batchingConfiguration = new DefaultResourceBatchingConfiguration();
16 }
17
18 @Override
19 public void tearDown() throws Exception
20 {
21 batchingConfiguration = null;
22 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF);
23 System.clearProperty(PluginUtils.ATLASSIAN_DEV_MODE);
24 super.tearDown();
25 }
26
27 public void testBatchingIsEnabledWhenNotInDevModeAndBatchingIsNotOff()
28 {
29 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
30 }
31
32 public void testBatchingIsDisabledWhenInDevMode()
33 {
34 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF);
35 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "true");
36 assertFalse(batchingConfiguration.isPluginWebResourceBatchingEnabled());
37 }
38
39 public void testBatchingIsDisabledWhenBatchingIsOff()
40 {
41 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF, "true");
42 System.clearProperty(PluginUtils.ATLASSIAN_DEV_MODE);
43 assertFalse(batchingConfiguration.isPluginWebResourceBatchingEnabled());
44 }
45
46 public void testBatchingIsEnabledWhenDevModeIsFalse()
47 {
48 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF);
49 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "false");
50 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
51 }
52
53 public void testBatchingIsEnabledWhenInDevModeAndBatchingIsExplicitlyNotOff()
54 {
55 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF, "false");
56 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "true");
57 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
58 }
59 }