Re: Wicket+Spring+JUnit testing

2012-09-17 Thread Sandor Feher
Hi,

An unitializes session variable caused my problem. First I thought it was
injecting problem.
Thank you for advices now I'm green :).



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-Spring-JUnit-testing-tp4652021p4652030.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket+Spring+JUnit testing

2012-09-17 Thread Martin Grigorov
Hi,

>From the code below I don't see what exactly doesn't work. It looks fine for 
>me.

For simpler cases/pages I'd recommend to use Wicket's
ApplicationContextMock instead of using the whole Spring context
because this will slow down your tests.
Just do:
ctx= new ApplicationContextMock();
ctx.put("someBeanName", new SomeServiceMock());

Put only the services (or mocks/stubs for them) which are used by this test.

On Mon, Sep 17, 2012 at 12:45 AM, Sandor Feher  wrote:
> Hi,
>
> Could you please advice a stack for this task ?
> I went thru lots of  (mostly obsolete) post with not much success. I have
> some spring beans which are not injected as I expected.
> Thank you in advance!
>
>
> --
> 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);
> }
> }
>
>
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Spring-JUnit-testing-tp4652021.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Wicket+Spring+JUnit testing

2012-09-16 Thread Sandor Feher
Hi,

Could you please advice a stack for this task ?
I went thru lots of  (mostly obsolete) post with not much success. I have
some spring beans which are not injected as I expected.
Thank you in advance!


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




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-Spring-JUnit-testing-tp4652021.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org