use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class SessionTokenInterceptor_Test method setUp.
@Before
public void setUp() {
component = new MyBackingComponent();
interceptor = new SessionTokenInterceptor();
interceptor.setBackingComponent(component);
uic = new UIContextImpl();
uic.setUI(component);
uic.setEnvironment(new MockWEnvironment());
setActiveContext(uic);
request = new MockRequest();
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method testServiceRequestWithUndefinedTarget.
@Test(expected = SystemException.class)
public void testServiceRequestWithUndefinedTarget() {
// UI should change when a target is present in a request
MockRequest request = new MockRequest();
request.setParameter(Environment.TARGET_ID, "TargetableInterceptor_Test.testServiceRequestWithUndefinedTarget");
interceptor.serviceRequest(request);
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class WrongStepServerInterceptor_Test method setUp.
@Before
public void setUp() {
component = new MyBackingComponent();
interceptor = new WrongStepServerInterceptor();
interceptor.setBackingComponent(component);
uic = new UIContextImpl();
uic.setUI(component);
uic.setEnvironment(new MockWEnvironment());
setActiveContext(uic);
request = new MockRequest();
// Default to GET method
request.setMethod("GET");
originalConfig = Config.getInstance();
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class WMultiTextField_Test method testGetRequestValue.
@Test
public void testGetRequestValue() {
WMultiTextField field = new WMultiTextField();
setActiveContext(createUIContext());
field.setTextInputs(ENTERED_1);
// Empty Request - return current value
MockRequest request = new MockRequest();
Assert.assertTrue("Request value should be the current value for an empty request", Arrays.equals(ENTERED_1, field.getRequestValue(request)));
// Empty values on the request
String[] value = new String[] { "", null };
request = new MockRequest();
request.setParameter(field.getId(), value);
Assert.assertNull("Request value should be null for empty values on request", field.getRequestValue(request));
// Values on the request
request = new MockRequest();
request.setParameter(field.getId(), ENTERED_1_2);
Assert.assertTrue("Request value should be the values on the request", Arrays.equals(ENTERED_1_2, field.getRequestValue(request)));
// An empty string or null in the array should be removed
String[] inputs2 = new String[] { "", "x", "y", "", "", null, "z" };
request.setParameter(field.getId(), inputs2);
Assert.assertTrue("Request value should be the values on the request without the null and empty entries", Arrays.equals(new String[] { "x", "y", "z" }, field.getRequestValue(request)));
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class WNumberField_Test method processDoHandleRequestWithEmptyRequest.
/**
* @return a numberField processed with a request with an empty value
*/
private WNumberField processDoHandleRequestWithEmptyRequest() {
resetContext();
WNumberField numberField = new WNumberField();
String numberFieldId = numberField.getId();
numberField.setLocked(true);
// Empty Request
setActiveContext(createUIContext());
MockRequest request = new MockRequest();
request.setParameter(numberFieldId, "");
numberField.doHandleRequest(request);
return numberField;
}
Aggregations