blob: 058ee307e1a661df927868b35d1bb8df9b5f0436 [file] [log] [blame]
var FrameworkTest = TestCase.create("FrameworkTest");
FrameworkTest.prototype.testEmptyGetBundles = function() {
var framework = new orion.Framework();
assertEquals(0, framework.getBundles().length);
};
FrameworkTest.prototype.getSetProperty = function() {
var framework = new orion.Framework();
assertUndefined(framework.getProperty("test"));
framework.setProperty("test", "value");
assertEquals("test", framework.getProperty("test"));
framework.setProperty("test");
assertUndefined(framework.getProperty("test"));
};
FrameworkTest.prototype.testNullLocationInstallBundle = function() {
var framework = new orion.Framework();
try {
framework.installBundle(null);
} catch (e) {
return;
}
fail();
};
FrameworkTest.prototype.testSimpleInstallBundle = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
};
FrameworkTest.prototype.testEmptyRefresh = function() {
var framework = new orion.Framework();
framework.refresh();
};
FrameworkTest.prototype.testSimpleRefresh = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
b.uninstall();
assertEquals(orion.Bundle.UNINSTALLED, b.getState());
assertEquals(1, framework.getBundles().length);
framework.refresh();
assertEquals(0, framework.getBundles().length);
};
FrameworkTest.prototype.testEmptyResolve = function() {
var framework = new orion.Framework();
framework.resolve();
};
FrameworkTest.prototype.testSimpleResolve = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertEquals(orion.Bundle.RESOLVED, b.getState());
};
FrameworkTest.prototype.testResolveNonSingleton = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", version:"1"});
var b = framework.installBundle("cde2", {name:"cde", version:"2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveSingletonFail = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde;singleton:=true", version:"1"});
var b = framework.installBundle("cde2", {name:"cde;singleton:=true", version:"2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveImportsFail = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveOptionalImports = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc;resolution:=optional"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveImportsSuccess = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc", script:"var abc = {hi:7};"});
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveVersionedImportsSuccess = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc;version=1.2", script:"var abc = {hi:7};"});
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc;version=1.2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveVersionedImportsFail = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc;version=1.1", script:"var abc = {hi:7};"});
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc;version=1.2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveResourceImportsSuccess = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"/abc/def"});
var b = framework.installBundle("xyz", {name:"xyz", imports:"/abc/def"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveImportsFailAfterUninstall = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc", script:"var abc = {hi:7};"});
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc"});
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
a.uninstall();
framework.refresh();
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveLikeFunction = function() {
var load = new Function("", "var abc = {hi:7};\n\n return {abc:abc};");
var x= load.apply({}, []);
assertEquals(7, x.abc.hi);
};
FrameworkTest.prototype.testResolveImportsLoad = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc", script:"var abc = {hi:7};"});
framework.resolve();
assertEquals(7, a._scope.abc.hi);
assertEquals(7, a.load("abc").hi);
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc", exports:"def", script:"var def = abc;"});
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
assertEquals(7, b.load("def").hi);
};
FrameworkTest.prototype.testResolveMultipleImportsLoad = function() {
var framework = new orion.Framework();
var a = framework.installBundle("cde", {name:"cde", exports:"abc,xyz", script:"var abc = {hi:7};\nvar xyz = {bye:9};"});
framework.resolve();
assertEquals(7, a._scope.abc.hi);
assertEquals(7, a.load("abc").hi);
assertEquals(9, a.load("xyz").bye);
var b = framework.installBundle("xyz", {name:"xyz", imports:"abc,xyz", exports:"def,ghi", script:"var def = abc;\nvar ghi = xyz;"});
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
assertEquals(7, b.load("def").hi);
assertEquals(9, b.load("ghi").bye);
};
FrameworkTest.prototype.testResolveRequiresFail = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveOptionalRequires = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc;resolution:=optional"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveRequiresFailAfterUninstall = function() {
var framework = new orion.Framework();
var a = framework.installBundle("abc", {name:"abc"});
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc"});
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
a.uninstall();
framework.refresh();
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveRequiresSuccess = function() {
var framework = new orion.Framework();
var a = framework.installBundle("abc", {name:"abc"});
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveVersionedRequiresSuccess = function() {
var framework = new orion.Framework();
var a = framework.installBundle("abc", {name:"abc", version:"1.2"});
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc;bundle-version=1.2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertTrue(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testResolveVersionedRequiresFail = function() {
var framework = new orion.Framework();
var a = framework.installBundle("abc", {name:"abc", version:"1.1"});
var b = framework.installBundle("xyz", {name:"xyz", requires:"abc;bundle-version=1.2"});
assertEquals(2, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, a.getState());
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.resolve();
assertTrue(orion.Bundle.RESOLVED == a.getState());
assertFalse(orion.Bundle.RESOLVED == b.getState());
};
FrameworkTest.prototype.testEmptyShutdown = function() {
var framework = new orion.Framework();
framework.shutdown();
};
FrameworkTest.prototype.testEmptyShutdown = function() {
var framework = new orion.Framework();
var b = framework.installBundle("xyz", {name:"xyz"});
assertEquals(1, framework.getBundles().length);
assertEquals(orion.Bundle.INSTALLED, b.getState());
framework.shutdown();
assertEquals(0, framework.getBundles().length);
};