use of org.eclipse.core.internal.expressions.TestExpression in project eclipse.platform.runtime by eclipse.
the class PropertyTesterTests method testPlatformTester.
public void testPlatformTester() throws Exception {
TestExpression exp = new TestExpression("org.eclipse.core.runtime", "bundleState", new Object[] { "org.eclipse.core.expressions" }, "ACTIVE", false);
EvaluationContext context = new EvaluationContext(null, Platform.class);
EvaluationResult result = exp.evaluate(context);
assertEquals(EvaluationResult.TRUE, result);
}
use of org.eclipse.core.internal.expressions.TestExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testForcePluginActivation.
public void testForcePluginActivation() throws Exception {
IExtensionRegistry registry = Platform.getExtensionRegistry();
// $NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement[] ces = registry.getConfigurationElementsFor("org.eclipse.core.expressions.tests", "testParticipants");
// $NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement enable = findExtension(ces, "test2").getChildren("enablement")[0];
EnablementExpression exp = (EnablementExpression) ExpressionConverter.getDefault().perform(enable);
Expression[] children = exp.getChildren();
assertTrue(children.length == 3);
TestExpression test = (TestExpression) children[0];
assertTrue(test.testGetForcePluginActivation());
test = (TestExpression) children[1];
assertTrue(!test.testGetForcePluginActivation());
test = (TestExpression) children[2];
assertTrue(!test.testGetForcePluginActivation());
}
use of org.eclipse.core.internal.expressions.TestExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testTestExpressionHashCode.
public void testTestExpressionHashCode() throws Exception {
TestExpression expression1 = new TestExpression("namespace", "prop", new Object[0], "value");
TestExpression expression2 = new TestExpression("namespace", "prop", new Object[0], "value");
assertEquals("Equal expressions should have the same hash code", expression1.hashCode(), expression2.hashCode());
}
use of org.eclipse.core.internal.expressions.TestExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testTestExpressionNotEqual.
public void testTestExpressionNotEqual() throws Exception {
TestExpression expression1 = new TestExpression("namespace", "prop", new Object[0], "value1");
TestExpression expression2 = new TestExpression("namespace", "prop", new Object[0], "value2");
assertTrue("These system test expressions should not be equal", !expression1.equals(expression2));
}
use of org.eclipse.core.internal.expressions.TestExpression in project eclipse.platform.runtime by eclipse.
the class PropertyTesterTests method testPluginActivation.
public void testPluginActivation() throws Exception {
if (TEST_DYNAMIC_AND_ACTIVATION) {
// $NON-NLS-1$
Bundle bundle = Platform.getBundle("org.eclipse.core.expressions.tests.forceActivation");
assertEquals(Bundle.STARTING, bundle.getState());
A receiver = new A();
TestExpression exp = new TestExpression("org.eclipse.core.expressions.tests.forceActivation", "testing", null, null, true);
EvaluationContext context = new EvaluationContext(null, receiver);
EvaluationResult result = exp.evaluate(context);
assertEquals(EvaluationResult.NOT_LOADED, result);
assertEquals(Bundle.STARTING, bundle.getState());
// $NON-NLS-1$ //$NON-NLS-2$
Property p = TestExpression.testGetTypeExtensionManager().getProperty(receiver, "org.eclipse.core.expressions.tests.forceActivation", "testing", false);
assertTrue(!p.isInstantiated());
context.setAllowPluginActivation(true);
exp.evaluate(context);
assertEquals(Bundle.ACTIVE, bundle.getState());
// $NON-NLS-1$ //$NON-NLS-2$
p = TestExpression.testGetTypeExtensionManager().getProperty(receiver, "org.eclipse.core.expressions.tests.forceActivation", "testing", false);
assertTrue(p.isInstantiated());
}
}
Aggregations