Hi,
Tudnátok valami stacket javasolni a fentire ? Kb. egy napja rágom át magam a különféle, leginkább elavult postokon, de nem jutottam túl messze.
Van néhány spring bean-em, amit használok, de a teszt eseteknél nem injektálódnak be automatikusan.
Köszönöm előre is!
package hu.xxx.xxx.main;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.ContextConfiguration;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author user
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"applicationContext.xml", "applicationContext-Security.xml"})
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class LoginPageTest {
@Autowired
private ApplicationContext ctx;
private WicketTester tester = null;
@Before
public void setUp() throws Exception {
tester = new WicketTester(new MyApplication() {
@Override
protected void init() {
SpringComponentInjector injector = new SpringComponentInjector(this, ctx);
getComponentInstantiationListeners().add(injector);
injector.inject(this);
}
});
}
@Test
public void renderPage() {
tester.startPage(HomePage.class);
}
}
- 4445 megtekintés
Hozzászólások
Es mi tortenik? A ctx null marad? Nincs vmi exception a stdout-on? Az applicationContext.xml es applicationContext-Security.xml ott vannak a LoginPageTest mellett?
- A hozzászóláshoz be kell jelentkezni
Nem. A ctx rendben van. A customBo-m viszont null a HomePage-ben.
public class HomePage extends BasePage {
@SpringBean(name = "HrpCustomBo")
private HrpCustomBo customBo;
.....
- A hozzászóláshoz be kell jelentkezni
Kukkantsunk bele a contextbe. A setup()-ba:
assertNotNull(ctx.getBean("HrpCustomBo", HrpCustomBo.class));
Azt lassuk mi lesz...
- A hozzászóláshoz be kell jelentkezni
Itt még megvan :).
- A hozzászóláshoz be kell jelentkezni
Debuggoltam. Nem a bean-ekkel volt a gond, hanem egy session változóval.
Mivel azt a LoginPage tölti, a HomePage-t először hívva elhasalt null-értékkel.
Köszönöm a segítséget!
- A hozzászóláshoz be kell jelentkezni
Szuperzöld :)
- A hozzászóláshoz be kell jelentkezni