Example usage for org.aspectj.ajde.core IBuildMessageHandler handleMessage

List of usage examples for org.aspectj.ajde.core IBuildMessageHandler handleMessage

Introduction

In this page you can find the example usage for org.aspectj.ajde.core IBuildMessageHandler handleMessage.

Prototype

boolean handleMessage(IMessage message) throws AbortException;

Source Link

Document

Handle message by reporting and/or throwing an AbortException.

Usage

From source file:org.eclipse.ajdt.ui.tests.ajde.UIMessageHandlerTest.java

License:Open Source License

/**
 * For an error with a throwable we expect an error dialog to appear
 * containing the information/*from   w w w.  ja  va 2  s  .  c  o m*/
 */
public void testHandleErrorWithMessageAndThrowable() throws Exception {
    IProject project = createPredefinedProject("Bean Example"); //$NON-NLS-1$
    AJDTErrorHandler.setShowErrorDialogs(false);
    String message = ""; //$NON-NLS-1$
    try {
        IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
                .getCompilerForProject(project).getMessageHandler();

        IMessage msg = new Message("fake error", IMessage.ERROR, new AbortException("fake abort"), null); //$NON-NLS-1$ //$NON-NLS-2$
        handler.handleMessage(msg);
    } catch (RuntimeException re) {
        message = re.getMessage();
    }
    assertTrue("expected a runtime error with message 'fake abort' when " + //$NON-NLS-1$
            " testing error handling but didn't find one", //$NON-NLS-1$
            message.equals("org.aspectj.bridge.AbortException: fake abort")); //$NON-NLS-1$
}

From source file:org.eclipse.ajdt.ui.tests.ajde.UIMessageHandlerTest.java

License:Open Source License

/**
 * For an abort message we expect an error dialog to appear containing the
 * information//  w  w w  . j  a  v  a2s .c om
 */
public void testHandleAbortWithMessageAndThrowable() throws Exception {
    IProject project = createPredefinedProject("Bean Example"); //$NON-NLS-1$
    AJDTErrorHandler.setShowErrorDialogs(false);
    String message = ""; //$NON-NLS-1$
    try {
        IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
                .getCompilerForProject(project).getMessageHandler();

        IMessage msg = new Message("fake abort", IMessage.ABORT, new AbortException("fake abort"), null); //$NON-NLS-1$ //$NON-NLS-2$
        handler.handleMessage(msg);
    } catch (RuntimeException re) {
        message = re.getMessage();
    }
    assertTrue("expected a runtime error with message 'fake abort' when " + //$NON-NLS-1$
            " testing error handling but didn't find one", //$NON-NLS-1$
            message.equals("org.aspectj.bridge.AbortException: fake abort")); //$NON-NLS-1$
}