Can you post the full stack trace? Matt
On Tue, Jun 17, 2008 at 6:13 AM, Martin Homik <[EMAIL PROTECTED]> wrote: > > Reproduced on the Person tutorial. Just add the following method to > PersonManagerImpl.java: > @Override > @Transactional > public Person save(Person person) { > /* do something else */ > > return super.save(person); > } > > > Any ideas, how to overcome this obstacle? What's the proper way to override > a save method in the manager? > > MH > > > > > Martin Homik wrote: > > > > In my managers, I override the save method. There is no problem in > > production state, that is jetty:run-war runs perfectly well. But in the > > test-cycle, I get a ClassCastException. So, the problem must be related > > to the mocks in the 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? > > > > PS: You should be able to reproduce the exception in the tutorial by > > overriding 'save' in PersonManagerImpl.java (I have not tested it, > > sorry): > > > > @Override > > @Transactional > > public Person save(Person person) { > > return (Person) super.save(person); > > } > > > > > > -- > View this message in context: > http://www.nabble.com/ClassCastException-when-testing-overriden-save-method-in-*Manager-tp17748663s2369p17900484.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] > >