Second part of onap rename
[appc.git] / appc-client / client-lib / src / test / java / org / openecomp / appc / client / impl / protocol / TestAsyncProtocolImplMissingProps.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.client.impl.protocol;
26
27 import org.onap.appc.client.impl.core.MessageContext;
28 import org.onap.appc.client.impl.protocol.AsyncProtocol;
29 import org.onap.appc.client.impl.protocol.AsyncProtocolImpl;
30 import org.onap.appc.client.impl.protocol.RetrieveMessageCallback;
31 import org.junit.Assert;
32 import org.junit.Test;
33
34 import java.io.IOException;
35 import java.io.InputStream;
36 import java.util.Properties;
37
38 public class TestAsyncProtocolImplMissingProps {
39
40     private static AsyncProtocol protocol;
41
42     private static class TestCallback implements RetrieveMessageCallback {
43
44         public void onResponse(String payload, MessageContext context) {
45             Assert.assertFalse("bad Callback !",false);
46         }
47     }
48
49     @Test
50     /**
51      * protocol should throw illegal argument exception due to null properties
52      */
53     public void testSetUpMissingProps() {
54
55         Properties props = new Properties();
56         String propFileName = "ueb.missing.properties";
57
58         InputStream input = TestAsyncProtocolImplMissingProps.class.getClassLoader().getResourceAsStream(propFileName);
59
60         try {
61             props.load(input);
62         } catch (IOException e) {
63             Assert.assertFalse(e.getMessage(),false);
64         }
65
66         protocol = new AsyncProtocolImpl();
67         try {
68             protocol.init(props, new TestCallback());
69         } catch (IllegalArgumentException e) {
70             Assert.assertTrue(true);
71         } catch (Exception e) {
72             Assert.assertFalse(e.getMessage(),false);
73         }
74     }
75 }