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 com.att.mr.test.dme2;
25 import java.net.URISyntaxException;
26 import java.util.HashMap;
27 import java.util.Properties;
29 import org.apache.log4j.Logger;
31 import junit.framework.TestCase;
33 import com.att.aft.dme2.api.DME2Client;
34 import com.att.aft.dme2.api.DME2Exception;
35 import com.att.mr.test.dmaap.DmaapAdminTest;
36 //import com.ibm.disthub2.impl.client.PropSchema;
38 public class DME2AdminTest extends TestCase {
39 private static final Logger LOGGER = Logger.getLogger(DME2AdminTest.class);
43 protected Properties props;
45 protected HashMap<String, String> hm;
47 protected String methodType;
49 protected String contentType;
51 protected String user;
53 protected String password;
56 protected void setUp() throws Exception {
58 System.setProperty("AFT_DME2_CLIENT_SSL_INCLUDE_PROTOCOLS", "SSLv3,TLSv1,TLSv1.1");
59 System.setProperty("AFT_DME2_CLIENT_IGNORE_SSL_CONFIG", "false");
60 System.setProperty("AFT_DME2_CLIENT_KEYSTORE_PASSWORD", "changeit");
61 this.props = LoadPropertyFile.getPropertyFileDataProducer();
62 String latitude = props.getProperty("Latitude");
63 String longitude = props.getProperty("Longitude");
64 String version = props.getProperty("Version");
65 String serviceName = props.getProperty("ServiceName");
66 serviceName = "dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/admin";
67 String env = props.getProperty("Environment");
68 String partner = props.getProperty("Partner");
69 String protocol = props.getProperty("Protocol");
71 methodType = props.getProperty("MethodTypeGet");
72 contentType = props.getProperty("contenttype");
73 user = props.getProperty("user");
74 password = props.getProperty("password");
77 this.url = protocol + "://" + serviceName + "?" + "version=" + version + "&" + "envContext=" + env + "&"
78 + "routeOffer=" + partner + "&partner=BOT_R";
79 LoadPropertyFile.loadAFTProperties(latitude, longitude);
80 hm = new HashMap<String, String>();
81 hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
82 hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
83 hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
86 public void testGetConsumerCache() {
87 LOGGER.info("test case consumer cache started");
89 String subContextPath = props.getProperty("SubContextPathGetAdminConsumerCache");
91 DME2Client sender = new DME2Client(new URI(url), 5000L);
92 sender.setAllowAllHttpReturnCodes(true);
93 sender.setMethod(methodType);
94 sender.setSubContext(subContextPath);
95 sender.setPayload("");
96 sender.addHeader("Content-Type", contentType);
98 sender.addHeader("X-CambriaAuth", "user1:7J49YriFlyRgebyOsSJhZvY/C60=");
99 sender.addHeader("X-X-CambriaDate", "2016-10-18T09:56:04-05:00");
101 //sender.setCredentials(user, password);
102 sender.setHeaders(hm);
103 LOGGER.info("Getting consumer Cache");
104 String reply = sender.sendAndWait(5000L);
105 System.out.println(reply);
106 assertTrue(LoadPropertyFile.isValidJsonString(reply));
107 assertNotNull(reply);
108 LOGGER.info("response from consumer cache=" + reply);
110 } catch (DME2Exception e) {
112 } catch (URISyntaxException e) {
114 } catch (Exception e) {
119 public void ttestDropConsumerCache() {
120 LOGGER.info("Drom consumer cache initiated");
122 String subContextPath = props.getProperty("SubContextPathDropAdminConsumerCache");
125 DME2Client sender = new DME2Client(new URI(url), 5000L);
126 sender.setAllowAllHttpReturnCodes(true);
127 sender.setMethod(methodType);
128 sender.setSubContext(subContextPath);
129 sender.setPayload("");
130 sender.addHeader("Content-Type", contentType);
131 sender.setCredentials(user, password);
132 sender.setHeaders(hm);
134 LOGGER.info("Dropping consumer cache...........");
135 String reply = sender.sendAndWait(5000L);
137 // assertTrue(LoadPropertyFile.isValidJsonString(reply));
138 assertNotNull(reply);
139 LOGGER.info("response =" + reply);
140 } catch (DME2Exception e) {
142 } catch (URISyntaxException e) {
144 } catch (Exception e) {