Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static StorageOptions getUnauthenticatedInstance() {
@SuppressWarnings("unchecked")
@Override
public Builder toBuilder() {
return new Builder(this).setHost(DEFAULT_HOST);
return new Builder(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.cloud.storage;

import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.TransportOptions;
import org.easymock.EasyMock;
import org.junit.Assert;
Expand All @@ -33,4 +35,34 @@ public void testInvalidTransport() {
Assert.assertNotNull(ex.getMessage());
}
}

@Test
public void testConfigureHostShouldBeKeptOnToBuilder() {
StorageOptions opts1 = StorageOptions.newBuilder().setHost("custom-host").build();
StorageOptions opts2 = opts1.toBuilder().build();

assertThat(opts2.getHost()).isEqualTo("custom-host");
}

@Test
public void testToBuilderShouldSpecifyDefaultIfNotOtherwiseSet() {
StorageOptions opts1 = StorageOptions.newBuilder().build();
StorageOptions opts2 = opts1.toBuilder().build();

assertThat(opts2.getHost()).isEqualTo("https://storage.googleapis.com");
}

@Test
public void testNewBuilderSpecifiesCorrectHost() {
StorageOptions opts1 = StorageOptions.newBuilder().build();

assertThat(opts1.getHost()).isEqualTo("https://storage.googleapis.com");
}

@Test
public void testDefaultInstanceSpecifiesCorrectHost() {
StorageOptions opts1 = StorageOptions.getDefaultInstance();

assertThat(opts1.getHost()).isEqualTo("https://storage.googleapis.com");
}
}