bebbffdcfed726ee80ab0d4f681bc64a9eea8d56
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.odlux.test;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertNotNull;
22 import static org.junit.Assert.assertTrue;
23
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl;
26 import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
27 import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader;
28
29 public class TestBundleLoaderImpl {
30
31     @Test
32     public void test() {
33         OdluxBundleLoader loader = OdluxBundleLoaderImpl.getInstance();
34         int loaded = loader.getNumberOfBundles();
35
36         OdluxBundle bundle1 = new OdluxBundle();
37         bundle1.setBundleName("b1");
38         bundle1.setIndex(0);
39         bundle1.setLoader(loader);
40         OdluxBundle bundle2 = new OdluxBundle();
41         bundle2.setBundleName("b2");
42         bundle2.setIndex(55);
43         bundle2.setLoader(loader);
44         bundle1.initialize();
45         bundle2.initialize();
46         assertNotNull(bundle1.getResourceFileContent("index.html"));
47         assertNotNull(bundle2.getResourceFileContent("index2.html"));
48         assertEquals(loaded+2, loader.getNumberOfBundles());
49         loader.addBundle(bundle1);
50         loader.addBundle(bundle2);
51         assertEquals(loaded+2, loader.getNumberOfBundles());
52         loader.removeBundle(bundle1);
53         loader.removeBundle(bundle2);
54         assertEquals(loaded, loader.getNumberOfBundles());
55
56         assertTrue(bundle1.hasResource("index.html"));
57         assertTrue(bundle2.hasResource("index2.html"));
58         assertNotNull(bundle1.getLoader());
59         assertEquals(0,bundle1.getIndex());
60         bundle1.clean();
61         bundle2.clean();
62         assertEquals(loaded,loader.getNumberOfBundles());
63
64
65     }
66 }