[DMAAP-BC] Fix failing jenkins
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / client / DrProvConnectionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.onap.dmaap.dbcapi.client;
21
22 import static org.junit.Assert.assertTrue;
23
24 import java.io.File;
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;
42
43 public class DrProvConnectionTest {
44
45         private static final String  fmt = "%24s: %s%n";
46         private static DmaapObjectFactory factory = new DmaapObjectFactory();
47
48         ReflectionHarness rh = new ReflectionHarness();
49
50         DrProvConnection ns;
51         MR_ClusterService mcs;
52         TopicService ts;
53
54         @Before
55         public void setUp() throws Exception {
56                 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
57                 ns = new DrProvConnection();
58         }
59
60         @After
61         public void tearDown() throws Exception {
62         }
63
64
65         @Test
66         public void test1() {
67                 rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "get", "idNotSet@namespaceNotSet:pwdNotSet" );
68         }
69
70         @Test
71         public void test2() {
72                 String v = "Validate";
73                 rh.reflect( "org.onap.dmaap.dbcapi.client.DrProvConnection", "set", v );
74
75         }
76
77         @Test
78         public void test3() {
79                 String locname = "central-demo";
80
81                 DcaeLocationService dls = new DcaeLocationService();
82                 DcaeLocation loc = factory.genDcaeLocation( "central" );
83                 dls.addDcaeLocation( loc );
84
85                 ApiError err = new ApiError();
86                 String[] hl = { "host1", "host2", "host3" };
87                 ns.makeFeedConnection( );
88                 ns.makeFeedConnection( "01" );
89                 ns.makeSubPostConnection( "part0/part1/part2/part3/part4" );
90                 ns.makeSubPutConnection( "44" );
91                 ns.makeIngressConnection( "01", "aUser", "10.10.10.10", "aNode" );
92                 ns.makeEgressConnection( "01", "aNode" );
93                 ns.makeNodesConnection( "someVar" );
94                 Feed feed = new Feed( "dgl feed 1" ,
95                                 "v1.0",
96                                 "dgl feed 1 for testing",
97                                 "TEST",
98                                 "unclassified"
99                     );
100             ArrayList<DR_Pub> pubs = new ArrayList<DR_Pub>();
101             pubs.add( new DR_Pub( "central-demo" ) );
102             feed.setPubs(pubs);
103
104                 String resp = ns.doPostFeed( feed, err );
105                 resp = ns.doPutFeed( feed, err );
106                 resp = ns.doDeleteFeed( feed, err );
107
108                 int i = ns.doXgressPost( err );
109
110                 DR_Sub sub = factory.genDrSub( "central", feed.getFeedId() );
111                 assertTrue( sub != null );
112                 String sr = ns.doPostDr_Sub( sub, err );
113                 /*
114                  * TODO:
115                         - create a new DR_Sub based on a simulated response
116                         - update using ns.doPutDr_Sub( sub, err );
117                  */
118         }
119
120         @Test
121         public void test4() {
122                 ApiError err = new ApiError();
123                 String resp = ns.doGetNodes( err );
124                 ns.makeNodesConnection( "someVar", "host1|host2" );
125                 resp = ns.doPutNodes( err );
126                 try {
127                         InputStream is = new FileInputStream(new File("/src/test/resources/dmaapbc.properties"));
128                         String body = ns.bodyToString( is );
129                 } catch ( FileNotFoundException fnfe ) {
130                 }
131         }
132
133 }
134