2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dmaap.dbcapi.client;
22 import static org.junit.Assert.assertTrue;
25 import java.io.FileInputStream;
26 import java.io.FileNotFoundException;
27 import java.io.InputStream;
28 import java.util.ArrayList;
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.dmaap.dbcapi.model.ApiError;
33 import org.onap.dmaap.dbcapi.model.DR_Pub;
34 import org.onap.dmaap.dbcapi.model.DR_Sub;
35 import org.onap.dmaap.dbcapi.model.DcaeLocation;
36 import org.onap.dmaap.dbcapi.model.Feed;
37 import org.onap.dmaap.dbcapi.service.DcaeLocationService;
38 import org.onap.dmaap.dbcapi.service.MR_ClusterService;
39 import org.onap.dmaap.dbcapi.service.TopicService;
40 import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
41 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
43 public class DrProvConnectionTest {
45 private static final String fmt = "%24s: %s%n";
46 private static DmaapObjectFactory factory = new DmaapObjectFactory();
48 ReflectionHarness rh = new ReflectionHarness();
51 MR_ClusterService mcs;
55 public void setUp() throws Exception {
56 ns = new DrProvConnection();
60 public void tearDown() throws Exception {
68 rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
74 String v = "Validate";
75 rh.reflect( "org.onap.dmaap.dbcapi.aaf.client.DrProvConnection", "set", v );
81 String locname = "central-demo";
83 DcaeLocationService dls = new DcaeLocationService();
84 DcaeLocation loc = factory.genDcaeLocation( "central" );
85 dls.addDcaeLocation( loc );
87 ApiError err = new ApiError();
88 String[] hl = { "host1", "host2", "host3" };
89 ns.makeFeedConnection( );
90 ns.makeFeedConnection( "01" );
91 ns.makeSubPostConnection( "part0/part1/part2/part3/part4" );
92 ns.makeSubPutConnection( "44" );
93 ns.makeIngressConnection( "01", "aUser", "10.10.10.10", "aNode" );
94 ns.makeEgressConnection( "01", "aNode" );
95 ns.makeNodesConnection( "someVar" );
96 Feed feed = new Feed( "dgl feed 1" ,
98 "dgl feed 1 for testing",
102 ArrayList<DR_Pub> pubs = new ArrayList<DR_Pub>();
103 pubs.add( new DR_Pub( "central-demo" ) );
106 String resp = ns.doPostFeed( feed, err );
107 resp = ns.doPutFeed( feed, err );
108 resp = ns.doDeleteFeed( feed, err );
110 int i = ns.doXgressPost( err );
112 DR_Sub sub = factory.genDrSub( "central", feed.getFeedId() );
113 assertTrue( sub != null );
114 String sr = ns.doPostDr_Sub( sub, err );
117 - create a new DR_Sub based on a simulated response
118 - update using ns.doPutDr_Sub( sub, err );
123 public void test4() {
124 ApiError err = new ApiError();
125 String resp = ns.doGetNodes( err );
126 ns.makeNodesConnection( "someVar", "host1|host2" );
127 resp = ns.doPutNodes( err );
129 InputStream is = new FileInputStream(new File("/src/test/resources/dmaapbc.properties"));
130 String body = ns.bodyToString( is );
131 } catch ( FileNotFoundException fnfe ) {