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.net.URLEncoder;
27 import java.util.HashMap;
28 import java.util.Properties;
30 import org.apache.log4j.Logger;
32 import junit.framework.TestCase;
34 import com.att.aft.dme2.api.DME2Client;
35 import com.att.aft.dme2.api.DME2Exception;
36 import com.att.mr.test.dmaap.DmaapAdminTest;
38 public class DME2ConsumerFilterTest extends TestCase {
39 private static final Logger LOGGER = Logger.getLogger(DME2ConsumerFilterTest.class);
41 public void testConsumerFilter() {
42 LOGGER.info("Test case consumer filter initiated");
44 Properties props = LoadPropertyFile.getPropertyFileDataProducer();
45 String latitude = props.getProperty("Latitude");
46 String longitude = props.getProperty("Longitude");
47 String version = props.getProperty("Version");
48 String serviceName = props.getProperty("ServiceName");
49 String env = props.getProperty("Environment");
50 String partner = props.getProperty("Partner");
51 String protocol = props.getProperty("Protocol");
52 String methodType = props.getProperty("MethodTypeGet");
53 String user = props.getProperty("user");
54 String password = props.getProperty("password");
55 String contenttype = props.getProperty("contenttype");
57 String url = protocol + "://DME2SEARCH/" + "service=" + serviceName + "/" + "version=" + version + "/"
58 + "envContext=" + env + "/" + "partner=" + partner;
59 LoadPropertyFile.loadAFTProperties(latitude, longitude);
60 HashMap<String, String> hm = new HashMap<String, String>();
61 hm.put("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
62 hm.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", "240000");
63 hm.put("AFT_DME2_EP_CONN_TIMEOUT", "5000");
66 // ..checking for topic exist is commented
67 // if (!topicTestObj.topicExist(url, props, hm)) {
68 // throw new Exception("Topic does not exist");
70 DME2Client sender = new DME2Client(new URI(url), 5000L);
71 sender.setAllowAllHttpReturnCodes(true);
72 sender.setMethod(methodType);
73 String subContextPathConsumer = props.getProperty("SubContextPathConsumer") + props.getProperty("newTopic")
74 + "/" + props.getProperty("group") + "/" + props.getProperty("id") + "?"
75 + props.getProperty("filterType");
77 sender.setSubContext(URLEncoder.encode(subContextPathConsumer, "UTF-8"));
78 sender.setPayload("");
80 sender.addHeader("Content-Type", contenttype);
81 sender.setCredentials(user, password);
82 sender.setHeaders(hm);
84 LOGGER.info("Consuming Message for Filter");
85 String reply = sender.sendAndWait(5000L);
87 LOGGER.info("Message received = " + reply);
89 } catch (DME2Exception e) {
91 } catch (URISyntaxException e) {
93 } catch (Exception e) {