use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class WebExternalResourceTest method before.
/**
* @throws Exception
*/
@Before
public void before() throws Exception {
File tempDir = new File("target/webapp");
tempDir.mkdir();
File tempFile = new File(tempDir, "index.html");
FileOutputStream out = new FileOutputStream(tempFile);
InputStream in = WebExternalResourceTest.class.getResourceAsStream("index.html");
Streams.copy(in, out);
in.close();
out.close();
tester = new WicketTester(new MockApplication(), tempDir.getPath());
// We fake the browser URL, otherwise Wicket doesn't know the requested URL and cannot guess
// the Content-Type
tester.getRequest().setURL("index.html");
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class ServletWebRequestTest method useCustomServletWebRequest.
/**
* https://issues.apache.org/jira/browse/WICKET-4123
*/
@Test
public void useCustomServletWebRequest() {
WebApplication application = new WebApplication() {
@Override
public Class<? extends Page> getHomePage() {
return CustomRequestPage.class;
}
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
return new CustomServletWebRequest(servletRequest, filterPath);
}
};
WicketTester tester = new WicketTester(application);
try {
tester.startPage(new CustomRequestPage());
} finally {
tester.destroy();
}
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class PageVersioningTest method setup.
/**
* setup()
*/
@Before
public void setup() {
final PageVersioningApplication application = new PageVersioningApplication();
wicketTester = new WicketTester(application) {
/**
* @see org.apache.wicket.util.tester.BaseWicketTester#newTestPageManagerProvider()
*/
@Override
protected IPageManagerProvider newTestPageManagerProvider() {
return new IPageManagerProvider() {
@Override
public IPageManager apply(IPageManagerContext pageManagerContext) {
final IDataStore dataStore = new InMemoryPageStore();
final AsynchronousDataStore asyncDS = new AsynchronousDataStore(dataStore, 100);
final DefaultPageStore pageStore = new DefaultPageStore(new JavaSerializer(application.getApplicationKey()), asyncDS, 40);
return new PageStoreManager(application.getName(), pageStore, pageManagerContext);
}
};
}
};
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class ComponentEventsTest method setup.
/**
*/
@Before
public void setup() {
tester = new WicketTester(new TestApplication());
application = (TestApplication) tester.getApplication();
session = (TestSession) tester.getSession();
cycle = (TestRequestCycle) tester.getRequestCycle();
page = new TestPage();
c1 = new TestContainer("c1");
c12 = new TestContainer("c12");
c13 = new TestContainer("c13");
c134 = new TestContainer("c134");
c135 = new TestComponent("c135");
c6 = new TestComponent("c6");
page.add(c1);
c1.add(c12);
c1.add(c13);
c13.add(c134);
c13.add(c135);
page.add(c6);
all = new Testable[] { page, c1, c12, c13, c134, c135, c6, application, session, cycle };
stop = null;
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class FormMethodMismatchTest method withButtonFormSubmittedContinuesWithCorrectMethod.
@Test
public void withButtonFormSubmittedContinuesWithCorrectMethod() {
final WicketTester tester = new WicketTester();
final boolean[] onSubmitCalled = new boolean[1];
final Form<Void> underTest = new Form<Void>("underTest") {
@Override
protected void onSubmit() {
onSubmitCalled[0] = true;
}
};
tester.startPage(new FormWithButtonPage(underTest));
final FormTester formTester = tester.newFormTester("underTest");
formTester.submit("button");
assertTrue(onSubmitCalled[0]);
}
Aggregations