aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/templates/test/BoomTemplate.java
blob: 0bbc5151b40cbc88129c05c44f475d604c9f6f99 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.templates.test;

import java.io.IOException;
import java.io.Writer;

import com.yahoo.prelude.templates.Context;
import com.yahoo.prelude.templates.UserTemplate;

/**
 * Test template which throws a runtime exception in its footer.
 *
 * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
 */
@SuppressWarnings("rawtypes")
public class BoomTemplate extends UserTemplate {
    public BoomTemplate(String name, String mimeType, String encoding) {
        super(name, mimeType, encoding);
    }

    @Override
    public void error(Context context, Writer writer) throws IOException {
        // NOP
    }

    @Override
    public void footer(Context context, Writer writer) throws IOException {
        throw new RuntimeException("Boom!");
    }

    @Override
    public void header(Context context, Writer writer) throws IOException {
        writer.write("header");
    }

    @Override
    public void hit(Context context, Writer writer) throws IOException {
        // NOP
    }

    @Override
    public void hitFooter(Context context, Writer writer) throws IOException {
        // NOP
    }

    @Override
    public void noHits(Context context, Writer writer) throws IOException {
        // NOP
    }

}