Package org.strecks.dispatch.internal

Source Code of org.strecks.dispatch.internal.TestDispatchControllerHelper

/*
* Copyright 2005-2006 the original author or authors.
*
* 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 org.strecks.dispatch.internal;

import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createStrictMock;
import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify;

import java.lang.reflect.Method;

import org.apache.struts.action.ActionMapping;
import org.strecks.action.navigable.impl.SimpleDispatchAction;
import org.strecks.exceptions.ApplicationConfigurationException;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
* @author Phil Zoio
*/
public final class TestDispatchControllerHelper
{

  @Test
  public void testGetMethod()
  {
    DispatchControllerHelper helper = new DispatchControllerHelper();
    SimpleDispatchAction action = new SimpleDispatchAction();
    Method method1 = helper.getMethod(action, "insert");
    Method method2 = helper.getMethod(action, "insert");
    assert method1 == method2;
  }

  @Test
  public void testCheckParamter()
  {

    ActionMapping actionMapping = createStrictMock(ActionMapping.class);
    expect(actionMapping.getPath()).andReturn("/path");

    replay(actionMapping);

    DispatchControllerHelper helper = new DispatchControllerHelper();
    try
    {
      helper.checkParameterName(actionMapping, null);
    }
    catch (ApplicationConfigurationException e)
    {
      Assert.assertEquals(e.getMessage(), "The element 'parameter' is required to determine the method name, "
          + "and is required in required in path /path");
    }

    verify(actionMapping);
  }

}
TOP

Related Classes of org.strecks.dispatch.internal.TestDispatchControllerHelper

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.