Search in sources :

Example 1 with TestExpression

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);
}
Also used : TestExpression(org.eclipse.core.internal.expressions.TestExpression) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 2 with TestExpression

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());
}
Also used : AndExpression(org.eclipse.core.internal.expressions.AndExpression) SystemTestExpression(org.eclipse.core.internal.expressions.SystemTestExpression) ResolveExpression(org.eclipse.core.internal.expressions.ResolveExpression) OrExpression(org.eclipse.core.internal.expressions.OrExpression) Expression(org.eclipse.core.expressions.Expression) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) EnablementExpression(org.eclipse.core.internal.expressions.EnablementExpression) InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) CountExpression(org.eclipse.core.internal.expressions.CountExpression) WithExpression(org.eclipse.core.internal.expressions.WithExpression) NotExpression(org.eclipse.core.internal.expressions.NotExpression) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression) TestExpression(org.eclipse.core.internal.expressions.TestExpression) EnablementExpression(org.eclipse.core.internal.expressions.EnablementExpression) SystemTestExpression(org.eclipse.core.internal.expressions.SystemTestExpression) TestExpression(org.eclipse.core.internal.expressions.TestExpression) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 3 with TestExpression

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());
}
Also used : SystemTestExpression(org.eclipse.core.internal.expressions.SystemTestExpression) TestExpression(org.eclipse.core.internal.expressions.TestExpression)

Example 4 with TestExpression

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));
}
Also used : SystemTestExpression(org.eclipse.core.internal.expressions.SystemTestExpression) TestExpression(org.eclipse.core.internal.expressions.TestExpression)

Example 5 with TestExpression

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());
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TestExpression(org.eclipse.core.internal.expressions.TestExpression) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) Property(org.eclipse.core.internal.expressions.Property) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Aggregations

TestExpression (org.eclipse.core.internal.expressions.TestExpression)5 SystemTestExpression (org.eclipse.core.internal.expressions.SystemTestExpression)3 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)2 EvaluationResult (org.eclipse.core.expressions.EvaluationResult)2 Expression (org.eclipse.core.expressions.Expression)1 AdaptExpression (org.eclipse.core.internal.expressions.AdaptExpression)1 AndExpression (org.eclipse.core.internal.expressions.AndExpression)1 CountExpression (org.eclipse.core.internal.expressions.CountExpression)1 EnablementExpression (org.eclipse.core.internal.expressions.EnablementExpression)1 EqualsExpression (org.eclipse.core.internal.expressions.EqualsExpression)1 InstanceofExpression (org.eclipse.core.internal.expressions.InstanceofExpression)1 IterateExpression (org.eclipse.core.internal.expressions.IterateExpression)1 NotExpression (org.eclipse.core.internal.expressions.NotExpression)1 OrExpression (org.eclipse.core.internal.expressions.OrExpression)1 Property (org.eclipse.core.internal.expressions.Property)1 ResolveExpression (org.eclipse.core.internal.expressions.ResolveExpression)1 WithExpression (org.eclipse.core.internal.expressions.WithExpression)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 Bundle (org.osgi.framework.Bundle)1