Cleaned up urlBase() readability.
Updated unit tests, and added a test for the app context in the URL.

Change-Id: I110b62ff8366a503c3309df0f26a7dd213ae0c5f
diff --git a/web/gui/src/main/webapp/tests/app/fw/remote/rest-spec.js b/web/gui/src/main/webapp/tests/app/fw/remote/rest-spec.js
index cd859ba..406da03 100644
--- a/web/gui/src/main/webapp/tests/app/fw/remote/rest-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/remote/rest-spec.js
@@ -18,21 +18,24 @@
  ONOS GUI -- Remote -- REST Service - Unit Tests
  */
 describe('factory: fw/remote/rest.js', function() {
-    var $log, $httpBackend, fs, rs, promise;
+    var $log, $httpBackend, fs, rs;
 
     beforeEach(module('onosUtil', 'onosRemote'));
 
     beforeEach(module(function($provide) {
-        $provide.factory('$location', function (){
+        $provide.factory('$location', function () {
             return {
                 protocol: function () { return 'http'; },
                 host: function () { return 'foo'; },
                 port: function () { return '80'; },
                 search: function() {
                     return {debug: 'true'};
+                },
+                absUrl: function () {
+                    return 'http://foo:123/onos/ui/rs/path';
                 }
             };
-        })
+        });
     }));
 
     beforeEach(inject(function (_$log_, _$httpBackend_, FnService, RestService) {
diff --git a/web/gui/src/main/webapp/tests/app/fw/remote/urlfn-spec.js b/web/gui/src/main/webapp/tests/app/fw/remote/urlfn-spec.js
index a998e0a..7b9c114 100644
--- a/web/gui/src/main/webapp/tests/app/fw/remote/urlfn-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/remote/urlfn-spec.js
@@ -21,21 +21,25 @@
 describe('factory: fw/remote/urlfn.js', function () {
     var $log, $loc, ufs, fs;
 
-    var protocol, host, port;
+    var protocol, host, port, context;
 
     beforeEach(module('onosRemote'));
 
     beforeEach(module(function($provide) {
-       $provide.factory('$location', function (){
+        $provide.factory('$location', function () {
         return {
             protocol: function () { return protocol; },
             host: function () { return host; },
             port: function () { return port; },
             search: function() {
                 return {debug: 'true'};
+            },
+            absUrl: function () {
+                return protocol + '://' + host + ':' + port +
+                    context + '/onos/ui/';
             }
         };
-       })
+       });
     }));
 
     beforeEach(inject(function (_$log_, $location, UrlFnService, FnService) {
@@ -45,10 +49,11 @@
         fs = FnService;
     }));
 
-    function setLoc(prot, h, p) {
+    function setLoc(prot, h, p, ctx) {
         protocol = prot;
         host = h;
         port = p;
+        context = ctx || '';
     }
 
     it('should define UrlFnService', function () {
@@ -90,4 +95,9 @@
         setLoc('http', 'foo', '123');
         expect(ufs.wsUrl('core', 456, 'bar')).toEqual('ws://bar:456/onos/ui/websock/core');
     });
+
+    it('should allow us to inject an app context', function () {
+        setLoc('http', 'foo', '123', '/my/app');
+        expect(ufs.wsUrl('path')).toEqual('ws://foo:123/my/app/onos/ui/websock/path');
+    });
 });
diff --git a/web/gui/src/main/webapp/tests/app/fw/remote/websocket-spec.js b/web/gui/src/main/webapp/tests/app/fw/remote/websocket-spec.js
index c3599cb..6b0d4a7 100644
--- a/web/gui/src/main/webapp/tests/app/fw/remote/websocket-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/remote/websocket-spec.js
@@ -57,6 +57,9 @@
                 port: function () { return '80'; },
                 search: function() {
                     return {debug: 'true'};
+                },
+                absUrl: function () {
+                    return 'ws://foo:123/onos/ui/websock/path';
                 }
             };
         })