summaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2021-01-21 13:28:18 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2021-01-21 14:22:25 +0100
commitb1bbb58449af091cf20f296ba19130b446d68022 (patch)
tree572838f05c7f0d081ed05d1b566d9d92377f4305 /container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
parent4c514714e3e739c66f0107629d44ef5e5877403a (diff)
Replace AccessLogEntry with non-blocking RequestLogEntry
Keep AccessLogEntry as interface for adding extra information in handlers, but use the new RequestLogEntry for access log serialization. Introduce new interface RequestLog that AccessLog class implements (to simplify unit testing). Rename AccessLogInterface to RequestLogHandler. Remove unused class AccessLogSampler.
Diffstat (limited to 'container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java')
-rw-r--r--container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java b/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
index 6498514c075..ae1076a4773 100644
--- a/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
+++ b/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
@@ -8,9 +8,10 @@ import com.yahoo.component.chain.Chain;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.jdisc.RequestHandlerTestDriver;
import com.yahoo.container.logging.AccessLogEntry;
-import com.yahoo.container.logging.AccessLogInterface;
import com.yahoo.container.protect.Error;
+import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
+import com.yahoo.jdisc.handler.ContentChannel;
import com.yahoo.jdisc.http.HttpRequest;
import com.yahoo.processing.Processor;
import com.yahoo.processing.execution.Execution;
@@ -23,11 +24,11 @@ import com.yahoo.processing.test.ProcessorLibrary;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -37,17 +38,16 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
+import static com.yahoo.jdisc.http.server.jetty.AccessLoggingRequestHandler.CONTEXT_KEY_ACCESS_LOG_ENTRY;
import static com.yahoo.processing.test.ProcessorLibrary.MapData;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.times;
/**
* Tests processing handler scenarios end to end.
@@ -83,18 +83,18 @@ public class ProcessingHandlerTestCase {
}
@Test
- public void processing_handler_stores_trace_log_values_in_the_access_log_entry() throws InterruptedException {
- ArgumentCaptor<AccessLogEntry> accessLogEntryCaptor = ArgumentCaptor.forClass(AccessLogEntry.class);
- AccessLogInterface accessLog = Mockito.mock(AccessLogInterface.class);
-
- driver = new ProcessingTestDriver(logValueChain, accessLog);
- driver.sendRequest("http://localhost/?chain=log-value").readAll();
-
- Mockito.verify(accessLog, times(1)).log(accessLogEntryCaptor.capture());
-
- AccessLogEntry entry = accessLogEntryCaptor.getValue();
- assertNotNull(entry);
- assertThat(entry.getKeyValues().get(LOG_KEY), is(Collections.singletonList(LOG_VALUE)));
+ public void processing_handler_stores_trace_log_values_in_the_access_log_entry() {
+ driver = new ProcessingTestDriver(logValueChain);
+ Request request = HttpRequest.newServerRequest(driver.jDiscDriver(), URI.create("http://localhost/?chain=log-value"), HttpRequest.Method.GET);
+ AccessLogEntry entry = new AccessLogEntry();
+ request.context().put(CONTEXT_KEY_ACCESS_LOG_ENTRY, entry);
+ RequestHandlerTestDriver.MockResponseHandler responseHandler = new RequestHandlerTestDriver.MockResponseHandler();
+ ContentChannel requestContent = request.connect(responseHandler);
+ requestContent.write(ByteBuffer.allocate(0), null);
+ requestContent.close(null);
+ request.release();
+ responseHandler.readAll();
+ assertThat(entry.getKeyValues().get(LOG_KEY), is(List.of(LOG_VALUE)));
}
@Test