changeset 947:228ad727f418

Change default URL for gui back to mongodb://. Reviewed-by: omajid, vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-January/005474.html
author Severin Gehwolf <sgehwolf@redhat.com>
date Thu, 31 Jan 2013 18:33:42 +0100
parents b5693fd9f6b8
children 3a1d50cfcbb7
files common/core/src/main/java/com/redhat/thermostat/common/config/ClientPreferences.java common/core/src/test/java/com/redhat/thermostat/common/config/ClientPreferencesTest.java
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/config/ClientPreferences.java	Thu Jan 31 14:37:55 2013 -0500
+++ b/common/core/src/main/java/com/redhat/thermostat/common/config/ClientPreferences.java	Thu Jan 31 18:33:42 2013 +0100
@@ -48,6 +48,7 @@
     static final String PASSWORD = "password";
     static final String CONNECTION_URL = "connection-url";
     static final String SAVE_ENTITLEMENTS = "save-entitlements";
+    static final String DEFAULT_CONNECTION_URL = "mongodb://127.0.0.1:27518";
     
     private final Preferences prefs;
     
@@ -82,7 +83,7 @@
     }
     
     public String getConnectionUrl() {
-        return prefs.get(CONNECTION_URL, "http://127.0.0.1:8082");
+        return prefs.get(CONNECTION_URL, DEFAULT_CONNECTION_URL);
     }
 
     public String getPassword() {
--- a/common/core/src/test/java/com/redhat/thermostat/common/config/ClientPreferencesTest.java	Thu Jan 31 14:37:55 2013 -0500
+++ b/common/core/src/test/java/com/redhat/thermostat/common/config/ClientPreferencesTest.java	Thu Jan 31 18:33:42 2013 +0100
@@ -37,16 +37,14 @@
 package com.redhat.thermostat.common.config;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.anyInt;
 import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.times;
 
 import java.util.prefs.Preferences;
 
@@ -160,5 +158,16 @@
         clientPrefs.setSaveEntitlements(true);
         verify(prefs).putBoolean(eq(ClientPreferences.SAVE_ENTITLEMENTS), eq(true));
     }
+    
+    @Test
+    public void testDefaultPreferencesIsMongodb() {
+        // Default preferences for GUI is mongodb:// since this is accomodates
+        // more use cases
+        Keyring keyring = mock(Keyring.class);
+        Preferences prefs = mock(Preferences.class);
+        when(prefs.get(eq("connection-url"), any(String.class))).thenReturn(ClientPreferences.DEFAULT_CONNECTION_URL);
+        ClientPreferences clientPrefs = new ClientPreferences(prefs, keyring);
+        assertEquals("mongodb://127.0.0.1:27518", clientPrefs.getConnectionUrl());
+    }
 }