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