Wicket+Spring+Junit tesztelés

Fórumok

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);
    }
}



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?

Nem. A ctx rendben van. A customBo-m viszont null a HomePage-ben.

public class HomePage extends BasePage {

@SpringBean(name = "HrpCustomBo")
private HrpCustomBo customBo;
.....