Search in sources :

Example 1 with Property

use of org.eclipse.core.internal.expressions.Property in project eclipse.platform.runtime by eclipse.

the class PropertyTesterTests method test.

private boolean test(String namespace, Object receiver, String property, Object[] args, Object expectedValue) throws CoreException {
    Property p = fgManager.getProperty(receiver, namespace, property);
    assertTrue(p.isInstantiated());
    return p.test(receiver, args, expectedValue);
}
Also used : Property(org.eclipse.core.internal.expressions.Property)

Example 2 with Property

use of org.eclipse.core.internal.expressions.Property in project eclipse.platform.runtime by eclipse.

the class PropertyTesterTests method testDynamicPlugin.

public void testDynamicPlugin() throws Exception {
    if (TEST_DYNAMIC_AND_ACTIVATION) {
        A receiver = new A();
        // $NON-NLS-1$ //$NON-NLS-2$
        Property p = fgManager.getProperty(receiver, "org.eclipse.core.expressions.tests.dynamic", "testing");
        assertTrue(!p.isInstantiated());
        // $NON-NLS-1$
        Bundle bundle = Platform.getBundle("org.eclipse.core.expressions.tests.dynamic");
        bundle.start();
        // $NON-NLS-1$ //$NON-NLS-2$
        p = fgManager.getProperty(receiver, "org.eclipse.core.expressions.tests.dynamic", "testing");
        assertTrue(p.isInstantiated());
        bundle.stop();
        bundle.uninstall();
        boolean exception = false;
        try {
            // $NON-NLS-1$ //$NON-NLS-2$
            p = fgManager.getProperty(receiver, "org.eclipse.core.expressions.tests.dynamic", "testing");
        } catch (CoreException e) {
            exception = true;
        } catch (InvalidRegistryObjectException e) {
            // The uninstall events are sent out in a separate thread.
            // So the type extension registry might not be flushed even
            // though the bundle has already been uninstalled.
            exception = true;
        }
        assertTrue("Core exception not thrown", exception);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) Bundle(org.osgi.framework.Bundle) InvalidRegistryObjectException(org.eclipse.core.runtime.InvalidRegistryObjectException) Property(org.eclipse.core.internal.expressions.Property)

Example 3 with Property

use of org.eclipse.core.internal.expressions.Property 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

Property (org.eclipse.core.internal.expressions.Property)3 Bundle (org.osgi.framework.Bundle)2 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)1 EvaluationResult (org.eclipse.core.expressions.EvaluationResult)1 TestExpression (org.eclipse.core.internal.expressions.TestExpression)1 CoreException (org.eclipse.core.runtime.CoreException)1 InvalidRegistryObjectException (org.eclipse.core.runtime.InvalidRegistryObjectException)1