aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/MockTesterClient.java
blob: 389887da9b1e8435207b1762236c5f42420abfcc (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;

import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.vespa.config.server.http.TesterClient;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

/**
 * @author hmusum
 */
public class MockTesterClient extends TesterClient {

    @Override
    public HttpResponse getStatus(String testerHostname, int port) {
        return new HttpResponse(200) {
            @Override
            public void render(OutputStream outputStream) throws IOException {
                outputStream.write("OK".getBytes(StandardCharsets.UTF_8));
            }
        };
    }

    @Override
    public HttpResponse getLog(String testerHostname, int port, Long after) {
        return new HttpResponse(200) {
            @Override
            public void render(OutputStream outputStream) throws IOException {
                outputStream.write("log".getBytes(StandardCharsets.UTF_8));
            }
        };
    }

    @Override
    public HttpResponse startTests(String testerHostname, int port, String suite, byte[] config) {
        return new HttpResponse(200) {
            @Override
            public void render(OutputStream outputStream) { }
        };
    }

    @Override
    public HttpResponse isTesterReady(String testerHostname, int port) {
        return new HttpResponse(200) {
            @Override
            public void render(OutputStream outputStream) throws IOException {
                outputStream.write("{ \"message\": \"OK\" } ".getBytes(StandardCharsets.UTF_8));
            }
        };
    }

    @Override
    public HttpResponse getReport(String testerHostname, int port) {
        return new HttpResponse(200) {
            @Override
            public void render(OutputStream outputStream) throws IOException {
                outputStream.write("report".getBytes(StandardCharsets.UTF_8));
            }
        };
    }

}