50
50
public class QueryResourceTest
51
51
{
52
52
private static final ObjectMapper jsonMapper = new DefaultObjectMapper ();
53
- public static final ServerConfig serverConfig = new ServerConfig (){
53
+ public static final ServerConfig serverConfig = new ServerConfig ()
54
+ {
54
55
@ Override
55
- public int getNumThreads (){
56
+ public int getNumThreads ()
57
+ {
56
58
return 1 ;
57
59
}
60
+
58
61
@ Override
59
- public Period getMaxIdleTime (){
62
+ public Period getMaxIdleTime ()
63
+ {
60
64
return Period .seconds (1 );
61
65
}
62
66
};
@@ -90,17 +94,21 @@ public <T> QueryRunner<T> getQueryRunnerForSegments(
90
94
};
91
95
92
96
private static final ServiceEmitter noopServiceEmitter = new NoopServiceEmitter ();
97
+
93
98
@ BeforeClass
94
- public static void staticSetup (){
99
+ public static void staticSetup ()
100
+ {
95
101
com .metamx .emitter .EmittingLogger .registerEmitter (noopServiceEmitter );
96
102
}
103
+
97
104
@ Before
98
105
public void setup ()
99
106
{
100
107
EasyMock .expect (testServletRequest .getContentType ()).andReturn (MediaType .APPLICATION_JSON );
101
108
EasyMock .expect (testServletRequest .getRemoteAddr ()).andReturn ("localhost" ).anyTimes ();
102
109
EasyMock .replay (testServletRequest );
103
110
}
111
+
104
112
private static final String simpleTimeSeriesQuery = "{\n "
105
113
+ " \" queryType\" : \" timeseries\" ,\n "
106
114
+ " \" dataSource\" : \" mmx_metrics\" ,\n "
@@ -115,6 +123,7 @@ public void setup()
115
123
+ " }\n "
116
124
+ " ]\n "
117
125
+ "}" ;
126
+
118
127
@ Test
119
128
public void testGoodQuery () throws IOException
120
129
{
@@ -126,10 +135,15 @@ public void testGoodQuery() throws IOException
126
135
new NoopServiceEmitter (),
127
136
new NoopRequestLogger (),
128
137
new QueryManager ()
129
- );
130
- Response respone = queryResource .doPost (new ByteArrayInputStream (simpleTimeSeriesQuery .getBytes ("UTF-8" )), null /*pretty*/ , testServletRequest );
138
+ );
139
+ Response respone = queryResource .doPost (
140
+ new ByteArrayInputStream (simpleTimeSeriesQuery .getBytes ("UTF-8" )),
141
+ null /*pretty*/ ,
142
+ testServletRequest
143
+ );
131
144
Assert .assertNotNull (respone );
132
145
}
146
+
133
147
@ Test
134
148
public void testBadQuery () throws IOException
135
149
{
@@ -143,7 +157,11 @@ public void testBadQuery() throws IOException
143
157
new NoopRequestLogger (),
144
158
new QueryManager ()
145
159
);
146
- Response respone = queryResource .doPost (new ByteArrayInputStream ("Meka Leka Hi Meka Hiney Ho" .getBytes ("UTF-8" )), null /*pretty*/ , testServletRequest );
160
+ Response respone = queryResource .doPost (
161
+ new ByteArrayInputStream ("Meka Leka Hi Meka Hiney Ho" .getBytes ("UTF-8" )),
162
+ null /*pretty*/ ,
163
+ testServletRequest
164
+ );
147
165
Assert .assertNotNull (respone );
148
166
Assert .assertEquals (Response .Status .INTERNAL_SERVER_ERROR .getStatusCode (), respone .getStatus ());
149
167
}
0 commit comments