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(DefaultResourceBatchingConfiguration.PLUGIN_WEB_RESOURCE_BATCH_CONTENT_TRACKING);
24 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_TRY_CATCH_WRAPPING);
25 System.clearProperty(PluginUtils.ATLASSIAN_DEV_MODE);
26
27 super.tearDown();
28 }
29
30 public void testBatchingIsEnabledWhenNotInDevModeAndBatchingIsNotOff()
31 {
32 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
33 }
34
35 public void testBatchingIsDisabledWhenInDevMode()
36 {
37 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF);
38 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "true");
39 assertFalse(batchingConfiguration.isPluginWebResourceBatchingEnabled());
40 }
41
42 public void testBatchingIsDisabledWhenBatchingIsOff()
43 {
44 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF, "true");
45 System.clearProperty(PluginUtils.ATLASSIAN_DEV_MODE);
46 assertFalse(batchingConfiguration.isPluginWebResourceBatchingEnabled());
47 }
48
49 public void testBatchingIsEnabledWhenDevModeIsFalse()
50 {
51 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF);
52 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "false");
53 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
54 }
55
56 public void testBatchingIsEnabledWhenInDevModeAndBatchingIsExplicitlyNotOff()
57 {
58 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEBRESOURCE_BATCHING_OFF, "false");
59 System.setProperty(PluginUtils.ATLASSIAN_DEV_MODE, "true");
60 assertTrue(batchingConfiguration.isPluginWebResourceBatchingEnabled());
61 }
62
63 public void testBatchContentTrackingEnabled()
64 {
65 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEB_RESOURCE_BATCH_CONTENT_TRACKING, "true");
66 assertTrue(batchingConfiguration.isBatchContentTrackingEnabled());
67 }
68
69 public void testBatchContentTrackingExplicitlyDisabled()
70 {
71 System.setProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEB_RESOURCE_BATCH_CONTENT_TRACKING, "false");
72 assertFalse(batchingConfiguration.isBatchContentTrackingEnabled());
73 }
74
75 public void testBatchContentTrackingIsDisabledByDefult()
76 {
77 System.clearProperty(DefaultResourceBatchingConfiguration.PLUGIN_WEB_RESOURCE_BATCH_CONTENT_TRACKING);
78 assertFalse(batchingConfiguration.isBatchContentTrackingEnabled());
79 }
80 }