2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.dlux.loader;
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;
17 import java.util.List;
18 import java.util.Properties;
21 public class DluxLoaderIndexServletTest {
23 private DluxLoader dluxLoader = new DluxLoader();
26 public void testLoadModulePropertyFile() throws DluxLoaderException {
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',"));
42 public void testLoadIndexHTML() throws DluxLoaderException {
43 DluxLoaderIndexServlet indexServlet = new DluxLoaderIndexServlet(dluxLoader);
44 List<String> indexHTML = indexServlet.getIndexHTML();
45 Properties properties = indexServlet.getProp();
47 String jsReplace = properties.getProperty("javascriptReplaceString");
48 String cssReplace = properties.getProperty("cssReplaceString");
50 boolean containsJSReplace = false;
51 boolean containsCssReplace = false;
53 for(String line : indexHTML) {
54 if(line.contains(jsReplace)) {
55 containsJSReplace = true;
58 if(line.contains(cssReplace)) {
59 containsCssReplace = true;
63 Assert.assertTrue(containsCssReplace);
64 Assert.assertTrue(containsJSReplace);