I override the test method in my managers. When testing,  I get a
ClassCastException. There is no problem in production state, that is
jetty:run-war runs perfectly well. So, the problem must be related to the
mocks in test classes. 

Here is my manager class:
public class SurveyValueManagerImpl 
         extends GenericManagerImpl<SurveyValue, Long>
         implements SurveyValueManager { 

        [... some other methods ...]


        @Override
        @Transactional
        public SurveyValue save(SurveyValue surveyValue) {
        
           [... do something else ...]

           Object o = super.save(surveyValue);
        
           return (SurveyValue) o;
        }
}

The super save method returns successfully, but because I have to return
something of type SurveyValue, I need to cast the object to the SurveyValue
type. And that's the problem.

The test method is no surprise:

        @Test
        public void testSaveSurveyValue() {
                log.debug("testing saveSurveyValue");

                final SurveyValue surveyValue = new SurveyValue();
                // enter all required fields

                // set expected behavior on dao
                context.checking(new Expectations() {
                        {
                                one(dao).save(with(same(surveyValue)));
                        }
                });

                manager.save(surveyValue);
        }

Any ideas?
-- 
View this message in context: 
http://www.nabble.com/ClassCastException-when-testing-overriden-save-method-in-*Manager-tp17748663s2369p17748663.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to