hosea commented on code in PR #1313:
URL: https://github.com/apache/wicket/pull/1313#discussion_r2570209986


##########
wicket-spring/src/test/java/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactoryTest.java:
##########
@@ -78,36 +78,4 @@ public void testCache() throws Exception
                proxy2 = factory.getFieldValue(field, obj);
                assertSame(proxy1, proxy2);
        }
-
-       /**
-        * @throws Exception
-        */
-       @Test
-       public void testFailsIfBeanWithIdIsNotFound() throws Exception
-       {
-               InjectableWithReferenceToNonexistingBean obj = new 
InjectableWithReferenceToNonexistingBean();
-               Field field = obj.getClass().getDeclaredField("nonExisting");
-               try
-               {
-                       final Bean bean = (Bean)factory.getFieldValue(field, 
obj);
-                       /*
-                        * returned bean will not be null even though the bean 
is not found. what we get instead
-                        * is a proxy. we invoke a method on the proxy in order 
to cause it to try to locate the
-                        * bean and that is when it will fail
-                        */

Review Comment:
   Removed test did something different from explanation. In fact, the 
try/catch covers the factory.getFieldValue(...)-call and the 
bean.method()-call. If any of both fails, the test is successfull. So the test 
does not guarantee, that factory.getFieldValue(...) returns a value. But it 
tells you in the comment.
   In reality: factory.getFieldValue(...) fails. And this makes the test 
successfull. 
   
   If the test covered what it says, it should have been implemented like this:
   ```
   final Bean bean = (Bean) factory.getFieldValue(field, obj);
   assertNotNull(bean);
   try {
     bean.method();
     fail();
   } catch` (RuntimeException e) {
     return;
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to