[
https://issues.apache.org/jira/browse/WICKET-2269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707874#action_12707874
]
Martin Makundi commented on WICKET-2269:
----------------------------------------
It might still be that the behavior behaves wrong if only the
instanceof check passes.
For example, in my situation, I have a Wicket HTML report TABLE whose
colspan and rowspan configurations I need to test at runtime. The only
workaround I came up with was this: IModel<?> model = (IModel<?>)
getReplaceModelMethod.invoke(behavior);
If there is no other way to extract this information, maybe a small
modification would be in order in the wickettester classes. The
getReplaceModel -method is protected so one option would be to simply
have some test helper class which has access... but the actual method
for calling this helper could be in wicketTester.
For example,
wicketTester.assertAttributeModifier(component, key, value) ...
wicketTester.assertAttributeModifier(path, key, value) ...
**
Martin
> A small change would allow WicketTesting attributeModifiers
> -----------------------------------------------------------
>
> Key: WICKET-2269
> URL: https://issues.apache.org/jira/browse/WICKET-2269
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Martin Makundi
> Assignee: Igor Vaynberg
> Original Estimate: 5h
> Remaining Estimate: 5h
>
> The workaround is as follows, because AttributeModifier.getReplaceModel
> -method is protected. This operation should somehow be supported in
> WicketTester:
> Workaround:
> private final static Method getReplaceModelMethod;
> static {
> try {
> getReplaceModelMethod =
> AttributeModifier.class.getDeclaredMethod("getReplaceModel");
> getReplaceModelMethod.setAccessible(true);
> } catch (Exception e) {
> e.printStackTrace();
> throw new RuntimeException(e);
> }
> }
> public void assertAttribute(String message, String expected, Component
> component, String attribute) {
> AttributeModifier behavior = getAttributeModifier(component, attribute);
> if (behavior != null) {
> try {
> IModel<?> model = (IModel<?>) getReplaceModelMethod.invoke(behavior);
> assertEquals(message, expected, model.getObject().toString());
> return;
> } catch (Exception e) {
> throw new RuntimeException(e);
> }
> }
>
> fail("Attribute not found.");
> }
> Usage example:
> assertAttribute("3", tableFooterCellWebMarkupComponent,
> WebPageConstants.COLSPAN);
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.