cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [2/2] git commit: Refactored config_parser.js to simply both it and its tests. Details:
Date Tue, 25 Feb 2014 21:31:33 GMT
Refactored config_parser.js to simply both it and its tests. Details:

- config_parser -> ConfigParser
- Deleted unused methods
- Don't auto-write from setters
- Stop mocking elementtree functions in tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/45e80ac1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/45e80ac1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/45e80ac1

Branch: refs/heads/master
Commit: 45e80ac1b2c73a18155e74ac286067a4299742d8
Parents: 1f681d4
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Feb 25 16:29:29 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Feb 25 16:29:29 2014 -0500

----------------------------------------------------------------------
 e2e/create.spec.js                              |   3 +-
 e2e/fixtures/hooks_bat/fail/fail.bat            |   2 +-
 e2e/fixtures/hooks_bat/test/07.bat              |   2 +-
 .../platforms/android/assets/www/cordova.js     |   2 +-
 .../android/assets/www/cordova_plugins.js       |   2 +-
 e2e/fixtures/platforms/android/cordova/build    |   2 +-
 e2e/fixtures/platforms/android/cordova/clean    |   2 +-
 .../android/cordova/lib/install-device          |   2 +-
 .../android/cordova/lib/install-emulator        |   2 +-
 .../platforms/android/cordova/lib/list-devices  |   2 +-
 .../android/cordova/lib/list-emulator-images    |   2 +-
 .../android/cordova/lib/list-started-emulators  |   2 +-
 .../android/cordova/lib/start-emulator          |   2 +-
 e2e/fixtures/platforms/android/cordova/log      |   2 +-
 e2e/fixtures/platforms/android/cordova/run      |   2 +-
 spec/ConfigParser.spec.js                       |  76 +++++
 spec/config_parser.spec.js                      | 280 -------------------
 spec/create.spec.js                             |  31 +-
 spec/metadata/android_parser.spec.js            | 102 +++----
 spec/metadata/blackberry_parser.spec.js         |  64 ++---
 spec/metadata/firefoxos_parser.spec.js          |  30 +-
 spec/metadata/ios_parser.spec.js                |  51 +---
 spec/metadata/windows8_parser.spec.js           |  73 +----
 spec/metadata/wp7_parser.spec.js                |  69 ++---
 spec/metadata/wp8_parser.spec.js                |  69 ++---
 spec/platform.spec.js                           |  19 +-
 spec/prepare.spec.js                            | 180 ++++++++----
 src/ConfigParser.js                             |  98 +++++++
 src/config_parser.js                            | 225 ---------------
 src/create.js                                   |   8 +-
 src/metadata/amazon_fireos_parser.js            |   6 +-
 src/metadata/android_parser.js                  |  17 +-
 src/metadata/blackberry10_parser.js             |  12 +-
 src/metadata/firefoxos_parser.js                |   6 +-
 src/metadata/ios_parser.js                      |   7 +-
 src/metadata/ubuntu_parser.js                   |  26 +-
 src/metadata/windows8_parser.js                 |  11 +-
 src/metadata/wp7_parser.js                      |  10 +-
 src/metadata/wp8_parser.js                      |  10 +-
 src/platform.js                                 |   3 +-
 src/prepare.js                                  |  80 +++++-
 src/serve.js                                    |   4 +-
 src/util.js                                     |   1 -
 43 files changed, 622 insertions(+), 977 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/create.spec.js
----------------------------------------------------------------------
diff --git a/e2e/create.spec.js b/e2e/create.spec.js
index c149694..bfb063f 100644
--- a/e2e/create.spec.js
+++ b/e2e/create.spec.js
@@ -25,6 +25,7 @@ var helpers = require('./helpers'),
     config = require('../src/config'),
     events = require('../src/events'),
     util = require('../src/util'),
+    ConfigParser = require('../src/ConfigParser'),
     cordova = require('../cordova');
 
 // A utility function to generate all combinations of elements from 2 arrays.
@@ -88,7 +89,7 @@ describe('create end-to-end', function() {
         expect(path.join(project, 'www', 'index.html')).toExist();
 
         // Check that www/config.xml was updated.
-        var configXml = new util.config_parser(path.join(project, 'www', 'config.xml'));
+        var configXml = new ConfigParser(path.join(project, 'www', 'config.xml'));
         expect(configXml.packageName()).toEqual(appId);
 
         // TODO (kamrik): check somehow that we got the right config.xml from the fixture and not some place else.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/hooks_bat/fail/fail.bat
----------------------------------------------------------------------
diff --git a/e2e/fixtures/hooks_bat/fail/fail.bat b/e2e/fixtures/hooks_bat/fail/fail.bat
index 0c810b7..a89b4c8 100644
--- a/e2e/fixtures/hooks_bat/fail/fail.bat
+++ b/e2e/fixtures/hooks_bat/fail/fail.bat
@@ -1,2 +1,2 @@
 @ECHO OFF
-EXIT /B 1
\ No newline at end of file
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/hooks_bat/test/07.bat
----------------------------------------------------------------------
diff --git a/e2e/fixtures/hooks_bat/test/07.bat b/e2e/fixtures/hooks_bat/test/07.bat
index 97caf28..6414880 100644
--- a/e2e/fixtures/hooks_bat/test/07.bat
+++ b/e2e/fixtures/hooks_bat/test/07.bat
@@ -1,3 +1,3 @@
 @ECHO OFF
 ECHO this is script 0 in %~dp0
-ECHO b >> hooks_order.txt
\ No newline at end of file
+ECHO b >> hooks_order.txt

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/assets/www/cordova.js b/e2e/fixtures/platforms/android/assets/www/cordova.js
index 391eb8c..07e3feb 100644
--- a/e2e/fixtures/platforms/android/assets/www/cordova.js
+++ b/e2e/fixtures/platforms/android/assets/www/cordova.js
@@ -1709,4 +1709,4 @@ window.cordova = require('cordova');
 
 require('cordova/init');
 
-})();
\ No newline at end of file
+})();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js b/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js
index fbe1f44..b58b5dd 100644
--- a/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js
+++ b/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js
@@ -1,3 +1,3 @@
 cordova.define('cordova/plugin_list', function(require, exports, module) {
 module.exports = []
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/build
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/build b/e2e/fixtures/platforms/android/cordova/build
index 752945f..7028eb8 100755
--- a/e2e/fixtures/platforms/android/cordova/build
+++ b/e2e/fixtures/platforms/android/cordova/build
@@ -32,4 +32,4 @@ if(args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
     process.exit(0);
 } else {
     process.exit(2);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/clean
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/clean b/e2e/fixtures/platforms/android/cordova/clean
index 6b72e71..70c4ca8 100755
--- a/e2e/fixtures/platforms/android/cordova/clean
+++ b/e2e/fixtures/platforms/android/cordova/clean
@@ -31,4 +31,4 @@ if(args.length > 2) {
     process.exit(0);
 } else {
     process.exit(2);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/install-device
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/install-device b/e2e/fixtures/platforms/android/cordova/lib/install-device
index cf53918..679efbf 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/install-device
+++ b/e2e/fixtures/platforms/android/cordova/lib/install-device
@@ -35,4 +35,4 @@ if(args.length > 2) {
 } else {
     device.install();
     process.exit(0);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/install-emulator
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/install-emulator b/e2e/fixtures/platforms/android/cordova/lib/install-emulator
index 70421be..c006eb2 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/install-emulator
+++ b/e2e/fixtures/platforms/android/cordova/lib/install-emulator
@@ -35,4 +35,4 @@ if(args.length > 2) {
 } else {
     emulator.install();
     process.exit(0);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/list-devices
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-devices b/e2e/fixtures/platforms/android/cordova/lib/list-devices
index bdd0abd..3ef4efa 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/list-devices
+++ b/e2e/fixtures/platforms/android/cordova/lib/list-devices
@@ -25,4 +25,4 @@ var devices = require('./device');
 var device_list = devices.list();
 for(device in device_list) {
     console.log(device_list[device]);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images b/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images
index 69f4789..3230537 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images
+++ b/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images
@@ -26,4 +26,4 @@ var emulator_list = emulators.list_images();
 for(emulator in emulator_list) {
     console.log(emulator_list[emulator].name);
     process.exit(0);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators b/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators
index 3e69b2f..525a64c 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators
+++ b/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators
@@ -26,4 +26,4 @@ var emulator_list = emulators.list_started();
 for(emulator in emulator_list) {
     console.log(emulator_list[emulator]);
     process.exit(0);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/lib/start-emulator
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/lib/start-emulator b/e2e/fixtures/platforms/android/cordova/lib/start-emulator
index 8ea6d3f..5d6c4dd 100755
--- a/e2e/fixtures/platforms/android/cordova/lib/start-emulator
+++ b/e2e/fixtures/platforms/android/cordova/lib/start-emulator
@@ -35,4 +35,4 @@ if(args.length > 2) {
 } else {
     emulator.start();
     process.exit(0);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/log
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/log b/e2e/fixtures/platforms/android/cordova/log
index 514f69c..087325f 100755
--- a/e2e/fixtures/platforms/android/cordova/log
+++ b/e2e/fixtures/platforms/android/cordova/log
@@ -30,4 +30,4 @@ if(args.length > 2) {
     log.run();
 } else {
     process.exit(2);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/e2e/fixtures/platforms/android/cordova/run
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android/cordova/run b/e2e/fixtures/platforms/android/cordova/run
index c3a5772..57d7345 100755
--- a/e2e/fixtures/platforms/android/cordova/run
+++ b/e2e/fixtures/platforms/android/cordova/run
@@ -32,4 +32,4 @@ if (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
     process.exit(0);
 } else {
     process.exit(2);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigParser.spec.js b/spec/ConfigParser.spec.js
new file mode 100644
index 0000000..da05ef8
--- /dev/null
+++ b/spec/ConfigParser.spec.js
@@ -0,0 +1,76 @@
+/**
+    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.
+*/
+var path = require('path'),
+    fs = require('fs'),
+    ConfigParser = require('../src/ConfigParser'),
+    xml = path.join(__dirname, 'test-config.xml'),
+    xml_contents = fs.readFileSync(xml, 'utf-8');
+
+describe('config.xml parser', function () {
+    var readFile;
+    beforeEach(function() {
+        readFile = spyOn(fs, 'readFileSync').andReturn(xml_contents);
+    });
+
+    it('should create an instance based on an xml file', function() {
+        var cfg;
+        expect(function () {
+            cfg = new ConfigParser(xml);
+        }).not.toThrow();
+        expect(cfg).toBeDefined();
+        expect(cfg.doc).toBeDefined();
+    });
+
+    describe('methods', function() {
+        var cfg;
+        beforeEach(function() {
+            cfg = new ConfigParser(xml);
+        });
+
+        describe('package name / id', function() {
+            it('should get the (default) packagename', function() {
+                expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
+            });
+            it('should allow setting the packagename', function() {
+                cfg.setPackageName('this.is.bat.country');
+                expect(cfg.packageName()).toEqual('this.is.bat.country');
+            });
+        });
+
+        describe('version', function() {
+            it('should get the version', function() {
+                expect(cfg.version()).toEqual('0.0.1');
+            });
+            it('should allow setting the version', function() {
+                cfg.setVersion('2.0.1');
+                expect(cfg.version()).toEqual('2.0.1');
+            });
+        });
+
+        describe('app name', function() {
+            it('should get the (default) app name', function() {
+                expect(cfg.name()).toEqual('Hello Cordova');
+            });
+            it('should allow setting the app name', function() {
+                cfg.setName('this.is.bat.country');
+                expect(cfg.name()).toEqual('this.is.bat.country');
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
deleted file mode 100644
index 4e3b5d4..0000000
--- a/spec/config_parser.spec.js
+++ /dev/null
@@ -1,280 +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.
-*/
-var path = require('path'),
-    fs = require('fs'),
-    shell = require('shelljs'),
-    config_parser = require('../src/config_parser'),
-    et = require('elementtree'),
-    xml = path.join(__dirname, 'test-config.xml'),
-    util = require('../src/util'),
-    xml_contents = fs.readFileSync(xml, 'utf-8');
-
-describe('config.xml parser', function () {
-    var readFile, update;
-    beforeEach(function() {
-        readFile = spyOn(fs, 'readFileSync').andReturn(xml_contents);
-        update = spyOn(config_parser.prototype, 'update');
-    });
-
-    it('should create an instance based on an xml file', function() {
-        var cfg;
-        expect(function () {
-            cfg = new config_parser(xml);
-        }).not.toThrow();
-        expect(cfg).toBeDefined();
-        expect(cfg.doc).toBeDefined();
-    });
-
-    describe('methods', function() {
-        var cfg;
-        beforeEach(function() {
-            cfg = new config_parser(xml);
-        });
-
-        describe('merge_with', function () {
-            it("should merge attributes and text of the root element without clobbering", function () {
-                var testXML = new et.ElementTree(et.XML("<widget foo='bar' id='NOTANID'>TEXT</widget>"));
-                cfg.merge_with({doc: testXML});
-                expect(cfg.doc.getroot().attrib.foo).toEqual("bar");
-                expect(cfg.doc.getroot().attrib.id).not.toEqual("NOTANID");
-                expect(cfg.doc.getroot().text).not.toEqual("TEXT");
-            });
-
-            it("should merge attributes and text of the root element with clobbering", function () {
-                var testXML = new et.ElementTree(et.XML("<widget foo='bar' id='NOTANID'>TEXT</widget>"));
-                cfg.merge_with({doc: testXML}, "foo", true);
-                expect(cfg.doc.getroot().attrib.foo).toEqual("bar");
-                expect(cfg.doc.getroot().attrib.id).toEqual("NOTANID");
-                expect(cfg.doc.getroot().text).toEqual("TEXT");
-            });
-
-            it("should not merge platform tags with the wrong platform", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><platform name='bar'><testElement testAttrib='value'>testTEXT</testElement></platform></widget>")),
-                    origCfg = et.tostring(cfg.doc.getroot());
-
-                cfg.merge_with({doc: testXML}, "foo", true);
-                expect(et.tostring(cfg.doc.getroot())).toEqual(origCfg);
-            });
-
-            it("should merge platform tags with the correct platform", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><platform name='bar'><testElement testAttrib='value'>testTEXT</testElement></platform></widget>")),
-                    origCfg = et.tostring(cfg.doc.getroot()),
-                    testElement;
-
-                cfg.merge_with({doc: testXML}, "bar", true);
-                expect(et.tostring(cfg.doc.getroot())).not.toEqual(origCfg);
-                testElement = cfg.doc.getroot().find("testElement");
-                expect(testElement).toBeDefined();
-                expect(testElement.attrib.testAttrib).toEqual("value");
-                expect(testElement.text).toEqual("testTEXT");
-            });
-
-            it("should merge singelton children without clobber", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><author testAttrib='value' href='http://www.nowhere.com'>SUPER_AUTHOR</author></widget>")),
-                    testElements;
-
-                cfg.merge_with({doc: testXML});
-                testElements = cfg.doc.getroot().findall("author");
-                expect(testElements).toBeDefined();
-                expect(testElements.length).toEqual(1);
-                expect(testElements[0].attrib.testAttrib).toEqual("value");
-                expect(testElements[0].attrib.href).toEqual("http://cordova.io");
-                expect(testElements[0].attrib.email).toEqual("dev@cordova.apache.org");
-                expect(testElements[0].text).toContain("Apache Cordova Team");
-            });
-
-            it("should clobber singelton children with clobber", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><author testAttrib='value' href='http://www.nowhere.com'>SUPER_AUTHOR</author></widget>")),
-                    testElements;
-
-                cfg.merge_with({doc: testXML}, "", true);
-                testElements = cfg.doc.getroot().findall("author");
-                expect(testElements).toBeDefined();
-                expect(testElements.length).toEqual(1);
-                expect(testElements[0].attrib.testAttrib).toEqual("value");
-                expect(testElements[0].attrib.href).toEqual("http://www.nowhere.com");
-                expect(testElements[0].attrib.email).toEqual("dev@cordova.apache.org");
-                expect(testElements[0].text).toEqual("SUPER_AUTHOR");
-            });
-
-            it("should append non singelton children", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><preference num='1'/> <preference num='2'/></widget>")),
-                    testElements;
-
-                cfg.merge_with({doc: testXML}, "", true);
-                testElements = cfg.doc.getroot().findall("preference");
-                expect(testElements.length).toEqual(4);
-            });
-
-            it("should handle namespaced elements", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><foo:bar testAttrib='value'>testText</foo:bar></widget>")),
-                    testElement;
-
-                cfg.merge_with({doc: testXML}, "foo", true);
-                testElement = cfg.doc.getroot().find("foo:bar");
-                expect(testElement).toBeDefined();
-                expect(testElement.attrib.testAttrib).toEqual("value");
-                expect(testElement.text).toEqual("testText");
-            });
-
-            it("should not append duplicate non singelton children", function () {
-                var testXML = new et.ElementTree(et.XML("<widget><preference name='fullscreen' value='true'/></widget>")),
-                    testElements;
-
-                cfg.merge_with({doc: testXML}, "", true);
-                testElements = cfg.doc.getroot().findall("preference");
-                expect(testElements.length).toEqual(2);
-            });
-        });
-
-        describe('package name / id', function() {
-            it('should get the (default) packagename', function() {
-                expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
-            });
-            it('should allow setting the packagename', function() {
-                cfg.packageName('this.is.bat.country');
-                expect(cfg.packageName()).toEqual('this.is.bat.country');
-            });
-            it('should write to disk after setting the packagename', function() {
-                cfg.packageName('this.is.bat.country');
-                expect(update).toHaveBeenCalled();
-            });
-        });
-
-        describe('version', function() {
-            it('should get the version', function() {
-                expect(cfg.version()).toEqual('0.0.1');
-            });
-            it('should allow setting the version', function() {
-                cfg.version('2.0.1');
-                expect(cfg.version()).toEqual('2.0.1');
-            });
-            it('should write to disk after setting the version', function() {
-                cfg.version('2.0.1');
-                expect(update).toHaveBeenCalled();
-            });
-        });
-
-        describe('content', function() {
-            it('should get the content src attribute', function() {
-                expect(cfg.content()).toEqual('index.html');
-            });
-            it('should allow setting the content src attribute', function() {
-                cfg.content('main.html');
-                expect(cfg.content()).toEqual('main.html');
-            });
-            it('should write to disk after setting the content', function() {
-                cfg.content('batman.html');
-                expect(update).toHaveBeenCalled();
-            });
-            it('should not error out if there is no content element', function () {
-                readFile.andCallThrough();
-                var no_content_xml = path.join(__dirname, "fixtures", "templates", "no_content_config.xml"),
-                    no_content_xml_contents = fs.readFileSync(no_content_xml, "utf-8");
-                readFile.andReturn(no_content_xml_contents);
-                var no_content_cfg = new config_parser(no_content_xml);
-                expect(no_content_cfg.content()).toEqual('index.html');
-            });
-        });
-
-        describe('app name', function() {
-            it('should get the (default) app name', function() {
-                expect(cfg.name()).toEqual('Hello Cordova');
-            });
-            it('should allow setting the app name', function() {
-                cfg.name('this.is.bat.country');
-                expect(cfg.name()).toEqual('this.is.bat.country');
-            });
-            it('should write to disk after setting the name', function() {
-                cfg.name('one toke over the line');
-                expect(update).toHaveBeenCalled();
-            });
-        });
-
-        describe('access elements (whitelist)', function() {
-            describe('getter', function() {
-                it('should get the (default) access element', function() {
-                    expect(cfg.access.get()[0]).toEqual('*');
-                });
-                it('should return an array of all access origin uris via access()', function() {
-                    expect(cfg.access.get() instanceof Array).toBe(true);
-                });
-            });
-            describe('setters', function() {
-                it('should allow removing a uri from the access list', function() {
-                    cfg.access.remove('*');
-                    expect(cfg.access.get().length).toEqual(0);
-                });
-                it('should write to disk after removing a uri', function() {
-                    cfg.access.remove('*');
-                    expect(update).toHaveBeenCalled();
-                });
-                it('should allow adding a new uri to the access list', function() {
-                    cfg.access.add('http://canucks.com');
-                    expect(cfg.access.get().length).toEqual(2);
-                    expect(cfg.access.get().indexOf('http://canucks.com') > -1).toBe(true);
-                });
-                it('should write to disk after adding a uri', function() {
-                    cfg.access.add('http://cordova.io');
-                    expect(update).toHaveBeenCalled();
-                });
-                it('should allow removing all access elements when no parameter is specified', function() {
-                    cfg.access.add('http://cordova.io');
-                    cfg.access.remove();
-                    expect(cfg.access.get().length).toEqual(0);
-                });
-            });
-        });
-
-        describe('preference elements', function() {
-            describe('getter', function() {
-                it('should get all preference elements', function() {
-                    expect(cfg.preference.get()[0].name).toEqual('fullscreen');
-                    expect(cfg.preference.get()[0].value).toEqual('true');
-                });
-                it('should return an array of all preference name/value pairs', function() {
-                    expect(cfg.preference.get() instanceof Array).toBe(true);
-                });
-            });
-            describe('setters', function() {
-                it('should allow removing a preference by name', function() {
-                    cfg.preference.remove('fullscreen');
-                    expect(cfg.preference.get().length).toEqual(1);
-                });
-                it('should write to disk after removing a preference', function() {
-                    cfg.preference.remove('phonegap-version');
-                    expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(/<preference\sname="phonegap-version"/);
-                });
-                it('should allow adding a new preference', function() {
-                    cfg.preference.add({name:'UIWebViewBounce',value:'false'});
-                    expect(cfg.preference.get().length).toEqual(3);
-                    expect(cfg.preference.get()[2].value).toEqual('false');
-                });
-                it('should write to disk after adding a preference', function() {
-                    cfg.preference.add({name:'UIWebViewBounce',value:'false'});
-                    expect(update).toHaveBeenCalled();
-                });
-                it('should allow removing all preference elements when no parameter is specified', function() {
-                    cfg.preference.remove();
-                    expect(cfg.preference.get().length).toEqual(0);
-                });
-            });
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index a0eb0e7..0b68d14 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -20,14 +20,35 @@ var cordova = require('../cordova'),
     path    = require('path'),
     shell   = require('shelljs'),
     fs      = require('fs'),
+    et = require('elementtree'),
+    ConfigParser = require('../src/ConfigParser'),
     util    = require('../src/util'),
     config    = require('../src/config'),
     lazy_load = require('../src/lazy_load'),
+    xmlHelpers = require('../src/xml-helpers'),
     Q = require('q'),
     tempDir = path.join(__dirname, '..', 'temp');
 
+var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
+    '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+    '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+    '        id        = "io.cordova.hellocordova"\n' +
+    '        version   = "0.0.1">\n' +
+    '    <name>Hello Cordova</name>\n' +
+    '    <description>\n' +
+    '        A sample Apache Cordova application that responds to the deviceready event.\n' +
+    '    </description>\n' +
+    '    <author href="http://cordova.io" email="dev@cordova.apache.org">\n' +
+    '        Apache Cordova Team\n' +
+    '    </author>\n' +
+    '    <content src="index.html" />\n' +
+    '    <access origin="*" />\n' +
+    '    <preference name="fullscreen" value="true" />\n' +
+    '    <preference name="webviewbounce" value="true" />\n' +
+    '</widget>\n';
+
 describe('create command', function () {
-    var mkdir, cp, config_spy, load_cordova, load_custom, exists, config_read, config_write, parser, package, name;
+    var mkdir, cp, config_spy, load_cordova, load_custom, exists, config_read, config_write;
     beforeEach(function() {
         shell.rm('-rf', tempDir);
         mkdir = spyOn(shell, 'mkdir');
@@ -38,11 +59,9 @@ describe('create command', function () {
         exists = spyOn(fs, 'existsSync').andReturn(false);
         load_cordova = spyOn(lazy_load, 'cordova').andReturn(Q(path.join('lib','dir')));
         load_custom = spyOn(lazy_load, 'custom').andReturn(Q(path.join('lib','dir')));
-        package = jasmine.createSpy('config.packageName');
-        name = jasmine.createSpy('config.name');
-        parser = spyOn(util, 'config_parser').andReturn({
-            packageName:package,
-            name:name
+        spyOn(ConfigParser.prototype, 'write');
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function() {
+            return new et.ElementTree(et.XML(TEST_XML));
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js
index 98ae906..498c018 100644
--- a/spec/metadata/android_parser.spec.js
+++ b/spec/metadata/android_parser.spec.js
@@ -21,21 +21,34 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     fs = require('fs'),
-    ET = require('elementtree'),
+    et = require('elementtree'),
+    xmlHelpers = require('../../src/xml-helpers'),
     Q = require('q'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
 // Create a real config object before mocking out everything.
-var cfg = new config_parser(path.join(__dirname, '..', 'test-config.xml'));
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
+
+var STRINGS_XML = '<resources> <string name="app_name">mobilespec</string> </resources>';
+var MANIFEST_XML = '<manifest android:versionCode="1" android:versionName="0.0.1" package="org.apache.mobilespec">\n' +
+    '<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">\n' +
+    '    <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="mobilespec" android:screenOrientation="VAL">\n' +
+    '        <intent-filter>\n' +
+    '            <action android:name="android.intent.action.MAIN" />\n' +
+    '            <category android:name="android.intent.category.LAUNCHER" />\n' +
+    '        </intent-filter>\n' +
+    '    </activity>\n' +
+    '</application>\n' +
+    '</manifest>\n';
 
 describe('android project parser', function() {
     var proj = path.join('some', 'path');
-    var exists, custom;
+    var exists;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
-        custom = spyOn(config, 'has_custom_path').andReturn(false);
+        spyOn(config, 'has_custom_path').andReturn(false);
     });
 
     function wrapper(p, done, post) {
@@ -71,7 +84,11 @@ describe('android project parser', function() {
     describe('instance', function() {
         var p, cp, rm, mkdir, is_cordova, write, read;
         var android_proj = path.join(proj, 'platforms', 'android');
+        var stringsRoot;
+        var manifestRoot;
         beforeEach(function() {
+            stringsRoot = null;
+            manifestRoot = null;
             p = new platforms.android.parser(android_proj);
             cp = spyOn(shell, 'cp');
             rm = spyOn(shell, 'rm');
@@ -79,92 +96,55 @@ describe('android project parser', function() {
             write = spyOn(fs, 'writeFileSync');
             read = spyOn(fs, 'readFileSync');
             mkdir = spyOn(shell, 'mkdir');
+            spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) {
+                if (/strings/.exec(path)) {
+                    return stringsRoot = new et.ElementTree(et.XML(STRINGS_XML));
+                } else if (/AndroidManifest/.exec(path)) {
+                    return manifestRoot = new et.ElementTree(et.XML(MANIFEST_XML));
+                }
+            });
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, readdir, cfg_parser, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
-            var activity_obj;
             beforeEach(function() {
-                find_obj = {
-                    text:'hi'
-                };
-                activity_obj = { attrib: {'android:screenOrientation':'VAL'} };
-                root_obj = {
-                    attrib:{
-                        package:'android_pkg'
-                    },
-                    find: function(n) {
-                        if (n == './application/activity') { return activity_obj };
-                        throw new Error('unexpected call to mocked find()');
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
-                readdir = spyOn(fs, 'readdirSync').andReturn([path.join(proj, 'src', 'android_pkg', 'MyApp.java')]);
+                spyOn(fs, 'readdirSync').andReturn([path.join(proj, 'src', 'android_pkg', 'MyApp.java')]);
                 cfg.name = function() { return 'testname' };
                 cfg.packageName = function() { return 'testpkg' };
                 cfg.version = function() { return 'one point oh' };
-                cfg.access.get = function() { return [] };
-                cfg.preference.get = function() { return [] };
-                cfg.content = function() { return 'index.html' };
                 read.andReturn('package org.cordova.somepackage; public class MyApp extends CordovaActivity { }');
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                cfg_parser = spyOn(util, 'config_parser').andReturn({
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    },
-                    content:cfg_content
-                });
             });
 
             it('should handle no orientation', function() {
+                cfg.getPreference = function() { return null; };
                 p.update_from_config(cfg);
-                expect(activity_obj.attrib['android:screenOrientation']).toEqual('VAL');
+                expect(manifestRoot.getroot().find('./application/activity').attrib['android:screenOrientation']).toEqual('VAL');
             });
             it('should handle default orientation', function() {
-                cfg.preference.get = function() { return [{name:'Orientation', value:'Portrait'},{name:'Orientation', value:'Default'}] };
+                cfg.getPreference = function() { return 'default'; };
                 p.update_from_config(cfg);
-                expect(activity_obj.attrib['android:screenOrientation']).toBeUndefined();
+                expect(manifestRoot.getroot().find('./application/activity').attrib['android:screenOrientation']).toBeUndefined();
             });
             it('should handle portrait orientation', function() {
-                cfg.preference.get = function() { return [{name:'Orientation', value:'Portrait'}] };
+                cfg.getPreference = function() { return 'portrait'; };
                 p.update_from_config(cfg);
-                expect(activity_obj.attrib['android:screenOrientation']).toEqual('userPortrait');
+                expect(manifestRoot.getroot().find('./application/activity').attrib['android:screenOrientation']).toEqual('userPortrait');
             });
             it('should handle invalid orientation', function() {
-                cfg.preference.get = function() { return [{name:'Orientation', value:'Prtrait'}] };
+                cfg.getPreference = function() { return 'prtrait'; };
                 p.update_from_config(cfg);
-                expect(activity_obj.attrib['android:screenOrientation']).toEqual('VAL');
+                expect(manifestRoot.getroot().find('./application/activity').attrib['android:screenOrientation']).toEqual('VAL');
             });
             it('should write out the app name to strings.xml', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.text).toEqual('testname');
+                expect(stringsRoot.getroot().find('string').text).toEqual('testname');
             });
             it('should write out the app id to androidmanifest.xml and update the cordova-android entry Java class', function() {
                 p.update_from_config(cfg);
-                expect(root_obj.attrib.package).toEqual('testpkg');
+                expect(manifestRoot.getroot().attrib.package).toEqual('testpkg');
             });
             it('should write out the app version to androidmanifest.xml', function() {
                 p.update_from_config(cfg);
-                expect(root_obj.attrib['android:versionName']).toEqual('one point oh');
+                expect(manifestRoot.getroot().attrib['android:versionName']).toEqual('one point oh');
             });
         });
         describe('www_dir method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js
index 6a47ef6..6927929 100644
--- a/spec/metadata/blackberry_parser.spec.js
+++ b/spec/metadata/blackberry_parser.spec.js
@@ -22,23 +22,47 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     fs = require('fs'),
-    ET = require('elementtree'),
+    et = require('elementtree'),
+    xmlHelpers = require('../../src/xml-helpers'),
     Q = require('q'),
     child_process = require('child_process'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
+
+var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
+    '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+    '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+    '        id        = "io.cordova.hellocordova"\n' +
+    '        version   = "0.0.1">\n' +
+    '    <name>Hello Cordova</name>\n' +
+    '    <description>\n' +
+    '        A sample Apache Cordova application that responds to the deviceready event.\n' +
+    '    </description>\n' +
+    '    <author href="http://cordova.io" email="dev@cordova.apache.org">\n' +
+    '        Apache Cordova Team\n' +
+    '    </author>\n' +
+    '    <content src="index.html" />\n' +
+    '    <access origin="*" />\n' +
+    '    <preference name="fullscreen" value="true" />\n' +
+    '    <preference name="webviewbounce" value="true" />\n' +
+    '</widget>\n';
+
 describe('blackberry10 project parser', function() {
     var proj = '/some/path';
-    var exists, custom, config_p, sh;
+    var exists, custom, sh;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
         custom = spyOn(config, 'has_custom_path').andReturn(false);
-        config_p = spyOn(util, 'config_parser');
         sh = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
             (cb || opts)(0, '', '');
         });
+        spyOn(ConfigParser.prototype, 'write');
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function() {
+            return new et.ElementTree(et.XML(TEST_XML));
+        });
     });
 
     function wrapper(p, done, post) {
@@ -98,7 +122,6 @@ describe('blackberry10 project parser', function() {
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, cfg, find_obj, root_obj;
             var xml_name, xml_pkg, xml_version, xml_access_rm, xml_update, xml_append, xml_content;
             beforeEach(function() {
                 xml_content = jasmine.createSpy('xml content');
@@ -127,32 +150,9 @@ describe('blackberry10 project parser', function() {
                     add: xml_preference_add,
                     remove: xml_preference_remove
                 };
-                find_obj = {
-                    text:'hi'
-                };
-                root_obj = {
-                    attrib:{
-                        package:'bb_pkg'
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
-                cfg = new config_parser();
                 cfg.name = function() { return 'testname'; };
-                cfg.content = function() { return 'index.html'; };
                 cfg.packageName = function() { return 'testpkg'; };
                 cfg.version = function() { return 'one point oh'; };
-                cfg.access = {};
-                cfg.access.getAttributes = function() { return []; };
-                cfg.access.remove = function() { };
-                cfg.preference.get = function() { return []; };
             });
         });
         describe('www_dir method', function() {
@@ -171,19 +171,11 @@ describe('blackberry10 project parser', function() {
             });
         });
         describe('update_www method', function() {
-            var backup_cfg_parser;
-            beforeEach(function () {
-                backup_cfg_parser = {
-                    update: jasmine.createSpy("backup_cfg_parser update")
-                };
-                config_p.andReturn(backup_cfg_parser);
-            });
 
             it('should rm project-level www and cp in platform agnostic www', function() {
                 p.update_www();
                 expect(rm).toHaveBeenCalled();
                 expect(cp).toHaveBeenCalled();
-                expect(backup_cfg_parser.update).toHaveBeenCalled();
             });
         });
         describe('update_overrides method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/firefoxos_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/firefoxos_parser.spec.js b/spec/metadata/firefoxos_parser.spec.js
index 5d20579..49694eb 100644
--- a/spec/metadata/firefoxos_parser.spec.js
+++ b/spec/metadata/firefoxos_parser.spec.js
@@ -21,21 +21,20 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     fs = require('fs'),
-    ET = require('elementtree'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
 describe('firefoxos project parser', function() {
     var proj = path.join('some', 'path');
-    var exists, exec, custom, cfg_parser;
+    var exists, exec, custom;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
         exec = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
             cb(0, '');
         });
         custom = spyOn(config, 'has_custom_path').andReturn(false);
-        cfg_parser = spyOn(util, 'config_parser');
     });
 
     describe('constructions', function() {
@@ -60,33 +59,10 @@ describe('firefoxos project parser', function() {
         });
 
         describe('update_from_config method', function() {
-            var cfg, cfg_access_add, cfg_access_rm,
-                cfg_pref_rm, cfg_pref_add, cfg_content;
-
             beforeEach(function() {
-                cfg = new config_parser();
                 cfg.name = function() { return 'testname'; };
                 cfg.packageName = function() { return 'testpkg'; };
                 cfg.version = function() { return '1.0'; };
-
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                cfg_parser = spyOn(util, 'config_parser').andReturn({
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    },
-                    content:cfg_content
-                });
             });
 
           /*  it('should write manifest.webapp', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/ios_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/ios_parser.spec.js b/spec/metadata/ios_parser.spec.js
index 40daf3d..54b912c 100644
--- a/spec/metadata/ios_parser.spec.js
+++ b/spec/metadata/ios_parser.spec.js
@@ -22,23 +22,22 @@ var platforms = require('../../platforms'),
     shell = require('shelljs'),
     plist = require('plist-with-patches'),
     xcode = require('xcode'),
-    ET = require('elementtree'),
+    et = require('elementtree'),
     fs = require('fs'),
     Q = require('q'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
 // Create a real config object before mocking out everything.
-var cfg = new config_parser(path.join(__dirname, '..', 'test-config.xml'));
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
 
 describe('ios project parser', function () {
     var proj = path.join('some', 'path');
-    var custom, readdir, cfg_parser;
+    var custom, readdir;
     beforeEach(function() {
         custom = spyOn(config, 'has_custom_path').andReturn(false);
         readdir = spyOn(fs, 'readdirSync').andReturn(['test.xcodeproj']);
-        cfg_parser = spyOn(util, 'config_parser');
     });
 
     function wrapper(p, done, post) {
@@ -84,29 +83,12 @@ describe('ios project parser', function () {
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, mv;
-            var find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
+            var mv;
+            var cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
             var plist_parse, plist_build, xc;
             var update_name, xc_write;
             beforeEach(function() {
                 mv = spyOn(shell, 'mv');
-                find_obj = {
-                    text:'hi'
-                };
-                root_obj = {
-                    attrib:{
-                        package:'android_pkg'
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
                 plist_parse = spyOn(plist, 'parseFileSync').andReturn({
                 });
                 plist_build = spyOn(plist, 'build').andReturn('');
@@ -120,27 +102,6 @@ describe('ios project parser', function () {
                 cfg.name = function() { return 'testname' };
                 cfg.packageName = function() { return 'testpkg' };
                 cfg.version = function() { return 'one point oh' };
-                cfg.access.get = function() { return [] };
-                cfg.preference.get = function() { return [] };
-                cfg.content = function() { return 'index.html'; };
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                cfg_parser.andReturn({
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    },
-                    content:cfg_content
-                });
                 p = new platforms.ios.parser(ios_proj);
             });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/windows8_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/windows8_parser.spec.js b/spec/metadata/windows8_parser.spec.js
index 5bbcda7..6f56b78 100644
--- a/spec/metadata/windows8_parser.spec.js
+++ b/spec/metadata/windows8_parser.spec.js
@@ -22,20 +22,22 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     child_process = require('child_process'),
+    xmlHelpers = require('../../src/xml-helpers'),
+    et = require('elementtree'),
     Q = require('q'),
     fs = require('fs'),
-    ET = require('elementtree'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
 // Create a real config object before mocking out everything.
-var cfg = new config_parser(path.join(__dirname, '..', 'test-config.xml'));
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
 
 describe('windows8 project parser', function() {
 
     var proj = '/some/path';
     var exists, exec, custom, readdir, cfg_parser;
+    var winXml;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
         exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
@@ -44,7 +46,10 @@ describe('windows8 project parser', function() {
         });
         custom = spyOn(config, 'has_custom_path').andReturn(false);
         readdir = spyOn(fs, 'readdirSync').andReturn(['test.jsproj']);
-        cfg_parser = spyOn(util, 'config_parser');
+        winXml = null;
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) {
+            return winXml = new et.ElementTree(et.XML('<foo><Application/><Identity/><VisualElements><a/></VisualElements><Capabilities><a/></Capabilities></foo>'));
+        });
     });
 
     function wrapper(promise, done, post) {
@@ -117,77 +122,25 @@ describe('windows8 project parser', function() {
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
             beforeEach(function() {
-                find_obj = {
-                    text:'.//Application',
-                    attrib:{
-                        Id:'old',
-                        Version:'0.0.0.0'
-                    },
-                    VisualElements:{
-                        attrib:{
-                            DisplayName:"old"
-                        }
-                    }
-                };
-                root_obj = {
-                    attrib:{
-                        package:'windows8_pkg'
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
                 cfg.name = function() { return 'testname' };
                 cfg.content = function() { return 'index.html' };
                 cfg.packageName = function() { return 'testpkg' };
                 cfg.version = function() { return 'one point oh' };
-                cfg.access.get = function() { return [] };
-                cfg.preference.get = function() { return [] };
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                parser.config = {
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    content:cfg_content,
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    }
-                };
                 readdir.andReturn(['test.sln']);
             });
 
             it('should write out the app name to package.appxmanifest', function() {
                 parser.update_from_config(cfg);
-                expect(find_obj.attrib.Name).toEqual(cfg.packageName());
-                expect(find_obj.attrib.DisplayName).toEqual(cfg.name());
+                var identityNode = winXml.getroot().find('.//Identity');
+                expect(identityNode.attrib.Name).toEqual(cfg.packageName());
             });
 
             it('should write out the app version to package.appxmanifest', function() {
                 parser.update_from_config(cfg);
-                expect(find_obj.attrib.Version).toEqual('one point oh');
-            });
-
-            it('should update the content element (start page)', function() {
-                parser.update_from_config(cfg);
-                expect(cfg_content).toHaveBeenCalledWith('index.html');
+                var identityNode = winXml.getroot().find('.//Identity');
+                expect(identityNode.attrib.Version).toEqual('one point oh');
             });
-
         });
 
         describe('www_dir method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/wp7_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp7_parser.spec.js b/spec/metadata/wp7_parser.spec.js
index f67a8bd..03fda18 100644
--- a/spec/metadata/wp7_parser.spec.js
+++ b/spec/metadata/wp7_parser.spec.js
@@ -22,19 +22,21 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     fs = require('fs'),
-    ET = require('elementtree'),
+    et = require('elementtree'),
+    xmlHelpers = require('../../src/xml-helpers'),
     Q = require('q'),
     child_process = require('child_process'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
 // Create a real config object before mocking out everything.
-var cfg = new config_parser(path.join(__dirname, '..', 'test-config.xml'));
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
 
 describe('wp7 project parser', function() {
     var proj = '/some/path';
     var exists, exec, custom, readdir, cfg_parser;
+    var projXml, manifestXml;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
         exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
@@ -42,7 +44,18 @@ describe('wp7 project parser', function() {
         });
         custom = spyOn(config, 'has_custom_path').andReturn(false);
         readdir = spyOn(fs, 'readdirSync').andReturn(['test.csproj']);
-        cfg_parser = spyOn(util, 'config_parser');
+        projXml = manifestXml = null;
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) {
+            if (/WMAppManifest.xml$/.exec(path)) {
+                return manifestXml = new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else if (/csproj$/.exec(path)) {
+                return projXml = new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else if (/xaml$/.exec(path)) {
+                return new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else {
+                throw new Error('Unexpected parseElementtreeSync: ' + path);
+            }
+        });
     });
 
     function wrapper(p, done, post) {
@@ -113,64 +126,28 @@ describe('wp7 project parser', function() {
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
             beforeEach(function() {
-                find_obj = {
-                    text:'hi',
-                    attrib:{Title:'old'}
-                };
-                root_obj = {
-                    attrib:{
-                        package:'android_pkg'
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
                 cfg.name = function() { return 'testname' };
                 cfg.content = function() { return 'index.html' };
                 cfg.packageName = function() { return 'testpkg' };
                 cfg.version = function() { return 'one point oh' };
-                cfg.access.get = function() { return [] };
-                cfg.preference.get = function() { return [] };
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                p.config = {
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    content:cfg_content,
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    }
-                };
                 readdir.andReturn(['test.sln']);
             });
 
             it('should write out the app name to wmappmanifest.xml', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.attrib.Title).toEqual('testname');
+                var appEl = manifestXml.getroot().find('.//App');
+                expect(appEl.attrib.Title).toEqual('testname');
             });
             it('should write out the app id to csproj file', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.text).toContain('testpkg');
+                var appEl = projXml.getroot().find('.//RootNamespace');
+                expect(appEl.text).toContain('testpkg');
             });
             it('should write out the app version to wmappmanifest.xml', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.attrib.Version).toEqual('one point oh');
+                var appEl = manifestXml.getroot().find('.//App');
+                expect(appEl.attrib.Version).toEqual('one point oh');
             });
         });
         describe('www_dir method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/metadata/wp8_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp8_parser.spec.js b/spec/metadata/wp8_parser.spec.js
index 84048f5..aa3b0c4 100644
--- a/spec/metadata/wp8_parser.spec.js
+++ b/spec/metadata/wp8_parser.spec.js
@@ -22,19 +22,21 @@ var platforms = require('../../platforms'),
     path = require('path'),
     shell = require('shelljs'),
     fs = require('fs'),
-    ET = require('elementtree'),
+    et = require('elementtree'),
+    xmlHelpers = require('../../src/xml-helpers'),
     Q = require('q'),
     child_process = require('child_process'),
     config = require('../../src/config'),
-    config_parser = require('../../src/config_parser'),
+    ConfigParser = require('../../src/ConfigParser'),
     cordova = require('../../cordova');
 
 // Create a real config object before mocking out everything.
-var cfg = new config_parser(path.join(__dirname, '..', 'test-config.xml'));
+var cfg = new ConfigParser(path.join(__dirname, '..', 'test-config.xml'));
 
 describe('wp8 project parser', function() {
     var proj = '/some/path';
     var exists, exec, custom, readdir, cfg_parser;
+    var manifestXml, projXml;
     beforeEach(function() {
         exists = spyOn(fs, 'existsSync').andReturn(true);
         exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
@@ -42,7 +44,18 @@ describe('wp8 project parser', function() {
         });
         custom = spyOn(config, 'has_custom_path').andReturn(false);
         readdir = spyOn(fs, 'readdirSync').andReturn(['test.csproj']);
-        cfg_parser = spyOn(util, 'config_parser');
+        projXml = manifestXml = null;
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function(path) {
+            if (/WMAppManifest.xml$/.exec(path)) {
+                return manifestXml = new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else if (/csproj$/.exec(path)) {
+                return projXml = new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else if (/xaml$/.exec(path)) {
+                return new et.ElementTree(et.XML('<foo><App Title="s"><PrimaryToken /><RootNamespace/><SilverlightAppEntry/><XapFilename/><AssemblyName/></App></foo>'));
+            } else {
+                throw new Error('Unexpected parseElementtreeSync: ' + path);
+            }
+        });
     });
 
     function wrapper(p, done, post) {
@@ -113,64 +126,28 @@ describe('wp8 project parser', function() {
         });
 
         describe('update_from_config method', function() {
-            var et, xml, find, write_xml, root, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
             beforeEach(function() {
-                find_obj = {
-                    text:'hi',
-                    attrib:{Title:'old'}
-                };
-                root_obj = {
-                    attrib:{
-                        package:'android_pkg'
-                    }
-                };
-                find = jasmine.createSpy('ElementTree find').andReturn(find_obj);
-                write_xml = jasmine.createSpy('ElementTree write');
-                root = jasmine.createSpy('ElementTree getroot').andReturn(root_obj);
-                et = spyOn(ET, 'ElementTree').andReturn({
-                    find:find,
-                    write:write_xml,
-                    getroot:root
-                });
-                xml = spyOn(ET, 'XML');
                 cfg.name = function() { return 'testname' };
                 cfg.content = function() { return 'index.html' };
                 cfg.packageName = function() { return 'testpkg' };
                 cfg.version = function() { return 'one point oh' };
-                cfg.access.get = function() { return [] };
-                cfg.preference.get = function() { return [] };
-                cfg_access_add = jasmine.createSpy('config_parser access add');
-                cfg_access_rm = jasmine.createSpy('config_parser access rm');
-                cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
-                cfg_pref_add = jasmine.createSpy('config_parser pref add');
-                cfg_content = jasmine.createSpy('config_parser content');
-                p.config = {
-                    access:{
-                        remove:cfg_access_rm,
-                        get:function(){},
-                        add:cfg_access_add
-                    },
-                    content:cfg_content,
-                    preference:{
-                        remove:cfg_pref_rm,
-                        get:function(){},
-                        add:cfg_pref_add
-                    }
-                };
                 readdir.andReturn(['test.sln']);
             });
 
             it('should write out the app name to wmappmanifest.xml', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.attrib.Title).toEqual('testname');
+                var appEl = manifestXml.getroot().find('.//App');
+                expect(appEl.attrib.Title).toEqual('testname');
             });
             it('should write out the app id to csproj file', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.text).toContain('testpkg');
+                var appEl = projXml.getroot().find('.//RootNamespace');
+                expect(appEl.text).toContain('testpkg');
             });
             it('should write out the app version to wmappmanifest.xml', function() {
                 p.update_from_config(cfg);
-                expect(find_obj.attrib.Version).toEqual('one point oh');
+                var appEl = manifestXml.getroot().find('.//App');
+                expect(appEl.attrib.Version).toEqual('one point oh');
             });
         });
         describe('www_dir method', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/45e80ac1/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index 8f0429a..0ad2fee 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -21,6 +21,8 @@ var cordova = require('../cordova'),
     path = require('path'),
     shell = require('shelljs'),
     superspawn = require('../src/superspawn'),
+    xmlHelpers = require('../src/xml-helpers'),
+    et = require('elementtree'),
     plugman = require('plugman'),
     fs = require('fs'),
     util = require('../src/util'),
@@ -35,6 +37,13 @@ var cwd = process.cwd();
 var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; });
 var project_dir = path.join('some', 'path');
 
+var TEST_XML = '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+    '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+    '        id        = "io.cordova.hellocordova"\n' +
+    '        version   = "0.0.1">\n' +
+    '    <name>Hello Cordova</name>\n' +
+    '</widget>\n';
+
 function fail(e) {
   expect('Got Error: ' + e).toBe('');
 }
@@ -45,7 +54,6 @@ describe('platform command', function() {
         cp,
         list_platforms,
         fire,
-        config_parser,
         find_plugins,
         config_read,
         load,
@@ -54,8 +62,6 @@ describe('platform command', function() {
         mkdir,
         existsSync,
         supports,
-        pkg,
-        name,
         spawn,
         prep_spy,
         plugman_install,
@@ -70,11 +76,8 @@ describe('platform command', function() {
         is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
         cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir);
         fire = spyOn(hooker.prototype, 'fire').andReturn(Q());
-        name = jasmine.createSpy('config name').andReturn('magical mystery tour');
-        pkg = jasmine.createSpy('config packageName').andReturn('ca.filmaj.id');
-        config_parser = spyOn(util, 'config_parser').andReturn({
-            packageName:pkg,
-            name:name
+        spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function() {
+            return new et.ElementTree(et.XML(TEST_XML));
         });
         find_plugins = spyOn(util, 'findPlugins').andReturn([]);
         list_platforms = spyOn(util, 'listPlatforms').andReturn(supported_platforms);


Mime
View raw message