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