aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
index e5d5133cca..5494684b3f 100644
--- a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
@@ -22,6 +22,7 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.buildeventstream.ArtifactGroupNamer;
import com.google.devtools.build.lib.buildeventstream.BuildEvent;
+import com.google.devtools.build.lib.buildeventstream.BuildEventArtifactUploaderMap;
import com.google.devtools.build.lib.buildeventstream.BuildEventContext;
import com.google.devtools.build.lib.buildeventstream.BuildEventProtocolOptions;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
@@ -31,7 +32,7 @@ import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.common.options.Options;
import java.io.File;
import java.io.IOException;
-import java.util.concurrent.Future;
+import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -44,7 +45,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-/** Tests {@link BuildEventTransportFactory}. **/
+/** Tests {@link BuildEventTransportFactory}. */
@RunWith(JUnit4.class)
public class BuildEventTransportFactoryTest {
@@ -85,14 +86,18 @@ public class BuildEventTransportFactoryTest {
Mockito.validateMockitoUsage();
}
+ private BuildEventArtifactUploaderMap localFilesOnly() {
+ return new BuildEventArtifactUploaderMap.Builder().build();
+ }
+
@Test
- public void testCreatesTextFormatFileTransport() throws IOException {
+ public void testCreatesTextFormatFileTransport() throws Exception {
File textFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn(textFile.getAbsolutePath());
- when(options.getBuildEventTextFilePathConversion()).thenReturn(true);
when(options.getBuildEventBinaryFile()).thenReturn("");
ImmutableSet<BuildEventTransport> transports =
- BuildEventTransportFactory.createFromOptions(options, protocolOpts, pathConverter);
+ BuildEventTransportFactory.createFromOptions(
+ options, protocolOpts, localFilesOnly(), (e) -> {});
assertThat(FluentIterable.from(transports).transform(GET_CLASS))
.containsExactly(TextFormatFileTransport.class);
sendEventsAndClose(buildEvent, transports);
@@ -100,13 +105,13 @@ public class BuildEventTransportFactoryTest {
}
@Test
- public void testCreatesBinaryFormatFileTransport() throws IOException {
+ public void testCreatesBinaryFormatFileTransport() throws Exception {
File binaryFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn("");
when(options.getBuildEventBinaryFile()).thenReturn(binaryFile.getAbsolutePath());
- when(options.getBuildEventBinaryFilePathConversion()).thenReturn(true);
ImmutableSet<BuildEventTransport> transports =
- BuildEventTransportFactory.createFromOptions(options, protocolOpts, pathConverter);
+ BuildEventTransportFactory.createFromOptions(
+ options, protocolOpts, localFilesOnly(), (e) -> {});
assertThat(FluentIterable.from(transports).transform(GET_CLASS))
.containsExactly(BinaryFormatFileTransport.class);
sendEventsAndClose(buildEvent, transports);
@@ -114,15 +119,14 @@ public class BuildEventTransportFactoryTest {
}
@Test
- public void testCreatesAllTransports() throws IOException {
+ public void testCreatesAllTransports() throws Exception {
File textFile = tmp.newFile();
File binaryFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn(textFile.getAbsolutePath());
when(options.getBuildEventBinaryFile()).thenReturn(binaryFile.getAbsolutePath());
- when(options.getBuildEventBinaryFilePathConversion()).thenReturn(true);
- when(options.getBuildEventTextFilePathConversion()).thenReturn(true);
ImmutableSet<BuildEventTransport> transports =
- BuildEventTransportFactory.createFromOptions(options, protocolOpts, pathConverter);
+ BuildEventTransportFactory.createFromOptions(
+ options, protocolOpts, localFilesOnly(), (e) -> {});
assertThat(FluentIterable.from(transports).transform(GET_CLASS))
.containsExactly(TextFormatFileTransport.class, BinaryFormatFileTransport.class);
sendEventsAndClose(buildEvent, transports);
@@ -134,23 +138,16 @@ public class BuildEventTransportFactoryTest {
public void testCreatesNoTransports() throws IOException {
when(options.getBuildEventTextFile()).thenReturn("");
ImmutableSet<BuildEventTransport> transports =
- BuildEventTransportFactory.createFromOptions(options, protocolOpts, pathConverter);
+ BuildEventTransportFactory.createFromOptions(
+ options, protocolOpts, localFilesOnly(), (e) -> {});
assertThat(transports).isEmpty();
}
- @Test
- public void testPathToUriString() {
- // See https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/
- assertThat(BuildEventTransportFactory.pathToUriString("C:/Temp/Foo Bar.txt"))
- .isEqualTo("file:///C:/Temp/Foo%20Bar.txt");
- }
-
private void sendEventsAndClose(BuildEvent event, Iterable<BuildEventTransport> transports)
- throws IOException{
+ throws InterruptedException, ExecutionException {
for (BuildEventTransport transport : transports) {
transport.sendBuildEvent(event, artifactGroupNamer);
- @SuppressWarnings({"unused", "nullness"})
- Future<?> possiblyIgnoredError = transport.close();
+ transport.close().get();
}
}
}