Author: mfranklin
Date: Mon Apr 16 19:02:00 2012
New Revision: 1326743
URL: http://svn.apache.org/viewvc?rev=1326743&view=rev
Log:
Added a check to make sure an OpenAjax Hub implementation is found in the
container (RAVE-95)
Modified:
rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js
Modified: rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js?rev=1326743&r1=1326742&r2=1326743&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js Mon Apr 16
19:02:00 2012
@@ -749,22 +749,30 @@ var rave = rave || (function() {
}
}
+ function createNewOpenAjaxHub() {
+ if(typeof OpenAjax == "undefined"){
+ throw "No implementation of OpenAjax found. " +
+ "Please ensure that an implementation has been included in the
page.";
+ }
+ return new OpenAjax.hub.ManagedHub({
+ onSubscribe:function (topic, container) {
+ log(container.getClientID() + " subscribes to this topic '" +
topic + "'");
+ return true;
+ },
+ onUnsubscribe:function (topic, container) {
+ log(container.getClientID() + " unsubscribes from this topic
'" + topic + "'");
+ return true;
+ },
+ onPublish:function (topic, data, pcont, scont) {
+ log(pcont.getClientID() + " publishes '" + data + "' to topic
'" + topic + "' subscribed by " + scont.getClientID());
+ return true;
+ }
+ });
+ }
+
function getOpenAjaxHubInstance() {
if(typeof openAjaxHub == "undefined" || openAjaxHub == null) {
- openAjaxHub = new OpenAjax.hub.ManagedHub({
- onSubscribe: function(topic, container) {
- log(container.getClientID() + " subscribes to this topic
'" + topic + "'");
- return true;
- },
- onUnsubscribe: function(topic, container) {
- log(container.getClientID() + " unsubscribes from this
topic '" + topic + "'");
- return true;
- },
- onPublish: function(topic, data, pcont, scont) {
- log(pcont.getClientID() + " publishes '" + data + "' to
topic '" + topic + "' subscribed by " + scont.getClientID());
- return true;
- }
- });
+ openAjaxHub = createNewOpenAjaxHub();
}
return openAjaxHub;
}
Modified: rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js?rev=1326743&r1=1326742&r2=1326743&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js (original)
+++ rave/trunk/rave-portal-resources/src/test/javascript/raveSpec.js Mon Apr 16
19:02:00 2012
@@ -689,20 +689,28 @@ describe("Rave", function() {
});
describe("getManagedHub", function(){
- OpenAjax = (function(){
- var cArgs;
- return{
- hub: {
- ManagedHub: function(args){
- cArgs=args;
- return {
+ beforeEach(function(){
+ OpenAjax = (function(){
+ var cArgs;
+ return{
+ hub: {
+ ManagedHub: function(args){
+ cArgs=args;
+ return {
- }
- },
- getArgs: function() {return cArgs;}
+ }
+ },
+ getArgs: function() {return cArgs;}
+ }
}
- }
- })();
+ })();
+ });
+
+ it("throws an error if there is no OpenAjax code on the page",
function(){
+ delete OpenAjax;
+ expect(rave.getManagedHub()).toThrow(new Error("No implementation
of OpenAjax found. " +
+ "Please ensure that an implementation has been included in the
page."));
+ });
it("returns a new instance of the managed hub", function(){
var hub = rave.getManagedHub();