Package de.odysseus.calyxo.control.base

Source Code of de.odysseus.calyxo.control.base.ControlModuleMappingsTest

/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.control.base;

import java.util.List;

import javax.servlet.ServletException;

import de.odysseus.calyxo.control.base.ControlModuleMapping;
import de.odysseus.calyxo.control.base.ControlModuleMappings;

import junit.framework.TestCase;

/**
*
* @author Christoph Beck
*/
public class ControlModuleMappingsTest extends TestCase {

  /**
   * Constructor for ControlModuleMappingsTest.
   * @param arg0
   */
  public ControlModuleMappingsTest(String arg0) {
    super(arg0);
  }

  public void testParseMappingsExtension() throws ServletException {
    ControlModuleMappings mappings =
      new ControlModuleMappings(getClass().getResourceAsStream("web.xml"));

    List list = mappings.getMappings("module1");
    assertEquals(1, list.size());
    ControlModuleMapping mapping = (ControlModuleMapping)list.get(0);
    assertNull(mapping.getPrefix());
    assertEquals(".module1", mapping.getExtension());
  }

  public void testParseMappingsPrefix() throws ServletException {
    ControlModuleMappings mappings =
      new ControlModuleMappings(getClass().getResourceAsStream("web.xml"));

    List list = mappings.getMappings("module2");
    assertEquals(1, list.size());
    ControlModuleMapping mapping = (ControlModuleMapping)list.get(0);
    assertEquals("/module2", mapping.getPrefix());
    assertNull(mapping.getExtension());
  }

  public void testParseMappingsPrefixExtension() throws ServletException {
    ControlModuleMappings mappings =
      new ControlModuleMappings(getClass().getResourceAsStream("web.xml"));

    List list = mappings.getMappings("module3");
    assertEquals(2, list.size());
    ControlModuleMapping mapping1 = (ControlModuleMapping)list.get(0);
    ControlModuleMapping mapping2 = (ControlModuleMapping)list.get(1);
    assertEquals("/module3", mapping1.getPrefix());
    assertNull(mapping1.getExtension());
    assertNull(mapping2.getPrefix());
    assertEquals(".module3", mapping2.getExtension());
  }

  public static void main(String[] args) {
    junit.textui.TestRunner.run(ControlModuleMappingsTest.class);
  }
}
TOP

Related Classes of de.odysseus.calyxo.control.base.ControlModuleMappingsTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.