google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

Spring doesn't correctly load configuration with GwtTest #140

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Does not work -- Exception after code -- I think its a class loader issue so 
I've included the POM.xml snippet after the exception.

@Configurable
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = 
{"classpath:/META-INF/spring/applicationContext.xml", 
        "classpath:/META-INF/spring/applicationContext-security.xml", 
        "classpath:/META-INF/spring/applicationContext-datasource-test.xml"})
public class formsGwtTest extends GwtTest  implements BeanFactoryAware {
}

Caused by: org.springframework.beans.FatalBeanException: Class 
[org.springframework.context.config.ContextNamespaceHandler] for namespace 
[http://www.springframework.org/schema/context] does not implement the 
[org.springframework.beans.factory.xml.NamespaceHandler] interface
        at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:126)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1333)

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
                <configuration>

                    <argLine>-Xmx512M -XX:MaxPermSize=128M</argLine>

                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <forkMode>always</forkMode>

                    <!-- Folder for generated testing stuff -->
                    <systemProperties>
                        <property>
                            <name>gwt.args</name>
                            <value>-out target/www</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>

What is the expected output? What do you see instead? NA

What version of the product are you using? On what operating system?
gwt-test-utils version 0.38 -- MacOS

Please provide any additional information below.

Just taking 'extends GwtTest' out of the class declaration allows Spring to 
load but then I get errors about not being able to run 'client' code of course.

A possible work around I will try today will be to explicitly load the spring 
context with java code using ClassPathXmlApplicationContext.

Original issue reported on code.google.com by Geoffrey...@gmail.com on 24 Apr 2012 at 2:53

GoogleCodeExporter commented 9 years ago
You didn't follow the wiki page : 
http://code.google.com/p/gwt-test-utils/wiki/HowToUseWithSpring

1) Extends GwtSpringTest instead of GwtTest 

2) Don't use @RunWith(SpringJUnit4ClassRunner.class), GwtSpringTest is run with 
a custom TestRunner especially design to make spring test work with 
gwt-test-utils. The @RunWith annotation is set in GwtSpringTest

3) In @ContextConfiguration, you have to set the gwt-test-utils custom 
ContextLoader : GwtTestContextLoader

So, you should have a declaration like this :

@ContextConfiguration(locations = {"classpath:applicationContext-test.xml"}, 
loader = GwtTestContextLoader.class)
public class formsGwtTest extends GwtSpringTest implements BeanFactoryAware {

Original comment by gael.laz...@gmail.com on 24 Apr 2012 at 3:02