blob: 5479f4db58ec9f01d55f0df412ae2d1262b6965a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container;
import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.handler.CompletionHandler;
import com.yahoo.jdisc.handler.ContentChannel;
import com.yahoo.jdisc.handler.ResponseHandler;
import com.yahoo.jdisc.service.AbstractClientProvider;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
* @author Christian Andersen
*/
public class MockClient extends AbstractClientProvider {
private final AtomicInteger counter = new AtomicInteger();
@Override
public ContentChannel handleRequest(Request request, ResponseHandler handler) {
counter.incrementAndGet();
final ContentChannel responseContentChannel = handler.handleResponse(new Response(200));
responseContentChannel.close(NOOP_COMPLETION_HANDLER);
return null;
}
public int getCounter() {
return counter.get();
}
private static final CompletionHandler NOOP_COMPLETION_HANDLER = new CompletionHandler() {
@Override
public void completed() {
// Ignored
}
@Override
public void failed(Throwable t) {
// Ignored
}
};
}
|