[ 
https://issues.apache.org/jira/browse/WICKET-2269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707889#action_12707889
 ] 

Martin Makundi commented on WICKET-2269:
----------------------------------------


If I have several AttributeModifiers... I might not have the correct one.


All other components' models can be tested, why not attributemodifiers'?


I am JUnit testing.. but that's another topic alltogether.
Nevertheless, if I have several AttributeModifiers, I need to check it
is the correct one. Just any attribute and any value does not cut it.


Well.. I do not parse the component values, why should I have to parse
attributeModifiers? That sounds inconsistent.

**
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.

Reply via email to