Package org.strecks.form.controller

Source Code of org.strecks.form.controller.TestDelegatingFormBinding

package org.strecks.form.controller;

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

import java.util.HashMap;
import java.util.Map;

import org.strecks.bind.handler.BindHandler;
import org.strecks.bind.internal.BindConvertInfo;
import org.strecks.converter.Converter;
import org.strecks.converter.handler.DefaultConversionHandler;
import org.strecks.form.impl.SimpleStrutsForm;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
* @author Phil Zoio
*/
public class TestDelegatingFormBinding
{

  private BindHandler bindHandler;

  private SimpleStrutsForm simpleForm;

  private DelegatingForm form;

  @BeforeMethod
  public void setUp()
  {

    simpleForm = new SimpleStrutsForm();
    bindHandler = createStrictMock(BindHandler.class);
    Map<String, BindHandler> map = new HashMap<String, BindHandler>();
    map.put("prop", bindHandler);

    BindConvertInfo bci = new BindConvertInfo(map, new HashMap<String, Converter>(), new DefaultConversionHandler());

    form = new DelegatingForm(simpleForm);
    form.setBindConvertInfo(bci);

  }

  @Test
  public void testBindInwards()
  {

    bindHandler.bindInwards(simpleForm, null, null);
    replay(bindHandler);
    form.bindInwards(null);
    verify(bindHandler);

  }

  @Test
  public void testBindOutwards()
  {

    bindHandler.bindOutwards(simpleForm, null);
    replay(bindHandler);
    form.bindOutwards(null);
    verify(bindHandler);

  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void testNullBciOut()
  {

    form.setBindConvertInfo(null);
    form.bindOutwards(null);

  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void testNullBciIn()
  {

    form.setBindConvertInfo(null);
    form.bindInwards(null);

  }

}
TOP

Related Classes of org.strecks.form.controller.TestDelegatingFormBinding

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.