Code cleanup.
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/protoc/command/DescriptorPathProtocOption_appendOptionToCommand_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/protoc/command/DescriptorPathProtocOption_appendOptionToCommand_Test.java
index 2b377df..096d297 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/protoc/command/DescriptorPathProtocOption_appendOptionToCommand_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/protoc/command/DescriptorPathProtocOption_appendOptionToCommand_Test.java
@@ -8,6 +8,8 @@
*/
package com.google.eclipse.protobuf.ui.protoc.command;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
import static org.junit.rules.ExpectedException.none;
import static org.mockito.Mockito.*;
@@ -25,28 +27,28 @@
public class DescriptorPathProtocOption_appendOptionToCommand_Test {
@Rule public ExpectedException thrown = none();
- private StringPreference descriptorPath;
private CompilerPreferences preferences;
+ private StringPreference descriptorPathPreference;
private ProtocCommand command;
private DescriptorPathProtocOption option;
@Before public void setUp() {
- descriptorPath = mock(StringPreference.class);
preferences = mock(CompilerPreferences.class);
- command = mock(ProtocCommand.class);
+ descriptorPathPreference = mock(StringPreference.class);
+ command = new ProtocCommand("protoc");
option = new DescriptorPathProtocOption(preferences, "/");
}
@Test public void should_not_append_to_command_if_descriptor_path_is_null() {
expectDescriptorPathToBeEqualTo(null);
option.addOptionTo(command);
- verifyZeroInteractions(command);
+ assertThat(command.toString(), equalTo("protoc"));
}
@Test public void should_not_append_to_command_if_descriptor_path_is_empty() {
expectDescriptorPathToBeEqualTo("");
option.addOptionTo(command);
- verifyZeroInteractions(command);
+ assertThat(command.toString(), equalTo("protoc"));
}
@Test public void should_throw_error_if_descriptor_path_does_not_contain_descriptor_FQN() {
@@ -54,17 +56,17 @@
thrown.expectMessage("Path '/usr/local/include' does not contain '/google/protobuf/descriptor.proto'");
expectDescriptorPathToBeEqualTo("/usr/local/include");
option.addOptionTo(command);
- verifyZeroInteractions(command);
+ assertThat(command.toString(), equalTo("protoc"));
}
@Test public void should_append_path_of_descriptor_to_command() {
expectDescriptorPathToBeEqualTo("/usr/local/include/google/protobuf/descriptor.proto");
option.addOptionTo(command);
- verify(command).appendOption("proto_path", "/usr/local/include");
+ assertThat(command.toString(), equalTo("protoc --proto_path=/usr/local/include"));
}
private void expectDescriptorPathToBeEqualTo(String value) {
- when(preferences.descriptorPath()).thenReturn(descriptorPath);
- when(descriptorPath.getValue()).thenReturn(value);
+ when(preferences.descriptorPath()).thenReturn(descriptorPathPreference);
+ when(descriptorPathPreference.getValue()).thenReturn(value);
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
index 8ec4d3f..5ad93d7 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
@@ -75,8 +75,7 @@
return null;
}
URI uri = resource.getURI();
- if (!uri.fileExtension().equals("proto"))
- {
+ if (!uri.fileExtension().equals("proto")) {
return null;
}
if (uri.scheme() == null) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/protoc/command/ProtocCommand.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/protoc/command/ProtocCommand.java
index ba17fef..e068af2 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/protoc/command/ProtocCommand.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/protoc/command/ProtocCommand.java
@@ -35,7 +35,7 @@
}
@Override public String toString() {
- return content.toString();
+ return content.toString().trim();
}
void setFileToCompile(IFile protoFile) {