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
 
  10  * http://www.apache.org/licenses/LICENSE-2.0
 
  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
 
  16  * ============LICENSE_END==========================================================================
 
  18 package org.onap.ccsdk.features.sdnr.odlux.test;
 
  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;
 
  28 public class TestBundleLoaderImpl {
 
  32         OdluxBundleLoader loader = OdluxBundleLoaderImpl.getInstance();
 
  33         int loaded = loader.getNumberOfBundles();
 
  35         OdluxBundle bundle1 = new OdluxBundle();
 
  36         bundle1.setBundleName("b1");
 
  38         bundle1.setLoader(loader);
 
  39         OdluxBundle bundle2 = new OdluxBundle();
 
  40         bundle2.setBundleName("b2");
 
  42         bundle2.setLoader(loader);
 
  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());
 
  55         assertTrue(bundle1.hasResource("index.html"));
 
  56         assertTrue(bundle2.hasResource("index2.html"));
 
  57         assertNotNull(bundle1.getLoader());
 
  58         assertEquals(0, bundle1.getIndex());
 
  61         assertEquals(loaded, loader.getNumberOfBundles());