Upgrade to latest oparent
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / client / MrTopicConnectionTest.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.MrTopicConnection;
23 import org.onap.dmaap.dbcapi.model.*;
24 import org.onap.dmaap.dbcapi.service.*;
25 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
26
27 import static org.junit.Assert.*;
28
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32 import java.util.List;
33 import java.util.ArrayList;
34 import java.io.InputStream;
35 import java.io.FileInputStream;
36 import java.io.FileNotFoundException;
37
38 public class MrTopicConnectionTest {
39
40         private static final String  fmt = "%24s: %s%n";
41
42         ReflectionHarness rh = new ReflectionHarness();
43
44         MrTopicConnection ns;
45         MR_ClusterService mcs;
46         TopicService ts;
47
48         @Before
49         public void setUp() throws Exception {
50                 ns = new MrTopicConnection( "aUser", "aPwd" );
51                 ts = new TopicService();
52                 mcs = new MR_ClusterService();
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.MrTopicConnection", "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.MrTopicConnection", "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 = new DcaeLocation( "CLLI1234", "central-onap", locname, "aZone", "10.10.10.0/24" );
81                 dls.addDcaeLocation( loc );
82
83                 ApiError err = new ApiError();
84                 String[] hl = { "host1", "host2", "host3" };
85                 MR_Cluster cluster = new MR_Cluster( locname, "localhost", "", hl );
86                 mcs.addMr_Cluster( cluster, err );
87                 ns.makeTopicConnection( cluster, "org.onap.dmaap.anInterestingTopic", "" );
88                 String msg = "{ 'key': '1234', 'val': 'hello world' }";
89                 ApiError e2 = ns.doPostMessage( msg );
90
91                 try {
92                         InputStream is = new FileInputStream( "./etc/dmaapbc.properties" );                             
93                         String body = ns.bodyToString( is );
94                 } catch ( FileNotFoundException fnfe ) {
95                 }
96
97         }
98
99
100
101 }
102