/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.internna.iwebmvc.core.xml;
import org.internna.iwebmvc.core.crypto.impl.DES3CiphererDecipherer;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockServletContext;
import static org.junit.Assert.*;
/**
*
* @author Jose Noheda
*/
public class MenuLoaderTest {
private MenuManagerImpl menuLoader;
@Before
public void setUp() throws Exception {
menuLoader = new MenuManagerImpl();
menuLoader.menuPath = "web/WEB-INF/resources/menu/menu.xml";
DES3CiphererDecipherer c = new DES3CiphererDecipherer();
c.init();
menuLoader.cipherer = c;
MockServletContext servletContext = new MockServletContext();
servletContext.setContextPath("/test");
menuLoader.setServletContext(servletContext);
menuLoader.init();
}
@Test
public void init() throws Exception {
assertNotNull("Menu bar loaded", menuLoader.getMenuBar());
assertTrue("Two menus", menuLoader.getMenuBar().getMenus().size() == 3);
assertEquals("Menu key", "CRUD", menuLoader.getMenuBar().getMenus().get(2).getKey());
assertNotNull("CRUD has subitems with menu", menuLoader.getMenuBar().getMenus().get(2).getItems().get(0).getMenu());
}
}