Prevent unit tests from failing for machines with a non-US default Locale

This commit is contained in:
Sophiah Ho 2021-07-27 13:01:48 -04:00 committed by GitHub
parent 0117fc12c7
commit 1fd1207bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -11,6 +11,8 @@ import io.dropwizard.logging.AbstractOutputStreamAppenderFactory;
import org.glassfish.jersey.internal.MapPropertiesDelegate;
import org.glassfish.jersey.server.ContainerRequest;
import org.glassfish.jersey.server.ContainerResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.whispersystems.websocket.WebSocketSecurityContext;
import org.whispersystems.websocket.session.ContextPrincipal;
@ -22,12 +24,25 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public class WebSocketRequestLogTest {
private final static Locale ORIGINAL_DEFAULT_LOCALE = Locale.getDefault();
@Before
public void beforeEachTest() {
Locale.setDefault(Locale.ENGLISH);
}
@After
public void afterEachTest() {
Locale.setDefault(ORIGINAL_DEFAULT_LOCALE);
}
@Test
public void testLogLineWithoutHeaders() throws InterruptedException {
WebSocketSessionContext sessionContext = mock(WebSocketSessionContext.class);