Announcement Announcement Module
Collapse
No announcement yet.
Why do all Spring Roo testRemove() tests fail? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why do all Spring Roo testRemove() tests fail?

    In my first Spring Roo project, I noticed a strange behaviour while testing the auto-generated entity tests (entity jpa --class ~.xyz --testAutomatically):

    In every generated xyzIntegrationTest_Roo_IntegrationTest.aj file, the testRemove() test, such as

    Code:
        
        @Test
        public void xyzImplIntegrationTest.testRemove() {
            xyzImpl obj = dod.getRandomxyzImpl();
            Assert.assertNotNull("Data on demand for 'xyzImpl' failed to initialize correctly", obj);
            Long id = obj.getId();
            Assert.assertNotNull("Data on demand for 'xyzImpl' failed to provide an identifier", id);
            obj = xyzImpl.findxyzImpl(id);
            obj.remove();
            obj.flush();
            // this is the assertion that does not hold
            Assert.assertNull("Failed to remove 'xyzImpl' with identifier '" + id + "'", xyzImpl.findxyzImpl(id));
        }
    , fail in the JUnit test queue after I add the following artificial test and test it before the others.

    Code:
        import org.junit.Test;
        import org.junit.runner.RunWith;
        import org.junit.runners.JUnit4;
        import org.junit.Assert;
        import org.springframework.context.ApplicationContext;
        import org.springframework.context.support.ClassPathXmlApplicationContext;
        import org.springframework.context.support.FileSystemXmlApplicationContext;
    
        @RunWith(JUnit4.class)
        public class DummyTest {
    
          @Test
          public void ArtificialTest() 
          {
            ApplicationContext ac = 
              new ClassPathXmlApplicationContext("classpath*:META-INF/spring/applicationContext.xml");
              // the same problem occurs for
              // new FileSystemXmlApplicationContext("src/main/resources/META-INF/spring/applicationContext.xml");
    
            Assert.assertTrue(true);
          }
        }
    Note that all tests run without errors if executed independently and that I have not modified the applicationContext.xml provided by Spring Roo at all.

    -----------------------------------------------------------------------------------------

    My questions are now:

    - Is this a known bug with an existing workaround or am I missing something important?

    - Is there another way to get the application context for an individual written test?

    -----------------------------------------------------------------------------------------

    Below you find the corresponding failure trace:

    Code:
    java.lang.AssertionError: Failed to remove 'xyzImpl' with identifier '1' 
    at org.junit.Assert.fail(Assert.java:93) 
    at org.junit.Assert.assertTrue(Assert.java:43) 
    at org.junit.Assert.assertNull(Assert.java:551) 
    at xyzImplIntegrationTest_Roo_IntegrationTest.ajc$interMethod$xyzImplIntegrationTest_Roo_IntegrationTest$xyzImplIntegrationTest$testRemove(xyzImplIntegrationTest_Roo_IntegrationTest.aj:118) 
    at xyzImplIntegrationTest.testRemove(xyzImplIntegrationTest.java:1) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:601) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) 
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) 
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) 
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

  • #2
    Nothing new

    Sorry for being a little bit impatient, but I wonder if there is anybody how can help me with this particular problem or if skipping these tests - as suggested in https://jira.springsource.org/browse/ROO-3174 - is the only practicable workaround, as "there are already too many hacks in our (Unit tests) code to support its operation."

    Comment

    Working...
    X