use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method testServiceRequestWithTarget.
@Test
public void testServiceRequestWithTarget() {
// Setup interceptor
MyApp root = new MyApp();
TargetableInterceptor interceptor = new TargetableInterceptor();
interceptor.attachUI(root);
UIContextHolder.getCurrent().setUI(root);
// UI should change when a target is present in a request
MockRequest request = new MockRequest();
request.setParameter(Environment.TARGET_ID, root.targetUI.getId());
// Check UI
Assert.assertSame("Incorrect UI returned", root, interceptor.getUI());
// Process Request
interceptor.serviceRequest(request);
// UI should be the target
Assert.assertSame("Incorrect new UI after serviceRequest with a target set", root.targetUI, interceptor.getUI());
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method testServiceRequestInvalidTarget.
@Test(expected = TargetableIdException.class)
public void testServiceRequestInvalidTarget() {
// Setup interceptor
MyApp root = new MyApp();
TargetableInterceptor interceptor = new TargetableInterceptor();
interceptor.setBackingComponent(root);
UIContextHolder.getCurrent().setUI(root);
// Invalid Target ID on request
MockRequest request = new MockRequest();
request.setParameter(Environment.TARGET_ID, "X-BAD");
// Process request
interceptor.serviceRequest(request);
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method testServiceRequestNoTarget.
@Test(expected = SystemException.class)
public void testServiceRequestNoTarget() {
MyApp root = new MyApp();
TargetableInterceptor interceptor = new TargetableInterceptor();
interceptor.attachUI(root);
interceptor.serviceRequest(new MockRequest());
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method testServiceRequestInvisibleTarget.
@Test(expected = TargetableIdException.class)
public void testServiceRequestInvisibleTarget() {
// Setup interceptor
MyApp root = new MyApp();
TargetableInterceptor interceptor = new TargetableInterceptor();
interceptor.setBackingComponent(root);
UIContextHolder.getCurrent().setUI(root);
// Setup request
MockRequest request = new MockRequest();
request.setParameter(Environment.TARGET_ID, root.targetUI.getId());
// Make target invisible
root.targetUI.setVisible(false);
// Process request
interceptor.serviceRequest(request);
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class SessionTokenInterceptor_Test method testServiceRequestCorrectToken.
@Test
public void testServiceRequestCorrectToken() {
// Setup interceptor
SessionTokenInterceptor interceptor = setupInterceptor();
MyBackingComponent component = (MyBackingComponent) interceptor.getBackingComponent();
UIContext uic = UIContextHolder.getCurrent();
MockRequest request = new MockRequest();
// Setup matching tokens on session and request
uic.getEnvironment().setSessionToken("X");
request.setParameter(Environment.SESSION_TOKEN_VARIABLE, "X");
// Process request
interceptor.serviceRequest(request);
Assert.assertTrue("Action phase should have occurred for corret token", component.handleRequestCalled);
}
Aggregations