summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Ruiz2012-02-23 16:19:06 (EST)
committerSergey Prigogin2012-02-23 16:19:06 (EST)
commit55b9874f5d71ff58fdb445c76e16633d99299cee (patch)
treeec0367b122cb5e6aa7f323cc054b35934fa6bea6
parenta3758a0664ce8bf01807c70a0bc6f043542f1c5b (diff)
downloadorg.eclipse.cdt-55b9874f5d71ff58fdb445c76e16633d99299cee.zip
org.eclipse.cdt-55b9874f5d71ff58fdb445c76e16633d99299cee.tar.gz
org.eclipse.cdt-55b9874f5d71ff58fdb445c76e16633d99299cee.tar.bz2
Minor code cleanup.
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/core/externaltool/ExternalToolInvokerTest.java83
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ArgsSetting.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/PathSetting.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ShouldDisplayOutputSetting.java2
4 files changed, 61 insertions, 28 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/core/externaltool/ExternalToolInvokerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/core/externaltool/ExternalToolInvokerTest.java
index fafa804..3058bca 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/core/externaltool/ExternalToolInvokerTest.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/core/externaltool/ExternalToolInvokerTest.java
@@ -16,14 +16,16 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.ConfigurationSettings;
import org.eclipse.cdt.codan.core.externaltool.IArgsSeparator;
import org.eclipse.cdt.codan.core.externaltool.ICommandLauncher;
-import org.eclipse.cdt.codan.core.externaltool.AbstractOutputParser;
import org.eclipse.cdt.codan.core.externaltool.InvocationFailure;
import org.eclipse.cdt.codan.core.externaltool.InvocationParameters;
+import org.eclipse.cdt.codan.core.externaltool.SingleConfigurationSetting;
import org.eclipse.cdt.codan.core.externaltool.SpaceDelimitedArgsSeparator;
import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.core.test.CodanTestCase;
import org.eclipse.core.resources.IProject;
@@ -67,16 +69,19 @@ public class ExternalToolInvokerTest extends CodanTestCase {
private MapProblemPreference createPreferences(File path, String args,
boolean shouldDisplayOutput) {
MapProblemPreference preferences = new MapProblemPreference();
- preferences.addChildDescriptor(new BasicProblemPreference("externalToolPath", "Path"));
- preferences.addChildDescriptor(new BasicProblemPreference("externalToolArgs", "Args"));
- preferences.addChildDescriptor(new BasicProblemPreference("externalToolShouldDisplayOutput",
- "Should Display Output"));
- preferences.setChildValue("externalToolPath", path);
- preferences.setChildValue("externalToolArgs", args);
- preferences.setChildValue("externalToolShouldDisplayOutput", shouldDisplayOutput);
+ preferences.addChildDescriptor(createPreference(PathSetting.KEY, path));
+ preferences.addChildDescriptor(createPreference(ArgsSetting.KEY, args));
+ preferences.addChildDescriptor(createPreference(ShouldDisplayOutputSetting.KEY,
+ shouldDisplayOutput));
return preferences;
}
+ private IProblemPreference createPreference(String key, Object value) {
+ BasicProblemPreference preference = new BasicProblemPreference(key, "");
+ preference.setValue(value);
+ return preference;
+ }
+
@Override
public boolean isCpp() {
return true;
@@ -89,26 +94,24 @@ public class ExternalToolInvokerTest extends CodanTestCase {
InvocationParameters parameters = new InvocationParameters(currentIFile, currentIFile,
currentIFile.getLocation().toOSString(), cproject.getProject().getLocation());
externalToolInvoker.invoke(parameters, configurationSettings, argsSeparator, parsers);
- assertSame(cproject.getProject(), commandLauncher.project);
- assertEquals(EXTERNAL_TOOL_NAME, commandLauncher.externalToolName);
- String expectedExecutablePath = configurationSettings.getPath().getValue().toString();
- assertEquals(expectedExecutablePath, commandLauncher.executablePath.toOSString());
- String[] expectedArgs = { parameters.getActualFilePath(), "--debug=true", "--include=all" };
- assertArrayEquals(expectedArgs, commandLauncher.args);
- assertEquals(parameters.getWorkingDirectory(), commandLauncher.workingDirectory);
- assertEquals(configurationSettings.getShouldDisplayOutput().getValue().booleanValue(),
- commandLauncher.shouldDisplayOutput);
- assertSame(parsers, commandLauncher.parsers);
+ commandLauncher.assertThatReceivedProject(cproject.getProject());
+ commandLauncher.assertThatReceivedExternalToolName(EXTERNAL_TOOL_NAME);
+ commandLauncher.assertThatReceivedExecutablePath(configurationSettings.getPath());
+ commandLauncher.assertThatReceivedArgs(configurationSettings.getArgs());
+ commandLauncher.assertThatReceivedWorkingDirectory(parameters.getWorkingDirectory());
+ commandLauncher.assertThatReceivedShouldDisplayOutput(
+ configurationSettings.getShouldDisplayOutput());
+ commandLauncher.assetThatReceivedOutputParsers(parsers);
}
private static class CommandLauncherStub implements ICommandLauncher {
- IProject project;
- String externalToolName;
- IPath executablePath;
- String[] args;
- IPath workingDirectory;
- boolean shouldDisplayOutput;
- List<AbstractOutputParser> parsers;
+ private IProject project;
+ private String externalToolName;
+ private IPath executablePath;
+ private String[] args;
+ private IPath workingDirectory;
+ private boolean shouldDisplayOutput;
+ private List<AbstractOutputParser> parsers;
@Override
public void buildAndLaunchCommand(IProject project, String externalToolName,
@@ -123,5 +126,35 @@ public class ExternalToolInvokerTest extends CodanTestCase {
this.shouldDisplayOutput = shouldDisplayOutput;
this.parsers = parsers;
}
+
+ void assertThatReceivedProject(IProject expected) {
+ assertEquals(expected, project);
+ }
+
+ void assertThatReceivedExternalToolName(String expected) {
+ assertEquals(expected, externalToolName);
+ }
+
+ void assertThatReceivedExecutablePath(SingleConfigurationSetting<File> expected) {
+ String expectedPath = expected.getValue().toString();
+ assertEquals(expectedPath, executablePath.toOSString());
+ }
+
+ void assertThatReceivedArgs(SingleConfigurationSetting<String> expected) {
+ String[] expectedArgs = expected.getValue().split("\\s+");
+ assertArrayEquals(expectedArgs, args);
+ }
+
+ void assertThatReceivedWorkingDirectory(IPath expected) {
+ assertSame(expected, workingDirectory);
+ }
+
+ void assertThatReceivedShouldDisplayOutput(SingleConfigurationSetting<Boolean> expected) {
+ assertEquals(expected.getValue().booleanValue(), shouldDisplayOutput);
+ }
+
+ void assetThatReceivedOutputParsers(List<AbstractOutputParser> expected) {
+ assertSame(expected, parsers);
+ }
}
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ArgsSetting.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ArgsSetting.java
index 37d8a74..61f0f9a 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ArgsSetting.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ArgsSetting.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
* @since 2.1
*/
public class ArgsSetting extends SingleConfigurationSetting<String> {
- private static final String KEY = "externalToolArgs"; //$NON-NLS-1$
+ static final String KEY = "externalToolArgs"; //$NON-NLS-1$
/**
* Constructor.
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/PathSetting.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/PathSetting.java
index 378fab6..91864b1 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/PathSetting.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/PathSetting.java
@@ -27,7 +27,7 @@ import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
* @since 2.1
*/
public class PathSetting extends SingleConfigurationSetting<File> {
- private static final String KEY = "externalToolPath"; //$NON-NLS-1$
+ static final String KEY = "externalToolPath"; //$NON-NLS-1$
/**
* Constructor.
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ShouldDisplayOutputSetting.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ShouldDisplayOutputSetting.java
index e3aaf70..77c3ce5 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ShouldDisplayOutputSetting.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/externaltool/ShouldDisplayOutputSetting.java
@@ -26,7 +26,7 @@ import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor;
* @since 2.1
*/
public class ShouldDisplayOutputSetting extends SingleConfigurationSetting<Boolean> {
- private static final String KEY = "externalToolShouldDisplayOutput"; //$NON-NLS-1$
+ static final String KEY = "externalToolShouldDisplayOutput"; //$NON-NLS-1$
/**
* Constructor.