我使用 Spring Roo,并依赖 Roo 的按需数据进行集成测试。
我最近意识到,当我从 Maven 运行它们时,在 Eclipse 中顺利运行的相同集成测试会中断。
问题似乎来自 Spring Roo 的按需数据。例如,我收到诸如...之类的错误
testFindPlisByMultiFieldWithNothingSet(trc.suivi.core.repository.PliRepositoryTest):预期:<10> 但为:<0>
...对于以下测试...
@Test
public void testFindPlisByMultiFieldWithNothingSet() {
PliDataOnDemand dod = new PliDataOnDemand();
dod.init();
PliQueryInfo pliQueryInfo = new PliQueryInfo();
List<Pli> plis = pliRepository.findPlisByMultiField(pliQueryInfo, null, null, null, null);
assertEquals(10, plis.size());
}
...表示dod.init()
没有填充我的内存数据库...
仅供参考,PliDataOnDemand 是我们的一个名为 Pli 的实体的按需数据类。
有人可以帮忙吗?
编辑:
从命令行:我运行“mvn test”
来自 eclipse:我刚刚从 eclipse 菜单中运行了测试
Maven版本:3.0.4
编辑2:
aspectJ maven 插件的输出:
[INFO] 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java:8) is annotated with @Component type annotation from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:26)
[INFO] 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java:8) is annotated with @Configurable type annotation from 'trc.suivi.core.domain.PliDataOnDemand_Roo_Configurable' (PliDataOnDemand_Roo_Configurable.aj:11)
[INFO] Extending interface set for type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) to include 'org.springframework.beans.factory.aspectj.ConfigurableObject' (AnnotationBeanConfigurerAspect.aj)
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped field from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'java.util.Random trc.suivi.core.domain.PliDataOnDemand.rnd')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped field from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'java.util.List<trc.suivi.core.domain.Pli> trc.suivi.core.domain.PliDataOnDemand.data')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped field from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'trc.suivi.core.domain.UtilisateurDataOnDemand trc.suivi.core.domain.PliDataOnDemand.utilisateurDataOnDemand')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'trc.suivi.core.domain.Pli trc.suivi.core.domain.PliDataOnDemand.getNewTransientPli(int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setDateAnnulation(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setDateCreation(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setDateModification(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setDateReception(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setFDV(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setIdentifiant(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setNbPlisFDVEstime(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setNumeroPli(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setPaiement(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setStatut(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.setTypePli(trc.suivi.core.domain.Pli, int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'trc.suivi.core.domain.Pli trc.suivi.core.domain.PliDataOnDemand.getSpecificPli(int)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'trc.suivi.core.domain.Pli trc.suivi.core.domain.PliDataOnDemand.getRandomPli()')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'boolean trc.suivi.core.domain.PliDataOnDemand.modifyPli(trc.suivi.core.domain.Pli)')
[INFO] Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java) has intertyped method from 'trc.suivi.core.domain.PliDataOnDemand_Roo_DataOnDemand' (PliDataOnDemand_Roo_DataOnDemand.aj:'void trc.suivi.core.domain.PliDataOnDemand.init()')
[INFO] Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java:8) advised by before advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.1.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:78(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
[INFO] Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java:8) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.1.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:87(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
[INFO] Join point 'initialization(void trc.suivi.core.domain.PliDataOnDemand.<init>())' in Type 'trc.suivi.core.domain.PliDataOnDemand' (PliDataOnDemand.java:8) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.1.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:87(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
编辑 3:
我明白了:
testFindPlisByMultiFieldWithIdentifiantSet(trc.suivi.core.repository.PliRepositoryTest): Unable to find trc.suivi.core.domain.Utilisateur with id 1; nested exception is javax.persistence.EntityNotFoundException: Unable to find trc.suivi.core.domain.Utilisateur with id 1
对于以下测试:
@Test
public void testFindPlisByMultiFieldWithIdentifiantSet() {
PliDataOnDemand dod = new PliDataOnDemand();
Pli pli = dod.getSpecificPli(0);
pli.setIdentifiant("theIdentifiant");
pliRepository.save(pli);
PliQueryInfo pliQueryInfo = new PliQueryInfo();
pliQueryInfo.setIdentifiant("theIdentifiant");
List<Pli> plis = pliRepository.findPlisByMultiField(pliQueryInfo, null, null, "identifiant", "desc");
assertEquals(1, plis.size());
}