blob: 29199cf3ef984cb74f6055db052c67ae434d5475 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.result.test;
import com.yahoo.prelude.templates.SearchRendererAdaptor;
import com.yahoo.search.result.DefaultErrorHit;
import com.yahoo.search.result.ErrorMessage;
import java.io.IOException;
import java.io.StringWriter;
/**
* @author bratseth
*/
public class DefaultErrorHitTestCase extends junit.framework.TestCase {
@SuppressWarnings("null")
public void testErrorHitRenderingWithException() throws IOException {
NullPointerException cause=null;
try {
Object a=null;
a.toString();
}
catch (NullPointerException e) {
cause=e;
}
StringWriter w=new StringWriter();
SearchRendererAdaptor.simpleRenderDefaultErrorHit(w, new DefaultErrorHit("test", new ErrorMessage(79, "Myerror", "Mydetail", cause)));
String sep = System.getProperty("line.separator");
assertEquals(
"<errordetails>\n" +
" <error source=\"test\" error=\"Myerror\" code=\"79\">Mydetail\n" +
" <cause>\n" +
"java.lang.NullPointerException" + sep +
"\tat "
,w.toString().substring(0, 119+sep.length()));
}
}
|