The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ozgwei (2) [Avatar] Offline
#1
Hi Chris,

Thanks for the great book! Our whole team loves your book and reference it regularly.

I'm using Spring 2 and obviously the AbstractSpringContextTests and its subclasses have been reworked.

Now I cannot compile AbstractDependencyInjectionSpringContextWithParentTests with the following errors:
* Cannot override the final getContext(Object) method from AbstractSpringContextTests.
* loadContexLocations(String[]) does not handle exception thrown by the superclass.

Is there any fix for this class?

Cheers,
alex
ozgwei (2) [Avatar] Offline
#2
Re: AbstractDependencyInjectionSpringContextWithParentTests not compiled
Making the following changes will pass the compilation:
@Override
protected ConfigurableApplicationContext loadContext(Object key) throws Exception {
ApplicationContext parent = getParentApplicationContext();
if (parent == null) {
assertNotNull("key", key);
return super.loadContext(key);
} else
return (ConfigurableApplicationContext) parent;
}

@Override
protected ConfigurableApplicationContext loadContextLocations(String[] locations) throws Exception {
ApplicationContext parent = getParentApplicationContext();
if (parent != null)
throw new RuntimeException("never here");
else
return super.loadContextLocations(locations);
}