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.messagerouter.msgrtr.mr.test.dme2;
25 import java.net.URISyntaxException;
26 import java.util.HashMap;
27 import java.util.Properties;
29 import org.apache.log4j.Logger;
30 import org.onap.dmaap.messagerouter.msgrtr.mr.test.dmaap.DmaapAdminTest;
32 import junit.framework.TestCase;
34 import com.att.aft.dme2.api.DME2Client;
35 import com.att.aft.dme2.api.DME2Exception;
37 public class DME2AdminTest extends TestCase {
38 private static final Logger LOGGER = Logger.getLogger(DME2AdminTest.class);
42 protected Properties props;
44 protected HashMap<String, String> hm;
46 protected String methodType;
48 protected String contentType;
50 protected String user;
52 protected String password;
55 protected void setUp() throws Exception {
57 System.setProperty("AFT_DME2_CLIENT_SSL_INCLUDE_PROTOCOLS", "SSLv3,TLSv1,TLSv1.1");
58 System.setProperty("AFT_DME2_CLIENT_IGNORE_SSL_CONFIG", "false");
59 System.setProperty("AFT_DME2_CLIENT_KEYSTORE_PASSWORD", "changeit");
60 this.props = LoadPropertyFile.getPropertyFileDataProducer();
61 String latitude = props.getProperty("Latitude");
62 String longitude = props.getProperty("Longitude");
63 String version = props.getProperty("Version");
64 String serviceName = props.getProperty("ServiceName");
65 serviceName = "dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/admin";
66 String env = props.getProperty("Environment");
67 String partner = props.getProperty("Partner");
68 String protocol = props.getProperty("Protocol");
70 methodType = props.getProperty("MethodTypeGet");
71 contentType = props.getProperty("contenttype");
72 user = props.getProperty("user");
73 password = props.getProperty("password");
76 this.url = protocol + "://" + serviceName + "?" + "version=" + version + "&" + "envContext=" + env + "&"
77 + "routeOffer=" + partner + "&partner=BOT_R";
78 LoadPropertyFile.loadAFTProperties(latitude, longitude);
79 hm = new HashMap<String, String>();
80 hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
81 hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
82 hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
85 public void testGetConsumerCache() {
86 LOGGER.info("test case consumer cache started");
88 String subContextPath = props.getProperty("SubContextPathGetAdminConsumerCache");
90 DME2Client sender = new DME2Client(new URI(url), 5000L);
91 sender.setAllowAllHttpReturnCodes(true);
92 sender.setMethod(methodType);
93 sender.setSubContext(subContextPath);
94 sender.setPayload("");
95 sender.addHeader("Content-Type", contentType);
97 sender.addHeader("X-CambriaAuth", "user1:7J49YriFlyRgebyOsSJhZvY/C60=");
98 sender.addHeader("X-X-CambriaDate", "2016-10-18T09:56:04-05:00");
100 //sender.setCredentials(user, password);
101 sender.setHeaders(hm);
102 LOGGER.info("Getting consumer Cache");
103 String reply = sender.sendAndWait(5000L);
104 System.out.println(reply);
105 assertTrue(LoadPropertyFile.isValidJsonString(reply));
106 assertNotNull(reply);
107 LOGGER.info("response from consumer cache=" + reply);
109 } catch (DME2Exception e) {
111 } catch (URISyntaxException e) {
113 } catch (Exception e) {
118 public void ttestDropConsumerCache() {
119 LOGGER.info("Drom consumer cache initiated");
121 String subContextPath = props.getProperty("SubContextPathDropAdminConsumerCache");
124 DME2Client sender = new DME2Client(new URI(url), 5000L);
125 sender.setAllowAllHttpReturnCodes(true);
126 sender.setMethod(methodType);
127 sender.setSubContext(subContextPath);
128 sender.setPayload("");
129 sender.addHeader("Content-Type", contentType);
130 sender.setCredentials(user, password);
131 sender.setHeaders(hm);
133 LOGGER.info("Dropping consumer cache...........");
134 String reply = sender.sendAndWait(5000L);
136 // assertTrue(LoadPropertyFile.isValidJsonString(reply));
137 assertNotNull(reply);
138 LOGGER.info("response =" + reply);
139 } catch (DME2Exception e) {
141 } catch (URISyntaxException e) {
143 } catch (Exception e) {