3d817a2d202c739e5e1c254c391d4bba36875e15
[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 import org.junit.Test;
24 import org.onap.ccsdk.features.sdnr.wt.odlux.OdluxBundleLoaderImpl;
25 import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
26 import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundleLoader;
27
28 public class TestBundleLoaderImpl {
29
30     @Test
31     public void test() {
32         OdluxBundleLoader loader = OdluxBundleLoaderImpl.getInstance();
33         int loaded = loader.getNumberOfBundles();
34
35         OdluxBundle bundle1 = new OdluxBundle();
36         bundle1.setBundleName("b1");
37         bundle1.setIndex(0);
38         bundle1.setLoader(loader);
39         OdluxBundle bundle2 = new OdluxBundle();
40         bundle2.setBundleName("b2");
41         bundle2.setIndex(55);
42         bundle2.setLoader(loader);
43         bundle1.initialize();
44         bundle2.initialize();
45         assertNotNull(bundle1.getResourceFileContent("index.html"));
46         assertNotNull(bundle2.getResourceFileContent("index2.html"));
47         assertEquals(loaded + 2, loader.getNumberOfBundles());
48         loader.addBundle(bundle1);
49         loader.addBundle(bundle2);
50         assertEquals(loaded + 2, loader.getNumberOfBundles());
51         loader.removeBundle(bundle1);
52         loader.removeBundle(bundle2);
53         assertEquals(loaded, loader.getNumberOfBundles());
54
55         assertTrue(bundle1.hasResource("index.html"));
56         assertTrue(bundle2.hasResource("index2.html"));
57         assertNotNull(bundle1.getLoader());
58         assertEquals(0, bundle1.getIndex());
59         bundle1.clean();
60         bundle2.clean();
61         assertEquals(loaded, loader.getNumberOfBundles());
62
63
64     }
65 }