Commit d7239495 authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

Closed #180.



I refactored the ItemProcessor so that it now implements an
IItemProcessor interface. The Client now takes an IItemProcessor in the
test constructor, and the ClientTester provides a FakeItemProcessor. The
FakeItemProcessor runs most (but not all) of the code of the
ItemProcessor on the test thread, thus fixing #180. I tested this
thoroughly on my machine, both with the test framework and the product.
Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent f06adcb6
......@@ -57,7 +57,7 @@
<module>../org.eclipse.ice.vibe</module>
<module>../org.eclipse.ice.vibe.test</module>
<module>../org.eclipse.ice.feature</module>
<module>../org.eclipse.ice.repository</module>
<module>../org.eclipse.ice.product</module>
<module>../org.eclipse.ice.repository</module>
<module>../org.eclipse.ice.product</module>
</modules>
</project>
\ No newline at end of file
......@@ -55,10 +55,14 @@ import org.junit.Test;
/**
* ClientTester checks the behavior and functionality of Client. It checks for
* proper location setting and file system querying from Core.
*
* This classes uses both the {@link org.eclipse.ice.client.test.FakeCore} and
* the {@link org.eclipse.ice.client.test.FakeItemProcessor}.
*
* @author Jay Jay Billings
*/
public class ClientTester {
/**
* The client to test
*/
......@@ -92,7 +96,7 @@ public class ClientTester {
// Instantiate needed classes
this.fakeCore = new FakeCore();
this.iCEClient = new Client();
this.iCEClient = new Client(new FakeItemProcessor());
this.fakeUIWidgetFactory = new FakeUIWidgetFactory();
// Setup the client
......@@ -147,8 +151,7 @@ public class ClientTester {
}
/**
* This operation checks that we can add an IFormWidget
* to the Client.s
* This operation checks that we can add an IFormWidget to the Client.s
*/
@Test
public void checkAddFormWidget() {
......@@ -159,6 +162,7 @@ public class ClientTester {
iCEClient.addFormWidget(widget);
assertNotNull(iCEClient.getFormWidget(1));
}
/**
* This operation checks the Client by making sure that errors can be
* dispatched to the UI system to be displayed to the user.
......@@ -176,7 +180,8 @@ public class ClientTester {
// Check the Factory to make sure it was called
assertTrue(fakeUIWidgetFactory.widgetRequested());
// Make sure the Widget was displayed
FakeErrorBoxWidget testWidget = fakeUIWidgetFactory.getLastErrorBoxWidget();
FakeErrorBoxWidget testWidget = fakeUIWidgetFactory
.getLastErrorBoxWidget();
assertNotNull(testWidget);
assertTrue(testWidget.widgetDisplayed());
}
......@@ -266,14 +271,14 @@ public class ClientTester {
}
// Make sure that there are no items
assertEquals(0, iCEClient.getItems().size());
System.out.println("Num ITEMS after delete = " + iCEClient.getItems().size());
System.out.println(
"Num ITEMS after delete = " + iCEClient.getItems().size());
return;
}
/**
* Check that the Core gets invoked when we
* rename an Item.
* Check that the Core gets invoked when we rename an Item.
*/
@Test
public void checkItemRenaming() {
......@@ -359,17 +364,6 @@ public class ClientTester {
// Process the Item through the IProcessEventListener interface
iCEClient.processSelected(testForm, "blend");
// There's a thread involved because the Client's processItem()
// operation moves the work off of the UI thread. Give the thread a
// little time to do its work.
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// Fail if an exception is caught
fail();
}
// Check the process status with the core to make sure the event was
// processed
assertEquals(FormStatus.Processed, fakeCore.getLastProcessStatus());
......@@ -386,17 +380,6 @@ public class ClientTester {
// Process the Item through the IClient.processItem operation
iCEClient.processItem(itemId, "blend");
// There's a thread involved because the Client's processItem()
// operation moves the work off of the UI thread. Give the thread a
// little time to do its work.
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// Fail if an exception is caught
fail();
}
// Check the process status with the core to make sure the event was
// processed
assertEquals(FormStatus.Processed, fakeCore.getLastProcessStatus());
......@@ -413,25 +396,16 @@ public class ClientTester {
// the proper return code, FormStatus.NeedsInfo.
iCEClient.processItem(itemId, "NeedsInfo");
// There's a thread involved because the Client's processItem()
// operation moves the work off of the UI thread. Give the thread a
// little time to do its work.
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// Fail if an exception is caught
fail();
}
// Check the process status to make sure the client made the call
assertEquals(FormStatus.NeedsInfo, fakeCore.getItemStatus(0));
assertEquals(FormStatus.NeedsInfo, fakeCore.getLastProcessStatus());
// Make sure the widget was requested from the factory
assertTrue(fakeUIWidgetFactory.widgetRequested());
// Retrieve the info widget and get its Form
FakeExtraInfoWidget infoWidget = fakeUIWidgetFactory.getLastExtraInfoWidget();
FakeExtraInfoWidget infoWidget = fakeUIWidgetFactory
.getLastExtraInfoWidget();
assertNotNull(infoWidget);
Form infoForm = infoWidget.getForm();
......@@ -439,22 +413,12 @@ public class ClientTester {
assertNotNull(infoForm);
assertTrue(infoWidget.widgetDisplayed());
// There's a thread involved because the Client's processItem()
// operation moves the work off of the UI thread. Give the thread a
// little time to do its work.
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// Fail if an exception is caught
fail();
}
// Make sure the Form was resubmitted to the core
assertTrue(fakeCore.itemUpdated());
// Get the streaming text widget and check it
FakeStreamingTextWidget textWidget = fakeUIWidgetFactory.getLastStreamingTextWidget();
FakeStreamingTextWidget textWidget = fakeUIWidgetFactory
.getLastStreamingTextWidget();
assertNotNull(textWidget);
// Check that the streaming text widget was displayed
assertTrue(textWidget.widgetDisplayed());
......@@ -652,19 +616,22 @@ public class ClientTester {
}
@Override
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
public void setTeamPrivateMember(boolean isTeamPrivate)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
public void setSessionProperty(QualifiedName key, Object value)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
public void setResourceAttributes(ResourceAttributes attributes)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -676,7 +643,8 @@ public class ClientTester {
}
@Override
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
public void setPersistentProperty(QualifiedName key, String value)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -688,7 +656,8 @@ public class ClientTester {
}
@Override
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
public void setLocal(boolean flag, int depth, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -700,7 +669,8 @@ public class ClientTester {
}
@Override
public void setDerived(boolean isDerived, IProgressMonitor monitor) throws CoreException {
public void setDerived(boolean isDerived, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -718,33 +688,37 @@ public class ClientTester {
}
@Override
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
public void refreshLocal(int depth, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
public void move(IProjectDescription description, boolean force,
boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
throws CoreException {
public void move(IProjectDescription description, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void move(IPath destination, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
public void move(IPath destination, boolean force,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
......@@ -840,13 +814,15 @@ public class ClientTester {
}
@Override
public Object getSessionProperty(QualifiedName key) throws CoreException {
public Object getSessionProperty(QualifiedName key)
throws CoreException {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QualifiedName, Object> getSessionProperties() throws CoreException {
public Map<QualifiedName, Object> getSessionProperties()
throws CoreException {
// TODO Auto-generated method stub
return null;
}
......@@ -882,13 +858,15 @@ public class ClientTester {
}
@Override
public String getPersistentProperty(QualifiedName key) throws CoreException {
public String getPersistentProperty(QualifiedName key)
throws CoreException {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<QualifiedName, String> getPersistentProperties() throws CoreException {
public Map<QualifiedName, String> getPersistentProperties()
throws CoreException {
// TODO Auto-generated method stub
return null;
}
......@@ -942,13 +920,15 @@ public class ClientTester {
}
@Override
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException {
public int findMaxProblemSeverity(String type, boolean includeSubtypes,
int depth) throws CoreException {
// TODO Auto-generated method stub
return 0;
}
@Override
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
public IMarker[] findMarkers(String type, boolean includeSubtypes,
int depth) throws CoreException {
// TODO Auto-generated method stub
return null;
}
......@@ -966,19 +946,22 @@ public class ClientTester {
}
@Override
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
public void deleteMarkers(String type, boolean includeSubtypes,
int depth) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
public void delete(int updateFlags, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
public void delete(boolean force, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -996,57 +979,64 @@ public class ClientTester {
}
@Override
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
throws CoreException {
public void copy(IProjectDescription description, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
throws CoreException {
public void copy(IProjectDescription description, boolean force,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void copy(IPath destination, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
public void copy(IPath destination, boolean force,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void clearHistory(IProgressMonitor monitor) throws CoreException {
public void clearHistory(IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
public void accept(IResourceVisitor visitor, int depth, int memberFlags)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {
public void accept(IResourceVisitor visitor, int depth,
boolean includePhantoms) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void accept(IResourceProxyVisitor visitor, int depth, int memberFlags) throws CoreException {
public void accept(IResourceProxyVisitor visitor, int depth,
int memberFlags) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
public void accept(IResourceProxyVisitor visitor, int memberFlags)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -1058,33 +1048,38 @@ public class ClientTester {
}
@Override
public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
public void setContents(IFileState source, boolean force,
boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
public void setContents(InputStream source, boolean force,
boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void setContents(IFileState source, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void setContents(InputStream source, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
public void setCharset(String newCharset, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
......@@ -1096,8 +1091,8 @@ public class ClientTester {
}
@Override
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
public void move(IPath destination, boolean force, boolean keepHistory,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
......@@ -1115,7 +1110,8 @@ public class ClientTester {
}
@Override
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
public IFileState[] getHistory(IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
return null;
}
......@@ -1145,7 +1141,8 @@ public class ClientTester {
}
@Override
public IContentDescription getContentDescription() throws CoreException {
public IContentDescription getContentDescription()
throws CoreException {
// TODO Auto-generated method stub
return null;
}
......@@ -1169,44 +1166,51 @@ public class ClientTester {
}
@Override
public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
public void delete(boolean force, boolean keepHistory,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void createLink(URI location, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void createLink(IPath localLocation, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void create(InputStream source, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {
public void create(InputStream source, boolean force,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
public void appendContents(InputStream source, boolean force,
boolean keepHistory, IProgressMonitor monitor)
throws CoreException {
// TODO Auto-generated method stub
}
@Override
public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
public void appendContents(InputStream source, int updateFlags,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
}
......
......@@ -92,8 +92,11 @@ public class FakeCore implements ICore {
*/
private boolean imported;
/**
* True if the Item's name was changed, false otherwise.
*/
private boolean itemNameChanged;
/**
* <p>
* True if the client attempted to cancel an Item process request, false
......@@ -152,7 +155,7 @@ public class FakeCore implements ICore {
cancelled = false;
loaded = false;
itemNameChanged = false;
return;
}
......@@ -350,7 +353,8 @@ public class FakeCore implements ICore {
// Change the name
if (form.getId() == 8675309) {
System.out.println("FakeCore Message: Failing with " + "FormStatus.InfoError!");
System.out.println("FakeCore Message: Failing with "
+ "FormStatus.InfoError!");
return FormStatus.InfoError;
}
......@@ -371,7 +375,8 @@ public class FakeCore implements ICore {
}
@Override
public FormStatus processItem(int itemId, String actionName, int uniqueClientId) {
public FormStatus processItem(int itemId, String actionName,
int uniqueClientId) {
// Check the Item id and the action name to make sure they are