1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package org.onap.dmaap.mr.test.dmaap;
24 import java.io.InputStream;
25 import java.util.Scanner;
27 import javax.ws.rs.client.Client;
28 import javax.ws.rs.client.ClientBuilder;
29 import javax.ws.rs.client.WebTarget;
30 import javax.ws.rs.core.Response;
32 import junit.framework.TestCase;
34 import org.apache.log4j.Logger;
35 import org.apache.http.HttpStatus;
37 public class DmaapMetricsTest {
38 /*private static final Logger LOGGER = Logger.getLogger(DmaapMetricsTest.class);
39 Client client = ClientBuilder.newClient();
40 WebTarget target = client.target(LoadPropertyFile.getPropertyFileData().getProperty("url"));
42 public void assertStatus(Response response) {
43 assertTrue(response.getStatus() == HttpStatus.SC_OK);
48 public void testMetrics() {
49 LOGGER.info("test case get all metrics");
50 target = target.path("/metrics");
51 Response response = target.request().get();
52 assertStatus(response);
53 LOGGER.info("successfully returned after fetching all metrics");
54 InputStream is = (InputStream) response.getEntity();
55 Scanner s = new Scanner(is);
56 s.useDelimiter("\\A");
57 String data = s.next();
59 LOGGER.info("DmaapMetricTest Test all metrics" + data);
62 // 2.get metrics by name
63 public void testMetricsByName() {
64 LOGGER.info("test case get metrics by name");
65 target = target.path("/metrics/startTime");
66 Response response = target.request().get();
67 assertStatus(response);
68 LOGGER.info("successfully returned after fetching specific metrics");
69 InputStream is = (InputStream) response.getEntity();
70 Scanner s = new Scanner(is);
71 s.useDelimiter("\\A");
72 String data = s.next();
74 LOGGER.info("DmaapMetricTest metrics by name" + data);