summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-04-12 07:12:34 (EDT)
committerSteffen Kriese2011-04-12 07:12:34 (EDT)
commit7e1778966a284a1fff8f5c8fa1d06c7d1168027e (patch)
treec698fd6899f9bbcd8f7b6eb0fdfa49415fa5e8d4
parentd3f1ab88cd98a9d8135b86187d9ab12326ce8936 (diff)
downloadorg.eclipse.riena-7e1778966a284a1fff8f5c8fa1d06c7d1168027e.zip
org.eclipse.riena-7e1778966a284a1fff8f5c8fa1d06c7d1168027e.tar.gz
org.eclipse.riena-7e1778966a284a1fff8f5c8fa1d06c7d1168027e.tar.bz2
added unittest for UIExecutor
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/ui/core/uiprocess/UIExecutorTest.java81
-rw-r--r--org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/UIExecutor.java2
2 files changed, 82 insertions, 1 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/core/uiprocess/UIExecutorTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/core/uiprocess/UIExecutorTest.java
new file mode 100644
index 0000000..14f152a
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/core/uiprocess/UIExecutorTest.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.ui.core.uiprocess;
+
+import java.util.concurrent.Callable;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.riena.internal.core.test.collect.UITestCase;
+import org.eclipse.riena.internal.ui.swt.test.UITestHelper;
+import org.eclipse.riena.ui.swt.utils.SwtUtilities;
+
+/**
+ *
+ */
+@UITestCase
+public class UIExecutorTest extends TestCase {
+
+ private Shell shell;
+ private Button button;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ shell = new Shell();
+ button = new Button(shell, SWT.None);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ SwtUtilities.dispose(shell);
+ }
+
+ public void testExecuteLively() throws Exception {
+ // FIXME Why is testExecuteLively so slow?
+ @SuppressWarnings("unchecked")
+ final Callable<Boolean> callableMock = EasyMock.createNiceMock(Callable.class);
+ EasyMock.expect(callableMock.call()).andReturn(Boolean.TRUE);
+ EasyMock.replay(callableMock);
+
+ final SelectionListenerMock selectionListenerMock = new SelectionListenerMock();
+ assertFalse(selectionListenerMock.widgetSelectedCalled);
+ button.addSelectionListener(selectionListenerMock);
+
+ UITestHelper.fireSelectionEvent(button);
+ final Boolean result = UIExecutor.executeLively(callableMock);
+ assertNotNull(result);
+ assertTrue(result);
+
+ EasyMock.verify(callableMock);
+ assertTrue(selectionListenerMock.widgetSelectedCalled);
+ }
+
+ private class SelectionListenerMock implements SelectionListener {
+ private boolean widgetSelectedCalled = false;
+
+ public void widgetSelected(final SelectionEvent e) {
+ widgetSelectedCalled = true;
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ }
+ }
+}
diff --git a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/UIExecutor.java b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/UIExecutor.java
index 860ba7a..224a36b 100644
--- a/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/UIExecutor.java
+++ b/org.eclipse.riena.ui.core/src/org/eclipse/riena/ui/core/uiprocess/UIExecutor.java
@@ -76,7 +76,7 @@ public final class UIExecutor {
}
});
if (process.getError() != null) {
- throw new RuntimeException("Exception will executing callable.", process.getError()); //$NON-NLS-1$
+ throw new RuntimeException("Exception while executing callable.", process.getError()); //$NON-NLS-1$
}
return process.getResult();
}