eb1c9055cbe5f4baa0ca20c82a6dba8df8b346cc
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / dlux / loader / impl / src / test / java / org / opendaylight / dlux / loader / DluxLoaderIndexServletTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.dlux.loader;
10
11 import org.junit.Test;
12 import org.junit.Assert;
13 import org.opendaylight.dlux.loader.exception.DluxLoaderException;
14 import org.opendaylight.dlux.loader.implementation.DluxLoader;
15 import org.opendaylight.dlux.loader.implementation.DluxLoaderIndexServlet;
16
17 import java.util.List;
18 import java.util.Properties;
19
20
21 public class DluxLoaderIndexServletTest {
22
23     private DluxLoader dluxLoader = new DluxLoader();
24
25     @Test
26     public void testLoadModulePropertyFile() throws DluxLoaderException {
27
28         DluxLoaderIndexServlet indexServlet = new DluxLoaderIndexServlet(dluxLoader);
29         Properties properties = indexServlet.getProp();
30         String defineJS = properties.getProperty("defineJS");
31         Assert.assertNotNull(defineJS); 
32         Assert.assertTrue(defineJS.contains("'angular',"));
33         String requireJS = properties.getProperty("requireJS");
34         Assert.assertNotNull(requireJS);
35         Assert.assertTrue(requireJS.contains("common/config/env.module"));
36         String angularJS = properties.getProperty("angularJS");
37         Assert.assertNotNull(angularJS);
38         Assert.assertTrue(angularJS.contains("'ui.router',"));
39     }
40
41     @Test
42     public void testLoadIndexHTML() throws DluxLoaderException {
43         DluxLoaderIndexServlet indexServlet = new DluxLoaderIndexServlet(dluxLoader);
44         List<String> indexHTML = indexServlet.getIndexHTML();
45         Properties properties = indexServlet.getProp();
46
47         String jsReplace = properties.getProperty("javascriptReplaceString");
48         String cssReplace = properties.getProperty("cssReplaceString");
49
50         boolean containsJSReplace = false;
51         boolean containsCssReplace = false;
52
53         for(String line : indexHTML) {
54             if(line.contains(jsReplace)) {
55                 containsJSReplace = true;
56             }
57
58             if(line.contains(cssReplace)) {
59                 containsCssReplace = true;
60             }
61         }
62
63         Assert.assertTrue(containsCssReplace);
64         Assert.assertTrue(containsJSReplace);
65     }
66
67 }