bd2acf73ab2b8e48446666b251da40b4c48ec99d
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.resmanagement.common.util.restclient;
18
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21
22 import org.junit.After;
23 import org.junit.AfterClass;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28
29 import mockit.Mock;
30 import mockit.MockUp;
31 import mockit.integration.junit4.JMockit;
32
33 /**
34  * <br/>
35  * <p>
36  * </p>
37  * 
38  * @author
39  * @version
40  */
41 @RunWith(JMockit.class)
42 public class TestRestfulFactory {
43
44     /**
45      * <br/>
46      * 
47      * @throws java.lang.Exception
48      * @since
49      */
50     @BeforeClass
51     public static void setUpBeforeClass() throws Exception {
52     }
53
54     /**
55      * <br/>
56      * 
57      * @throws java.lang.Exception
58      * @since
59      */
60     @AfterClass
61     public static void tearDownAfterClass() throws Exception {
62     }
63
64     /**
65      * <br/>
66      * 
67      * @throws java.lang.Exception
68      * @since
69      */
70     @Before
71     public void setUp() throws Exception {
72     }
73
74     /**
75      * <br/>
76      * 
77      * @throws java.lang.Exception
78      * @since
79      */
80     @After
81     public void tearDown() throws Exception {
82     }
83
84     /**
85      * <br/>
86      * 
87      * @since
88      */
89     @Test
90     public void testGetRestInstance() {
91         Restful instance = RestfulFactory.getRestInstance("https");
92         assertNull(instance);
93         new MockUp<HttpRest>() {
94
95             @Mock
96             public void initHttpRest(final RestfulOptions option) throws ServiceException {
97                 throw new ServiceException();
98             }
99
100         };
101         instance = RestfulFactory.getRestInstance("http");
102         assertNotNull(instance);
103
104         instance = RestfulFactory.getRestInstance("http");
105         assertNotNull(instance);
106     }
107 }