jeudi 18 février 2016

Overriding Spring NamespaceHandler

I'm trying to test some classes using a test file as below

@RunWith( SpringJUnit4ClassRunner.class )    
@ContextConfiguration (classes = {MyConfig.class})
public abstract class MyTest extends AbstractJUnit4SpringContextTests{
    ......................  
}

@Configuration
@ImportResource({"classpath:xxxx.xml"})
public class MyConfig{
}

One of the beans in this xxxx.xml uses third party classes that use Spring schema-based extensions for configuring other beans.

The third party classes has customized NamespaceHandler that overrides default Spring NamespaceHandler. It also has its own /META-INF/spring.handlers in the third party jar file.

I am trying to overwrite one of the third party bean parser definition and hence created customized MyNamespaceHandler class and also registered it in the local project's /META-INF/spring.handlers.

When I run the test case it always uses the third party NamespaceHandler. My Eclipse classpath is setup to lookup first in the local project directory before the third party jar files.

Please advise how I can get the test case to use MyNamespaceHandler.

Aucun commentaire:

Enregistrer un commentaire