http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/assets/tpl/lib/basic-modal.html ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/assets/tpl/lib/basic-modal.html b/brooklyn-ui/src/main/webapp/assets/tpl/lib/basic-modal.html deleted file mode 100644 index c046548..0000000 --- a/brooklyn-ui/src/main/webapp/assets/tpl/lib/basic-modal.html +++ /dev/null @@ -1,29 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<div class="modal-header"> - <button type="button" class="close" data-dismiss="modal">×</button> - <h3><% if (title) { %><%= title %><% } else { %> <% } %></h3> -</div> - -<div class="modal-body"></div> - -<div class="modal-footer"> - <a href="#" class="btn" data-dismiss="modal"><%= cancelButtonText %></a> - <a href="#" class="btn btn-info modal-submit"><%= submitButtonText %></a> -</div>
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/assets/tpl/lib/config-key-type-value-input-pair.html ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/assets/tpl/lib/config-key-type-value-input-pair.html b/brooklyn-ui/src/main/webapp/assets/tpl/lib/config-key-type-value-input-pair.html deleted file mode 100644 index cbf88b1..0000000 --- a/brooklyn-ui/src/main/webapp/assets/tpl/lib/config-key-type-value-input-pair.html +++ /dev/null @@ -1,23 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<div class="config-key-input-pair form-inline"> - <input type="text" class="config-key-type" placeholder="Name" value="<%= type %>"/> - <input type="text" class="config-key-value" placeholder="Value" value="<%= value %>"/> - <button type="button" class="btn config-key-row-remove">-</button> -</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/assets/tpl/script/groovy.html ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/assets/tpl/script/groovy.html b/brooklyn-ui/src/main/webapp/assets/tpl/script/groovy.html deleted file mode 100644 index 06fc9d1..0000000 --- a/brooklyn-ui/src/main/webapp/assets/tpl/script/groovy.html +++ /dev/null @@ -1,93 +0,0 @@ - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<div id="groovy-ui-container" class="single-main-container"> - - <div style="padding-bottom: 12px;"> - <div><h3>Groovy Scripting</h3></div> - </div> - - <div id="message-bar" class="label-important hide style="padding-bottom: 12px;"> - </div> - - - <div class="output"> - <div class="throbber"><img src="/assets/images/throbber.gif"/></div> - - <div class="toggler-region error"> - <div class="toggler-header"> - <div class="toggler-icon icon-chevron-down"></div> - <div><b>Error</b></div> - </div> - <div class="for-textarea"><textarea readonly="readonly" placeholder="no details available" class="code-textarea"></textarea></div> - </div> - - <div class="toggler-region result"> - <div class="toggler-header"> - <div class="toggler-icon icon-chevron-down"></div> - <div><b>Result</b></div> - </div> - <div class="for-textarea"><textarea readonly="readonly" placeholder="no details available" class="code-textarea"></textarea></div> - </div> - - <div class="toggler-region stdout"> - <div class="toggler-header"> - <div class="toggler-icon icon-chevron-down"></div> - <div><b>Output (stdout)</b></div> - </div> - <div class="for-textarea"><textarea readonly="readonly" class="code-textarea"></textarea></div> - </div> - - <div class="toggler-region stderr"> - <div class="toggler-header"> - <div class="toggler-icon icon-chevron-down"></div> - <div><b>Output (stderr)</b></div> - </div> - <div class="for-textarea"><textarea readonly="readonly" class="code-textarea"></textarea></div> - </div> - </div> - - <div class="input"> - <div class="toggler-region"> - <div class="toggler-header"> - <div class="toggler-icon icon-chevron-down"></div> - <div><b>Instructions</b></div> - </div> - - <div class="groovy-scripting-text"> - Enter code to run on the Brooklyn Server. - <p><ul> - <li><code>mgmt</code> is the management context</li> - <li><code>last</code> is the result of your last successful script</li> - <li><code>data</code> is user-session map for storing your data</li> - </ul><p> - <a id="load-example">Click to load an example.</a> - </div> - </div> - - <div class="toggler-region for-textarea"> - <textarea id="script" placeholder="Enter script here" class="code-textarea"></textarea> - </div> - <div class="submit"> - <button id="submit" class="btn btn-info btn-mini">Submit</button> - </div> - </div> - -</div> http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/assets/tpl/script/swagger.html ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/assets/tpl/script/swagger.html b/brooklyn-ui/src/main/webapp/assets/tpl/script/swagger.html deleted file mode 100644 index 89b2bc4..0000000 --- a/brooklyn-ui/src/main/webapp/assets/tpl/script/swagger.html +++ /dev/null @@ -1,30 +0,0 @@ - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<div class="single-main-container"> - -<link rel="stylesheet" href="/assets/css/swagger.css"> - -<div class="apidoc-title"> REST API Reference </div> -<div class="throbber"><img src="/assets/images/throbber.gif"/></div> -<div id="message-bar" class="swagger-ui-wrap"> </div> - -<div id="swagger-ui-container" class="swagger-ui-wrap"></div> - -</div> http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/favicon.ico ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/favicon.ico b/brooklyn-ui/src/main/webapp/favicon.ico deleted file mode 100644 index bdf37d2..0000000 Binary files a/brooklyn-ui/src/main/webapp/favicon.ico and /dev/null differ http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/main/webapp/index.html ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/main/webapp/index.html b/brooklyn-ui/src/main/webapp/index.html deleted file mode 100644 index a7c8121..0000000 --- a/brooklyn-ui/src/main/webapp/index.html +++ /dev/null @@ -1,77 +0,0 @@ -<!DOCTYPE html> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<!-- Brooklyn SHA-1: GIT_SHA_1 --> -<html> -<head> - <meta charset='utf-8'/> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <meta name="description" content="Brooklyn Web Console (Javascript GUI)"> - - <title>Brooklyn JS REST client</title> - - <link rel="stylesheet" href="/assets/css/styles.css"> - <link rel="stylesheet" href="/assets/css/brooklyn.css"> - <style> - body { - padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ - } - </style> - - <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> - <!--[if lt IE 9]> - <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> - <![endif]--> -</head> -<body> - -<div class="navbar navbar-fixed-top"> - <div class="navbar-inner"> - <div class="userName-top"><span id="user"></span> | <a href="/logout" id="logout-link">Log out</a></div> - <div class="container"> - <a class="logo" href="#" title="Brooklyn, Version 0.9.0-SNAPSHOT"><!-- Logo added via CSS --></a> <!-- BROOKLYN_VERSION --> - <div class="menubar-top"> - <ul class="nav"> - <li><a href="#v1/home" class="nav1 nav1_home">Home</a></li> - <li><a href="#v1/applications" class="nav1 nav1_apps">Applications</a></li> - <li><a href="#v1/catalog" class="nav1 nav1_catalog">Catalog</a></li> - <li class="dropdown"> - <a href="#" class="nav1 nav1_script dropdown-toggle" data-toggle="dropdown">Script</a> - <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> - <li><a href="/assets/html/swagger-ui.html" target="_blank" class="nav1 nav1_apidoc">REST API</a></li> - <li><a href="#v1/script/groovy" class="nav1 nav1_groovy">Groovy</a></li> - </ul> - </li> - <li><a href="#v1/help" class="nav1 nav1_help"><b>?</b></a></li> - </ul> - </div> - </div> - </div> -</div> - -<div id="main-content"> - <div id="application-content"></div> - <div id="server-caution-overlay"></div> -</div> - -<!-- load our code with require.js. data-main is replaced with optimised file at build --> -<script type="text/javascript" data-main="assets/js/config.js" src="assets/js/libs/require.js"></script> - -</body> -</html> http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/config.txt ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/config.txt b/brooklyn-ui/src/test/javascript/config.txt deleted file mode 100644 index 0fec281..0000000 --- a/brooklyn-ui/src/test/javascript/config.txt +++ /dev/null @@ -1,72 +0,0 @@ - /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - /* Custom configuration for Jasmine tests. */ - - /* Libraries */ - paths:{ - "jquery":"js/libs/jquery", - "underscore":"js/libs/underscore", - "backbone":"js/libs/backbone", - "bootstrap":"js/libs/bootstrap", - "jquery-form":"js/libs/jquery.form", - "jquery-datatables":"js/libs/jquery.dataTables", - "jquery-slideto":"js/util/jquery.slideto", - "jquery-wiggle":"js/libs/jquery.wiggle.min", - "jquery-ba-bbq":"js/libs/jquery.ba-bbq.min", - "moment":"js/libs/moment", - "handlebars":"js/libs/handlebars-1.0.rc.1", - "brooklyn":"js/util/brooklyn", - "brooklyn-view":"js/util/brooklyn-view", - "brooklyn-utils":"js/util/brooklyn-utils", - "datatables-extensions":"js/util/dataTables.extensions", - "googlemaps":"view/googlemaps", - // async deliberately excluded - "text":"js/libs/text", - "uri":"js/libs/URI", - "zeroclipboard":"js/libs/ZeroClipboard", - "js-yaml":"js/libs/js-yaml", - - "model":"js/model", - "view":"js/view", - "router":"js/router" - }, - shim:{ - "underscore":{ - exports:"_" - }, - "backbone":{ - deps:[ "underscore", "jquery" ], - exports:"Backbone" - }, - "jquery-datatables": { - deps: [ "jquery" ] - }, - "datatables-extensions":{ - deps:[ "jquery", "jquery-datatables" ] - }, - "jquery-form": { deps: [ "jquery" ] }, - "jquery-slideto": { deps: [ "jquery" ] }, - "jquery-wiggle": { deps: [ "jquery" ] }, - "jquery-ba-bbq": { deps: [ "jquery" ] }, - "handlebars": { deps: [ "jquery" ] }, - "bootstrap": { deps: [ "jquery" ] /* http://stackoverflow.com/questions/9227406/bootstrap-typeerror-undefined-is-not-a-function-has-no-method-tab-when-us */ } - }, - // Seconds require will wait before timing out. Defaults to seven seconds. - waitSeconds: 300 http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/home-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/home-spec.js b/brooklyn-ui/src/test/javascript/specs/home-spec.js deleted file mode 100644 index 8933fb6..0000000 --- a/brooklyn-ui/src/test/javascript/specs/home-spec.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -/** - * Jasmine test specs for Application Template and Template rendering. We test for HTML structure, - * ID's, classes that we use, etc. - * - * Tests go like this: - * - we test that all templates are on the page - * - we test that the templates contain all the divs, buttons with the right id's and classes - * - we test that rendering produces the right stuff - */ -define([ - "underscore", "jquery", "model/application", "model/location", "view/home" -], function (_, $, Application, Location, HomeView) { - - describe('view/home-spec', function () { - - describe('view/home HomePageView', function () { - var view, - apps = new Application.Collection, - locs = new Location.Collection - apps.url = "fixtures/application-list.json" - apps.fetch({async:false}) - locs.url = "fixtures/location-list.json" - locs.fetch({async:false}) - - beforeEach(function () { - view = new HomeView({ - collection:apps, - locations:locs, - offline:true - }).render() - }) - - afterEach(function () { - view.close() - }) - - it('should have a div#home-first-row and div#home-second-row', function () { - expect(view.$('div.home-first-row').length).toEqual(1) - expect(view.$('div.home-second-row').length).toEqual(1) - }) - - it('should contain an apps table and a new button', function () { - expect(view.$('div#new-application-resource').length).toEqual(1) - expect(view.$('div#applications').length).toEqual(1) - }) - - it('div#new-application-resource must have button#add-new-application-resource', function () { - expect(view.$('div button#add-new-application').length).toEqual(1) - }) - - it('div#applications must have table with tbody#applications-table-body', function () { - expect(view.$('div#applications table').length).toEqual(1) - expect(view.$('div#applications tbody#applications-table-body').length).toEqual(1) - }) - - it('must have div#modal-container', function () { - expect(view.$('div#modal-container').length).toEqual(1) - }) - }) - - describe('view/home ApplicationEntryView rendering', function () { - var model = new Application.Model({ - status:'STARTING', - spec:new Application.Spec({ - name:'sample', - entities:[ - { name:'entity-01', - type:'org.apache.TomcatServer'} - ], - locations:['/some/where/over/the/rainbow'] - }) - }) - var view = new HomeView.AppEntryView({ - model:model - }).render() - - it('must have 2 td tags', function () { - expect(view.$('td').length).toEqual(2) - }) - -// it('must have a td with button.delete', function () { -// expect(view.$('button.delete').length).toEqual(1) -// expect(view.$('button.delete').parent().is('td')).toEqual(true) -// expect(view.$("button.delete").attr("id")).toBe(model.cid) -// }) - }) - }) -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/library-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/library-spec.js b/brooklyn-ui/src/test/javascript/specs/library-spec.js deleted file mode 100644 index 7a0421f..0000000 --- a/brooklyn-ui/src/test/javascript/specs/library-spec.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -/** - * Test for availability of JavaScript functions/libraries. - * We test for a certain version. People need to be aware they can break stuff when upgrading. - * TODO: find a way to test bootstrap.js version ? - */ - -define([ - 'underscore', 'jquery', 'backbone', -], function (_, $, Backbone) { - - describe('Test the libraries', function () { - - describe('underscore.js', function () { - it('must be version 1.4.4', function () { - expect(_.VERSION).toEqual('1.4.4') - }) - }) - - describe('jquery', function () { - it('must be version 1.7.2', function () { - expect(jQuery.fn.jquery).toEqual('1.7.2') - expect(jQuery).toEqual($); - }) - }) - - describe('backbone', function () { - it('must be version 1.0.0', function () { - expect(Backbone.VERSION).toEqual('1.0.0') - }) - }) - }) -}) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/app-tree-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/app-tree-spec.js b/brooklyn-ui/src/test/javascript/specs/model/app-tree-spec.js deleted file mode 100644 index 7cbacf4..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/app-tree-spec.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "model/app-tree" -], function (AppTree) { - - /** TODO the application-tree.json is hacked together and out of date, - * reflects a combo of what comes back from server and what used to come back and was expected */ - - $.ajaxSetup({ async:false }); - var apps = new AppTree.Collection - apps.url = "fixtures/application-tree.json" - apps.fetch({ async:false }) - - describe("model/app-tree", function () { - - it("loads fixture data", function () { - expect(apps.length).toBe(2) - var app1 = apps.at(0) - expect(app1.get("name")).toBe("test") - expect(app1.get("id")).toBe("riBZUjMq") - expect(app1.get("type")).toBe("") - expect(app1.get("children").length).toBe(1) - expect(app1.get("children")[0].name).toBe("tomcat1") - expect(app1.get("children")[0].type).toBe("org.apache.brooklyn.entity.webapp.tomcat.TomcatServer") - expect(apps.at(1).get("children").length).toBe(2) - }) - - it("has working getDisplayName", function () { - var app1 = apps.at(0) - expect(app1.getDisplayName()).toBe("test") - }) - - it("has working hasChildren method", function () { - expect(apps.at(0).hasChildren()).toBeTruthy() - }) - - it("returns AppTree.Collection for getChildren", function () { - var app1 = apps.at(0), - children = new AppTree.Collection(app1.get("children")) - expect(children.length).toBe(1) - expect(children.at(0).getDisplayName()).toBe("tomcat1") - }) - - it("returns entity names for ids", function() { - expect(apps.getEntityNameFromId("fXyyQ7Ap")).toBe("tomcat1"); - expect(apps.getEntityNameFromId("child-02")).toBe("tomcat2"); - expect(apps.getEntityNameFromId("child-04")).toBe("tomcat04"); - expect(apps.getEntityNameFromId("nonexistant")).toBeFalsy(); - }); - }) -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/application-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/application-spec.js b/brooklyn-ui/src/test/javascript/specs/model/application-spec.js deleted file mode 100644 index 1b76e3b..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/application-spec.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "model/application", "model/entity" -], function (Application, Entity) { - - $.ajaxSetup({ async:false }); - - describe('model/application Application model', function () { - - var application = new Application.Model() - - application.url = 'fixtures/application.json' - application.fetch({async:false}) - - it('loads all model properties defined in fixtures/application.json', function () { - expect(application.get("status")).toEqual('STARTING') - expect(application.getLinkByName('self')).toEqual('/v1/applications/myapp') - expect(application.getLinkByName('entities')).toEqual('fixtures/entity-summary-list.json') - }) - - it("loads the spec from fixtures/application.json", function () { - var applicationSpec = application.getSpec(), - entity = new Entity.Model(applicationSpec.get("entities")[0]) - - expect(applicationSpec.get("name")).toEqual('myapp') - expect(applicationSpec.get("locations")[0]).toEqual('/v1/locations/1') - expect(entity.get("name")).toEqual('Vanilla Java App') - }) - - it('fetches entities from the spec url: fixtures/entity-summary-list.json', function () { - expect(application.getLinkByName('entities')).toBe('fixtures/entity-summary-list.json') - }) - }) - - describe('model/application', function () { - - var spec, location, entity - - beforeEach(function () { - spec = new Application.Spec - location = "/v1/locations/2" - entity = new Entity.Model({name:'test'}) - - spec.url = 'fixtures/application-spec.json' - spec.fetch({async:false}) - }) - - it('loads the properties from fixtures/application-spec.json', function () { - expect(spec.get("name")).toEqual('myapp') - expect(spec.get("locations")[0]).toEqual('/v1/locations/1') - expect(spec.get("entities").length).toBe(1) - }) - - it("loads the entity from fixtures/application-spec.json", function () { - var entity = new Entity.Model(spec.get("entities")[0]) - expect(entity.get("name")).toEqual('Vanilla Java App') - expect(entity.get("type")).toEqual('org.apache.brooklyn.entity.java.VanillaJavaApp') - expect(entity.getConfigByName('initialSize')).toEqual('1') - expect(entity.getConfigByName('creationScriptUrl')).toEqual('http://my.brooklyn.io/storage/foo.sql') - }) - - it("triggers 'change' when we add a location", function () { - spyOn(spec, "trigger").andCallThrough() - spec.addLocation(location) - expect(spec.trigger).toHaveBeenCalled() - expect(spec.get("locations").length).toEqual(2) - }) - - it("triggers 'change' when we remove a location", function () { - spec.addLocation(location) - spyOn(spec, "trigger").andCallThrough() - - spec.removeLocation('/v1/invalid/location') - expect(spec.trigger).not.toHaveBeenCalled() - spec.removeLocation(location) - expect(spec.trigger).toHaveBeenCalled() - expect(spec.get("locations").length).toEqual(1) - }) - - it('allows you to add the same location twice', function () { - var spec = new Application.Spec, - location = '/ion/23' - spec.addLocation(location) - spec.addLocation(location) - expect(spec.get("locations").length).toEqual(2) - }) - - it("triggers 'change' when you add an entity", function () { - spyOn(spec, "trigger").andCallThrough() - spec.removeEntityByName(entity.get("name")) - expect(spec.trigger).not.toHaveBeenCalled() - spec.addEntity(entity) - expect(spec.trigger).toHaveBeenCalled() - }) - - it("triggers 'change' when you remove an entity", function () { - spec.addEntity(entity) - spyOn(spec, "trigger").andCallThrough() - spec.removeEntityByName(entity.get("name")) - expect(spec.trigger).toHaveBeenCalled() - }) - - it('allows you to add the same entity twice', function () { - var spec = new Application.Spec, - entity = new Entity.Model({ name:'test-entity'}) - spec.addEntity(entity) - spec.addEntity(entity) - expect(spec.get("entities").length).toEqual(2) - }) - }) -}) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/catalog-application-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/catalog-application-spec.js b/brooklyn-ui/src/test/javascript/specs/model/catalog-application-spec.js deleted file mode 100644 index d6a1c27..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/catalog-application-spec.js +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - 'underscore', 'model/catalog-application' -], function (_, CatalogApplication) { - var catalogApplication = new CatalogApplication.Model - catalogApplication.url = 'fixtures/catalog-application.json' - catalogApplication.fetch({async:false}) - - describe('model/catalog-application', function() { - it('loads data from fixture file', function () { - expect(catalogApplication.get('id')).toEqual('com.example.app:1.1') - expect(catalogApplication.get('type')).toEqual('com.example.app') - expect(catalogApplication.get('name')).toEqual('My example application') - expect(catalogApplication.get('version')).toEqual('1.1') - expect(catalogApplication.get('description')).toEqual('My awesome example application, as a catalog item') - expect(catalogApplication.get('planYaml')).toEqual('services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n launch.command: echo \"Launch application\"\n checkRunning.command: echo \"Check running application\"') - expect(catalogApplication.get('iconUrl')).toEqual('http://my.example.com/icon.png') - }) - }) - describe("model/catalog-application", function () { - it('fetches from /v1/locations', function () { - var catalogApplicationCollection = new CatalogApplication.Collection() - expect(catalogApplicationCollection.url).toEqual('/v1/catalog/applications') - }) - - // keep these in describe so jasmine-maven will load them from the file pointed by URL - var catalogApplicationFixture = new CatalogApplication.Collection - catalogApplicationFixture.url = 'fixtures/catalog-application-list.json' - catalogApplicationFixture.fetch() - - it('loads all model properties defined in fixtures/catalog-application.json', function () { - expect(catalogApplicationFixture.length).toEqual(3) - - var catalogApplication1 = catalogApplicationFixture.at(0) - expect(catalogApplication1.get('id')).toEqual('com.example.app:1.1') - expect(catalogApplication1.get('type')).toEqual('com.example.app') - expect(catalogApplication1.get('name')).toEqual('My example application') - expect(catalogApplication1.get('version')).toEqual('1.1') - expect(catalogApplication1.get('description')).toEqual('My awesome example application, as a catalog item') - expect(catalogApplication1.get('planYaml')).toEqual('services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n launch.command: echo \"Launch application\"\n checkRunning.command: echo \"Check running application\"') - expect(catalogApplication1.get('iconUrl')).toEqual('http://my.example.com/icon.png') - - var catalogApplication2 = catalogApplicationFixture.at(1) - expect(catalogApplication2.get('id')).toEqual('com.example.app:2.0') - expect(catalogApplication2.get('type')).toEqual('com.example.app') - expect(catalogApplication2.get('name')).toEqual('My example application') - expect(catalogApplication2.get('version')).toEqual('2.0') - expect(catalogApplication2.get('description')).toEqual('My awesome example application, as a catalog item') - expect(catalogApplication2.get('planYaml')).toEqual('services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n launch.command: echo \"Launch application\"\n checkRunning.command: echo \"Check running application\"') - expect(catalogApplication2.get('iconUrl')).toEqual('http://my.example.com/icon.png') - - var catalogApplication3 = catalogApplicationFixture.at(2) - expect(catalogApplication3.get('id')).toEqual('com.example.other.app:1.0') - expect(catalogApplication3.get('type')).toEqual('com.example.other.app') - expect(catalogApplication3.get('name')).toEqual('Another example application') - expect(catalogApplication3.get('version')).toEqual('1.0') - expect(catalogApplication3.get('description')).toEqual('Another awesome example application, as a catalog item') - expect(catalogApplication3.get('planYaml')).toEqual('services:\n- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess\n launch.command: echo \"Launch other application\"\n checkRunning.command: echo \"Check running other application\"') - expect(catalogApplication3.get('iconUrl')).toEqual('http://my.other.example.com/icon.png') - }) - - it ('Collection#getDistinctApplications returns all available applications, group by type', function() { - var groupBy = catalogApplicationFixture.getDistinctApplications() - - expect(Object.keys(groupBy).length).toBe(2) - expect(groupBy.hasOwnProperty('com.example.app')).toBeTruthy() - expect(groupBy['com.example.app'].length).toBe(2) - expect(groupBy['com.example.app'][0].get('version')).toEqual('1.1') - expect(groupBy['com.example.app'][1].get('version')).toEqual('2.0') - expect(groupBy.hasOwnProperty('com.example.other.app')).toBeTruthy() - expect(groupBy['com.example.other.app'].length).toBe(1) - expect(groupBy['com.example.other.app'][0].get('version')).toEqual('1.0') - }) - - it('Collection#getTypes() returns only distinct types', function() { - var types = catalogApplicationFixture.getTypes() - - expect(types.length).toBe(2) - expect(types[0]).toEqual('com.example.app') - expect(types[1]).toEqual('com.example.other.app') - }) - - describe('Collection#hasType()', function() { - it('Returns true if the given type exists within the applications list', function() { - var ret = catalogApplicationFixture.hasType('com.example.other.app') - - expect(ret).toBeTruthy() - }) - - it('Returns false if the given type exists within the applications list', function() { - var ret = catalogApplicationFixture.hasType('com.example.other.app.that.does.not.exist') - - expect(ret).toBeFalsy() - }) - }) - - describe('Collection#getVersions()', function() { - it('Returns an empty array if no applications exist with the given type', function() { - var versions = catalogApplicationFixture.getVersions('com.example.other.app.that.does.not.exist') - - expect(versions.length).toBe(0) - }) - - it('Returns the expected array of versions if applications exist with the given type', function() { - var versions = catalogApplicationFixture.getVersions('com.example.app') - - expect(versions.length).toBe(2) - expect(versions[0]).toEqual('1.1') - expect(versions[1]).toEqual('2.0') - }) - }) - }) -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/effector-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/effector-spec.js b/brooklyn-ui/src/test/javascript/specs/model/effector-spec.js deleted file mode 100644 index 5ffdebd..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/effector-spec.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "model/effector-summary", "model/effector-param" -], function (EffectorSummary, EffectorParam) { - - $.ajaxSetup({async: false}); - - describe("effector-spec: EffectorSummary model", function () { - var effectorCollection = new EffectorSummary.Collection; - effectorCollection.url = "fixtures/effector-summary-list.json"; - effectorCollection.fetch(); - - it("must have start, stop and restart effectors", function () { - var actual = effectorCollection.pluck("name").sort(); - var expected = ["restart", "start", "stop"].sort(); - expect(actual).toEqual(expected); - }); - - describe("the start effector", function () { - var startEffector = effectorCollection.at(0); - it("has void return type and two parameters", function () { - expect(startEffector.get("name")).toBe("start"); - expect(startEffector.get("returnType")).toBe("void"); - expect(startEffector.get("parameters").length).toBe(2); - }); - - it("has a parameter named 'locations'", function () { - var parameter = new EffectorParam.Model(startEffector.getParameterByName("locations")); - expect(parameter.get("name")).toBe("locations"); - expect(parameter.get("type")).toBe("java.util.Collection"); - expect(parameter.get("description")).toBe("A list of locations"); - }); - - it("has a parameter named 'booleanValue'", function () { - var parameter = new EffectorParam.Model(startEffector.getParameterByName("booleanValue")); - expect(parameter.get("name")).toBe("booleanValue"); - expect(parameter.get("type")).toBe("java.lang.Boolean"); - expect(parameter.get("description")).toBe("True or false"); - expect(parameter.get("defaultValue")).toBe(true); - }); - }) - }) -}); http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/entity-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/entity-spec.js b/brooklyn-ui/src/test/javascript/specs/model/entity-spec.js deleted file mode 100644 index 6b3c80e..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/entity-spec.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "underscore", "model/entity" -], function (_, Entity) { - $.ajaxSetup({ async:false }); - - describe("model/entity", function () { - // keep these in describe so jasmine-maven will load them from the file pointed by URL - var entityFixture = new Entity.Collection - entityFixture.url = 'fixtures/entity.json' - entityFixture.fetch() - - it('loads all model properties defined in fixtures/entity.json', function () { - expect(entityFixture.length).toEqual(1) - var entity = entityFixture.at(0) - expect(entity.get("name")).toEqual('Vanilla Java App') - expect(entity.get("type")).toEqual('org.apache.brooklyn.entity.java.VanillaJavaApp') - expect(entity.get("config")).toEqual({}) - }) - }) -}) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/entity-summary-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/entity-summary-spec.js b/brooklyn-ui/src/test/javascript/specs/model/entity-summary-spec.js deleted file mode 100644 index 230b331..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/entity-summary-spec.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define( - ["model/entity-summary" ], - function (EntitySummary) { - - describe('model/entity-summary EntitySummary model and collection', function () { - var summaries = new EntitySummary.Collection - summaries.url = 'fixtures/entity-summary-list.json' - summaries.fetch({async:false}) - var eSummary = summaries.at(0) - - it('the collection element must be of type TomcatServer and have expected properties', function () { - expect(eSummary.getLinkByName('catalog')) - .toBe('/v1/catalog/entities/org.apache.brooklyn.entity.webapp.tomcat.TomcatServer') - expect(eSummary.get("type")).toBe('org.apache.brooklyn.entity.webapp.tomcat.TomcatServer') - expect(eSummary.getLinkByName('sensors')).toBe('fixtures/sensor-summary-list.json') - expect(eSummary.getDisplayName()).toBe('TomcatServer:zQsqdXzi') - }) - - it('collection has working findByDisplayName function', function () { - expect(summaries.findByDisplayName('test').length).toBe(0) - expect(summaries.findByDisplayName(eSummary.getDisplayName()).length).toBe(1) - expect(JSON.stringify(summaries.findByDisplayName(eSummary.getDisplayName()).pop().toJSON())).toBe(JSON.stringify(eSummary.toJSON())) - }) - - it('collection must have one element', function () { - expect(summaries.length).toBe(1) - }) - - }) - }) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/location-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/location-spec.js b/brooklyn-ui/src/test/javascript/specs/model/location-spec.js deleted file mode 100644 index f72fc8c..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/location-spec.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "underscore", "model/location" -], function (_, Location) { - - var location = new Location.Model - location.url = "fixtures/location-summary.json" - location.fetch({async:false}) - - describe('model/location', function () { - it("loads data from fixture file", function () { - expect(location.get("spec")).toBe("localhost") - expect(location.getLinkByName("self")).toBe("/v1/locations/123") - }) - }) - - describe('model/location', function () { - // keep these in describe so jasmine-maven will load them from the file pointed by URL - var locationFixtures = new Location.Collection - locationFixtures.url = 'fixtures/location-list.json' - locationFixtures.fetch() - it('loads all model properties defined in fixtures/location-list.json', function () { - expect(locationFixtures.length).toEqual(1) - var spec = locationFixtures.at(0) - expect(spec.get("id")).toEqual('123') - expect(spec.get("name")).toEqual('localhost') - expect(spec.get("spec")).toEqual('localhost') - expect(spec.get("config")).toEqual({}) - expect(spec.hasSelfUrl('/v1/locations/123')).toBeTruthy() - expect(spec.getLinkByName("self")).toEqual('/v1/locations/123') - }) - - var locationCollection = new Location.Collection() - it('fetches from /v1/locations', function () { - expect(locationCollection.url).toEqual('/v1/locations') - }) - it('has model LocationSpec', function () { - expect(locationCollection.model).toEqual(Location.Model) - }) - }) -}) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/sensor-summary-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/sensor-summary-spec.js b/brooklyn-ui/src/test/javascript/specs/model/sensor-summary-spec.js deleted file mode 100644 index 222df70..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/sensor-summary-spec.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define(['model/sensor-summary'], function (SensorSummary) { - - describe('SensorSummary model', function () { - var sensorCollection = new SensorSummary.Collection - sensorCollection.url = 'fixtures/sensor-summary-list.json' - sensorCollection.fetch() - - it('collection must have 4 sensors', function () { - expect(sensorCollection.length).toBe(4) - }) - - it('must have a sensor named service.state', function () { - var filteredSensors = sensorCollection.where({ 'name':'service.state'}) - expect(filteredSensors.length).toBe(1) - var ourSensor = filteredSensors.pop() - expect(ourSensor.get("name")).toBe('service.state') - expect(ourSensor.get("type")).toBe('org.apache.brooklyn.entity.lifecycle.Lifecycle') - expect(ourSensor.get("description")).toBe('Service lifecycle state') - expect(ourSensor.getLinkByName('self')).toBe('fixtures/service-state.json') - expect(ourSensor.getLinkByName()).toBe(undefined) - }) - }) -}) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/model/task-summary-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/model/task-summary-spec.js b/brooklyn-ui/src/test/javascript/specs/model/task-summary-spec.js deleted file mode 100644 index b7e488c..0000000 --- a/brooklyn-ui/src/test/javascript/specs/model/task-summary-spec.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "model/task-summary" -], function (TaskSummary) { - - describe("model/task-summary spec", function () { - var tasks = new TaskSummary.Collection - tasks.url = "fixtures/task-summary-list.json" - tasks.fetch({async:false}) - - it("loads the collection from 'fixtures/task-summary-list.json'", function () { - var task = tasks.at(0) - expect(task.get("entityId")).toBe("VzK45RFC") - expect(task.get("displayName")).toBe("start") - expect(task.get("rawSubmitTimeUtc")).toBe(1348663165550) - }) - }) -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/router-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/router-spec.js b/brooklyn-ui/src/test/javascript/specs/router-spec.js deleted file mode 100644 index 8f54bb8..0000000 --- a/brooklyn-ui/src/test/javascript/specs/router-spec.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -define([ - "brooklyn", "router" -], function (Brooklyn, Router) { - - var View = Backbone.View.extend({ - render:function () { - this.$el.html("<p>fake view</p>") - return this - } - }) - - describe("router", function () { - var view, router - - beforeEach(function () { - view = new View - router = new Router - $("body").append('<div id="container"></div>') - }) - - afterEach(function () { - $("#container").remove() - }) - - it("shows the view inside div#container", function () { - expect($("body #container").length).toBe(1) - expect($("#container").text()).toBe("") - router.showView("#container", view) - expect($("#container").text()).toBe("fake view") - }) - - it("should call 'close' of old views", function () { - spyOn(view, "close") - - router.showView("#container", view) - expect(view.close).not.toHaveBeenCalled() - // it should close the old view - router.showView("#container", new View) - expect(view.close).toHaveBeenCalled() - }) - }) - - describe("Periodic functions", function() { - var CallbackView = View.extend({ - initialize: function() { - this.counter = 0; - this.callPeriodically("test-callback", function() { - this.counter += 1; - }, 3) - } - }); - - // Expects callback to have been called at least once - it("should have 'this' set to the owning view", function() { - Brooklyn.view.refresh = true; - var view = new CallbackView(); - waits(15); - runs(function() { - expect(view.counter).toBeGreaterThan(0); - }); - }); - - it("should not be run if Brooklyn.view.refresh is false", function() { - Brooklyn.view.refresh = false; - var view = new CallbackView(); - waits(15); - runs(function() { - expect(view.counter).toEqual(0); - Brooklyn.view.refresh = true; - }); - }); - }); - -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/util/brooklyn-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/util/brooklyn-spec.js b/brooklyn-ui/src/test/javascript/specs/util/brooklyn-spec.js deleted file mode 100644 index 4098235..0000000 --- a/brooklyn-ui/src/test/javascript/specs/util/brooklyn-spec.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -define([ - "brooklyn", "backbone" -], function (B, Backbone) { - - describe("view", function () { - describe("form", function() { - var formTemplate = _.template('<form>' + - '<input name="id" type="text"/>' + - '<input name="initialvalue" type="text" value="present"/>' + - '<button type="submit" class="submit">Submit</button>' + - '</form>'); - - it("should set existing values on the model", function() { - var form = new B.view.Form({template: formTemplate, onSubmit: function() {}}); - expect(form.model.get("initialvalue")).toBe("present"); - expect(form.model.get("id")).toBe(""); - }); - - it("should maintain a model as inputs change", function () { - var form = new B.view.Form({ - template: formTemplate, - onSubmit: function() {} - }); - // simulate id entry - form.$("[name=id]").val("987"); - form.$("[name=id]").trigger("change"); - expect(form.model.get("id")).toBe("987"); - }); - - it("should call the onSubmit callback when the form is submitted", function () { - var wasCalled = false; - var onSubmit = function (model) { - wasCalled = true; - }; - var form = new B.view.Form({ - template: formTemplate, - onSubmit: onSubmit - }); - form.$("form").trigger("submit"); - expect(wasCalled).toBe(true); - }); - - it("should fail if called without template or onSubmit", function () { - try { - new B.view.Form({template: ""}); - fail; - } catch (e) { - // expected - } - try { - new B.view.Form({onSubmit: function() {}}); - fail; - } catch (e) { - // expected - } - - }); - }); - }); - - describe("_.stripComments", function () { - it("should strip a basic comment", function () { - var text = "<p>abc</p>\n <!-- comment-here --> <p>cba</p>"; - expect(_.stripComments(text)).toBe("<p>abc</p>\n <p>cba</p>"); - }); - - it("should return an empty string for an empty comment", function () { - expect(_.stripComments("<!---->")).toBe(""); - expect(_.stripComments("<!-- -->")).toBe(""); - }); - - it("should strip multiple comments", function () { - var text = "a<!-- one -->b<!--two-->c<!-- three -->"; - expect(_.stripComments(text)).toBe("abc"); - }); - - it("should strip trailing newlines", function () { - expect(_.stripComments("<!-- a -->\nb")).toBe("b"); - expect(_.stripComments("<!-- a -->\rb")).toBe("b"); - }); - - it("should leave text with no comments untouched", function () { - var text = "<p>abc</p>"; - expect(_.stripComments(text)).toBe(text); - }); - - it("should remove the Apache license header from an HTML template", function () { - var text = "<!--\n" + - "Licensed to the Apache Software Foundation (ASF) under one\n" + - "or more contributor license agreements. See the NOTICE file\n" + - "distributed with this work for additional information\n" + - "regarding copyright ownership. The ASF licenses this file\n" + - "to you under the Apache License, Version 2.0 (the\n" + - "\"License\"); you may not use this file except in compliance\n" + - "with the License. You may obtain a copy of the License at\n" + - "\n" + - "http://www.apache.org/licenses/LICENSE-2.0\n" + - "\n" + - "Unless required by applicable law or agreed to in writing,\n" + - "software distributed under the License is distributed on an\n" + - "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" + - "KIND, either express or implied. See the License for the\n" + - "specific language governing permissions and limitations\n" + - "under the License.\n" + - "-->\n" + - "real content"; - expect(_.stripComments(text)).toBe("real content"); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/util/brooklyn-utils-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/util/brooklyn-utils-spec.js b/brooklyn-ui/src/test/javascript/specs/util/brooklyn-utils-spec.js deleted file mode 100644 index 4c21f50..0000000 --- a/brooklyn-ui/src/test/javascript/specs/util/brooklyn-utils-spec.js +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -define([ - 'brooklyn-utils', "backbone" -], function (Util, Backbone) { - - describe('Rounding numbers', function () { - - var round = Util.roundIfNumberToNumDecimalPlaces; - - it("should round in the correct direction", function() { - // unchanged - expect(round(1, 2)).toBe(1); - expect(round(1.1, 1)).toBe(1.1); - expect(round(1.9, 1)).toBe(1.9); - expect(round(1.123123123, 6)).toBe(1.123123); - expect(round(-22.222, 3)).toBe(-22.222); - - // up - expect(round(1.9, 0)).toBe(2); - expect(round(1.5, 0)).toBe(2); - expect(round(1.49, 1)).toBe(1.5); - - // down - expect(round(1.01, 1)).toBe(1.0); - expect(round(1.49, 0)).toBe(1); - expect(round(1.249, 1)).toBe(1.2); - expect(round(1.0000000000000000000001, 0)).toBe(1); - }); - - it("should round negative numbers correctly", function() { - // up - expect(round(-10, 0)).toBe(-10); - expect(round(-10.49999, 0)).toBe(-10); - - // down - expect(round(-10.5, 0)).toBe(-11); - expect(round(-10.50001, 0)).toBe(-11); - expect(round(-10.49999, 1)).toBe(-10.5); - }); - - it("should ignore non-numeric values", function() { - expect(round("xyz", 1)).toBe("xyz"); - expect(round("2.4", 0)).toBe("2.4"); - expect(round({a: 2}, 0)).toEqual({a: 2}); - }); - - it("should ignore negative mantissas", function() { - expect(round(10.5, -1)).toBe(10.5); - expect(round(100, -1)).toBe(100); - expect(round(0, -1)).toBe(0); - }); - - }); - - describe("pathOf", function() { - - it("should extract the path component of a URI", function() { - expect(Util.pathOf("http://www.example.com/path/to/resource#more?a=b&c=d")).toBe("/path/to/resource"); - }); - - it("should return an empty path for an empty URL", function() { - expect(Util.pathOf("")).toBe(""); - }); - - it("should handle input without domain", function() { - expect(Util.pathOf("/a/b/c/d#e")).toBe("/a/b/c/d"); - }) - }); - - describe("inputValue", function () { - it("should return inputs as strings", function () { - expect(Util.inputValue($('<input type="text" value="bob"/>'))).toBe("bob"); - expect(Util.inputValue($('<textarea rows="10" cols="5">content</textarea>'))).toBe("content"); - }); - - it("should return true/false for checkboxes", function () { - var input = $('<input type="checkbox" checked/>'); - expect(Util.inputValue(input)).toBe(true); - input = $('<input type="checkbox" />'); - expect(Util.inputValue(input)).toBe(false); - }); - }); - - describe("bindModelFromForm", function () { - // pretend to be a Backbone model without bringing in Backbone as a dependency - var TestModel = Backbone.Model.extend({ - urlRoot: function () { - return "/foo/bar/"; - } - }); - var form = $("<form>" + - "<input name='id' type='input' value='text'/>" + - "<input name='bool' type='checkbox' checked/>" + - "</form>"); - - it("should create a new model if given a constructor", function () { - var model = Util.bindModelFromForm(TestModel, form); - expect(model instanceof TestModel).toBe(true); - expect(model.url()).toBe("/foo/bar/text"); - var inputs = model.attributes; - expect(_.keys(inputs).length).toBe(2); - expect(inputs.id).toBe("text"); - expect(inputs.bool).toBe(true); - }); - - it("should update an existing model", function () { - var model = new TestModel({initialAttribute: "xyz"}); - Util.bindModelFromForm(model, form); - var inputs = model.attributes; - expect(_.keys(inputs).length).toBe(3); - expect(inputs.id).toBe("text"); - expect(inputs.bool).toBe(true); - expect(inputs.initialAttribute).toBe("xyz"); - }); - }); - - describe("extractError", function () { - it("should extract the response message", function () { - var m = Util.extractError({ responseText: '{"message": "hello"}'}, "default"); - expect(m).toBe("hello"); - }); - - it("should return the default on invalid JSON", function () { - var m = Util.extractError({ responseText: "<html></html>"}, "default"); - expect(m).toBe("default"); - }); - - it("should return the default if the response has no message", function () { - var m = Util.extractError({ a: '{"b": "c"}'}, "default"); - expect(m).toBe("default"); - }); - }); - -}); http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/view/application-add-wizard-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/view/application-add-wizard-spec.js b/brooklyn-ui/src/test/javascript/specs/view/application-add-wizard-spec.js deleted file mode 100644 index 29a0b09..0000000 --- a/brooklyn-ui/src/test/javascript/specs/view/application-add-wizard-spec.js +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -/** - * Test the ModalWizard can build a modal to view, edit and submit an application. - */ -define([ - "underscore", "jquery", "backbone", "view/application-add-wizard", "model/application", "model/location" -// "text!tpl/home/step1.html", "text!tpl/home/step2.html", "text!tpl/home/step3.html", -// "text!tpl/home/step1-location-row.html", "text!tpl/home/step1-location-option.html", -// "text!tpl/home/step2-entity-entry.html", "text!tpl/home/step2-config-entry.html" -], function (_, $, Backbone, AppAddWizard, Application, Locations -// , -// Entities, -// Step1Html, Step2Html, Step3Html, -// Step1LocationRowHtml, LocationOptionHtml, -// Step2EntityEntryHtml, Step2ConfigEntryHtml - ) { - - /* TEST disabled until we can more cleanly supply javascript. - * should probably move to have one big model, - * rather than passing around lots of small model items. - */ - -// Backbone.View.prototype.close = function () { -// if (this.beforeClose) { -// this.beforeClose() -// } -// this.remove() -// this.unbind() -// } -// -// var fakeRouter = new Backbone.Router() -// var modal = new ModalWizard({appRouter:fakeRouter}); -// -// describe("view/modal-wizard", function () { -// -// it("creates an empty Application.Spec", function () { -// expect(modal.model.get("name")).toBe("") -// expect(modal.model.get("entities")).toEqual([]) -// expect(modal.model.get("locations")).toEqual([]) -// }) -// -// it("creates a view for each of the 3 steps", function () { -// expect(modal.steps.length).toBe(3) -// expect(modal.steps[0].view instanceof ModalWizard.Step1).toBeTruthy() -// expect(modal.steps[1].view instanceof ModalWizard.Step2).toBeTruthy() -// expect(modal.steps[2].view instanceof ModalWizard.Step3).toBeTruthy() -// }) -// -// it("beforeClose method closes all 3 subviews", function () { -// spyOn(Backbone.View.prototype, "close").andCallThrough() -// modal.beforeClose() -// expect(modal.steps[0].view.close).toHaveBeenCalled() -// expect(modal.steps[1].view.close).toHaveBeenCalled() -// expect(modal.steps[2].view.close).toHaveBeenCalled() -// }) -// }) -// -// describe("view/modal-wizard step1", function () { -// var app, view -// -// beforeEach(function () { -// app = new Application.Spec -// view = new ModalWizard.Step1({model:app}) -// view.locations.url = "fixtures/location-list.json" -// view.locations.fetch({async:false}) -// view.render() -// }) -// -// afterEach(function () { -// view.close() -// }) -// -// it("does not validate empty view", function () { -// expect(view.validate()).toBe(false) -// expect(view.$("#app-locations ul").html()).toBe("") -// expect(view.$("#application-name").text()).toBe("") -// }) -// -// it("updates the name on blur", function () { -// view.$("#application-name").val("myapp") -// view.$("#application-name").trigger("blur") -// expect(app.get("name")).toBe("myapp") -// }) -// -// it("adds and removes location", function () { -// expect(app.get("locations").length).toBe(0) -// view.$("#add-app-location").trigger("click") -// expect(app.get("locations").length).toBe(1) -// view.$(".remove").trigger("click") -// expect(app.get("locations").length).toBe(0) -// }) -// -// }) -// -// describe("view/modal-wizard step2", function () { -// var app, view -// -// beforeEach(function () { -// app = new Application.Spec -// view = new ModalWizard.Step2({model:app}) -// // TODO supply catalog entities -// view.render() -// }) -// -// afterEach(function () { -// view.close() -// }) -// -// // to be added -// }) -// -// describe("view/modal-wizard step3", function () { -// var app, view -// -// beforeEach(function () { -// app = new Application.Spec -// view = new ModalWizard.Step3({model:app}) -// view.render() -// }) -// -// afterEach(function () { -// view.close() -// }) -// -// it("has #app-summary to render the application", function () { -// expect(view.$("#app-summary").length).toBe(1) -// }) -// -// it("validates only when application spec contains data", function () { -// expect(view.validate()).toBe(false) -// app.set({name:"myapp", locations:["/dummy/1"], entities:[ -// {} -// ]}) -// expect(view.validate()).toBe(true) -// }) -// }) -// -// describe('tpl/home/step1.html', function () { -// var $step = $(Step1Html) -// -// it('must have input#application-name', function () { -// expect($step.find('input#application-name').length).toEqual(1); -// }); -// -// it('must have div#app-locations', function () { -// var $appLocations = $step.filter('div#app-locations'); -// expect($appLocations.length).toEqual(1); -// expect($appLocations.find('h4').length).toEqual(1); -// expect($appLocations.find('ul').length).toEqual(1); -// expect($appLocations.find('button#toggle-selector-container').length).toEqual(1); -// }); -// -// it('must have select#select-location', function () { -// expect($step.find('select#select-location').length).toEqual(1); -// }); -// -// it('must have button#add-app-location', function () { -// expect($step.find('button#add-app-location').length).toEqual(1); -// }); -// it('must have div.info-message', function () { -// expect($step.filter('div.info-message').length).toEqual(1); -// }) -// }); -// -// describe('tpl/home/step2.html', function () { -// var $step = $(Step2Html); -// -// it('must have div#entities with h4 and ul', function () { -// var $div = $step.filter('div#entities'); -// expect($div.length).toEqual(1); -// expect($div.find('h4').length).toEqual(1); -// expect($div.find('ul').length).toEqual(1); -// expect($div.find('button#toggle-entity-form').length).toEqual(1); -// }); -// -// it('must have div#new-entity with all components', function () { -// var $div = $step.filter('div#new-entity'); -// expect($div.length).toEqual(1); -// expect($div.find('div#entity-form').length).toEqual(1); -// expect($div.find('button#add-app-entity').length).toEqual(1); -// expect($div.find('div.entity-info-message').length).toEqual(1); -// }); -// it('must have div.info-message', function () { -// expect($step.filter('div.info-message').length).toEqual(1); -// }); -// }); -// -// describe('tpl/home/step3.html', function () { -// var $step = $(Step3Html); -// it('div.body must have h3 and textarea#app-summary', function () { -// expect($step.find('h3').length).toEqual(1); -// expect($step.find('textarea#app-summary').length).toEqual(1); -// }); -// it('must have div.info-message', function () { -// expect($step.filter('div.info-message').length).toEqual(1); -// }); -// }); -}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/18b073a9/brooklyn-ui/src/test/javascript/specs/view/application-explorer-spec.js ---------------------------------------------------------------------- diff --git a/brooklyn-ui/src/test/javascript/specs/view/application-explorer-spec.js b/brooklyn-ui/src/test/javascript/specs/view/application-explorer-spec.js deleted file mode 100644 index 3e3dd96..0000000 --- a/brooklyn-ui/src/test/javascript/specs/view/application-explorer-spec.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. -*/ -/** - * Tests for application tree - view explorer. - */ -define([ - "underscore", "jquery", "model/app-tree", "view/application-explorer", - "model/entity-summary", "model/application" -], function (_, $, AppTree, ApplicationExplorerView, EntitySummary, Application) { - - describe('view/application-explorer-spec', function () { - - describe('Application Explorer', function () { - var apps = new AppTree.Collection, - view - apps.url = 'fixtures/application-tree.json' - apps.fetch({async:false}) - - var entityFetch, applicationFetch, defer; - - beforeEach(function () { - // ApplicationTree makes fetch requests to EntitySummary and Application models - // with hard-coded URLs, causing long stacktraces in mvn output. This workaround - // turns their fetch methods into empty functions. - entityFetch = EntitySummary.Model.prototype.fetch; - applicationFetch = Application.Model.prototype.fetch; - defer = _.defer; - _.defer = EntitySummary.Model.prototype.fetch = Application.Model.prototype.fetch = function() {}; - view = new ApplicationExplorerView({ collection:apps }).render() - }) - - afterEach(function() { - EntitySummary.Model.prototype.fetch = entityFetch; - Application.Model.prototype.fetch = applicationFetch; - _.defer = defer; - }); - - it('must contain div.row with two spans: #tree and #details', function () { - expect(view.$el.is('#application-explorer')).toBeTruthy() - expect(view.$el.is('div.container.container-fluid')).toBeTruthy() - expect(view.$("div#tree").is('.span4')).toBeTruthy() - expect(view.$("div#details").is('.span8')).toBeTruthy() - }) - - it("must have a i.refresh element inside #tree header", function () { - expect(view.$("#tree h3").length).toBe(1) - expect(view.$("#tree i.application-tree-refresh").length).toBe(1) - }) - - it("must have div#app-tree for rendering the applications", function () { - expect(view.$("div#app-tree").length).toBe(1) - }) - - it("triggers collection fetch on application refresh", function () { - spyOn(apps, "fetch").andCallThrough() - view.$(".application-tree-refresh").trigger("click") - waits(100) - runs(function () { - expect(view.collection.fetch).toHaveBeenCalled() - }) - }) - }) - }) -}) \ No newline at end of file
