You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractDeploymentConfigurationTest.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.vaadin.server;
  2. import static org.junit.Assert.assertEquals;
  3. import java.util.Properties;
  4. import java.util.UUID;
  5. import org.junit.Test;
  6. import com.vaadin.shared.communication.PushMode;
  7. /**
  8. * Test for {@link AbstractDeploymentConfiguration}
  9. *
  10. * @author Vaadin Ltd
  11. */
  12. public class AbstractDeploymentConfigurationTest {
  13. @Test
  14. public void getUIClass_returnsUIParameterPropertyValue() {
  15. String ui = UUID.randomUUID().toString();
  16. DeploymentConfiguration config = getConfig(VaadinSession.UI_PARAMETER,
  17. ui);
  18. assertEquals("Unexpected UI class configuration option value", ui,
  19. config.getUIClassName());
  20. }
  21. @Test
  22. public void getUIProviderClass_returnsUIProviderPropertyValue() {
  23. String uiProvider = UUID.randomUUID().toString();
  24. DeploymentConfiguration config = getConfig(
  25. Constants.SERVLET_PARAMETER_UI_PROVIDER, uiProvider);
  26. assertEquals("Unexpected UI providerclass configuration option value",
  27. uiProvider, config.getUIProviderClassName());
  28. }
  29. @Test
  30. public void getWidgetset_returnsWidgetsetProviderPropertyValue() {
  31. String widgetset = UUID.randomUUID().toString();
  32. DeploymentConfiguration config = getConfig(
  33. Constants.PARAMETER_WIDGETSET, widgetset);
  34. assertEquals("Unexpected widgetset configuration option value",
  35. widgetset, config.getWidgetset(null));
  36. }
  37. @Test
  38. public void getWidgetset_noWidgetsetPropertyValue_returnsProvidedDefaultValue() {
  39. DeploymentConfiguration config = getConfig(null, null);
  40. String widgetset = UUID.randomUUID().toString();
  41. assertEquals("Unexpected widgetset configuration option value",
  42. widgetset, config.getWidgetset(widgetset));
  43. }
  44. @Test
  45. public void getResourcesPath_returnsResourcesPathPropertyValue() {
  46. String resources = UUID.randomUUID().toString();
  47. DeploymentConfiguration config = getConfig(
  48. Constants.PARAMETER_VAADIN_RESOURCES, resources);
  49. assertEquals("Unexpected resources path configuration option value",
  50. resources, config.getResourcesPath());
  51. }
  52. @Test
  53. public void getClassLoader_returnsClassloaderPropertyValue() {
  54. String classLoader = UUID.randomUUID().toString();
  55. DeploymentConfiguration config = getConfig("ClassLoader", classLoader);
  56. assertEquals("Unexpected classLoader configuration option value",
  57. classLoader, config.getClassLoaderName());
  58. }
  59. private DeploymentConfiguration getConfig(String property, String value) {
  60. Properties props = new Properties();
  61. if (property != null) {
  62. props.put(property, value);
  63. }
  64. return new DeploymentConfigImpl(props);
  65. }
  66. private static class DeploymentConfigImpl
  67. extends AbstractDeploymentConfiguration {
  68. private final Properties properties;
  69. DeploymentConfigImpl(Properties props) {
  70. properties = props;
  71. }
  72. @Override
  73. public boolean isProductionMode() {
  74. return false;
  75. }
  76. @Override
  77. public boolean isXsrfProtectionEnabled() {
  78. return false;
  79. }
  80. @Override
  81. public boolean isSyncIdCheckEnabled() {
  82. return false;
  83. }
  84. @Override
  85. public int getResourceCacheTime() {
  86. return 0;
  87. }
  88. @Override
  89. public int getHeartbeatInterval() {
  90. return 0;
  91. }
  92. @Override
  93. public boolean isCloseIdleSessions() {
  94. return false;
  95. }
  96. @Override
  97. public PushMode getPushMode() {
  98. return null;
  99. }
  100. @Override
  101. public Properties getInitParameters() {
  102. return null;
  103. }
  104. @Override
  105. public String getApplicationOrSystemProperty(String propertyName,
  106. String defaultValue) {
  107. return properties.getProperty(propertyName, defaultValue);
  108. }
  109. @Override
  110. public boolean isSendUrlsAsParameters() {
  111. return DefaultDeploymentConfiguration.DEFAULT_SEND_URLS_AS_PARAMETERS;
  112. }
  113. }
  114. }