/** * Constructor. * * @param resourceName * the name of the shared resource that will handle the web socket messages */ public TestWebSocketProcessor(final WicketTester wicketTester, final String resourceName) { super(createRequest(wicketTester, resourceName), wicketTester.getApplication()); }
/** * Constructor. * * @param resourceName * the name of the shared resource that will handle the web socket messages */ public TestWebSocketProcessor(final WicketTester wicketTester, final String resourceName) { super(createRequest(wicketTester, resourceName), wicketTester.getApplication()); }
@Override public OrientDbWebApplication getApplication() { return (OrientDbWebApplication) super.getApplication(); }
private SimplifiedPaxWicketInjector(WicketTester tester) { tester.getApplication().getComponentInstantiationListeners().add( new PaxWicketSpringBeanComponentInjector(tester.getApplication(), applicationContext)); }
WicketTester tester = new WicketTester(new MyApplication()); tester.startPage(MyPage.class); Localizer localizer = tester.getApplication().getResourceSettings() .getLocalizer(); String foo = localizer.getString("page.label",tester.getLastRenderedPage(), "")
/** * Creates an HttpServletRequest that is needed by AbstractWebSocketProcessor * * @return a mock http request */ private static MockHttpServletRequest createRequest(final WicketTester wicketTester) { Application application = wicketTester.getApplication(); HttpSession httpSession = wicketTester.getHttpSession(); MockHttpServletRequest request = new MockHttpServletRequest(application, httpSession, null); request.addParameter(WebRequest.PARAM_AJAX_BASE_URL, "."); return request; }
/** * Creates an HttpServletRequest that is needed by AbstractWebSocketProcessor * * @return a mock http request */ private static MockHttpServletRequest createRequest(final WicketTester wicketTester) { Application application = wicketTester.getApplication(); HttpSession httpSession = wicketTester.getHttpSession(); MockHttpServletRequest request = new MockHttpServletRequest(application, httpSession, null); request.addParameter(WebRequest.PARAM_AJAX_BASE_URL, "."); return request; }
@Test public void testWebApplicationRedefenition() { assertTrue(tester.getApplication() instanceof TestEnvOrienteerWebApplication); }
/** * Asserts that there is a feedback message provided by a given component * * @param component * the component that provided the expected feedback message. Optional. * @param key * the resource key for the feedback message. Mandatory. * @param model * the model used for interpolating the feedback message. Optional. * @param filter * the filter that decides in which messages to look in. E.g. with a specific * level, rendered or not, etc. */ public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, IFeedbackMessageFilter filter) { Args.notNull(key, "key"); String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString(key, component, model); List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); assertTrue(String.format("Feedback message with key '%s' cannot be found in %s", key, actualMessages), actualMessages.contains(expectedMessage)); }
/** * Asserts that there is a feedback message provided by a given component * * @param component * the component that provided the expected feedback message. Optional. * @param key * the resource key for the feedback message. Mandatory. * @param model * the model used for interpolating the feedback message. Optional. * @param filter * the filter that decides in which messages to look in. E.g. with a specific level, * rendered or not, etc. */ public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, IFeedbackMessageFilter filter) { Args.notNull(key, "key"); String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString( key, component, model); List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); assertTrue(actualMessages.contains(expectedMessage), String .format("Feedback message with key '%s' cannot be found in %s", key, actualMessages)); }
@Test public void isInstalled() throws Exception { WebApplication application = tester.getApplication(); assertThat(WicketWebjars.isInstalled(application), is(false)); WicketWebjars.install(application); assertThat(WicketWebjars.isInstalled(application), is(true)); } }
/** * Constructor. * * @param wicketTester * The testing helper * @param page * The page to test */ public AtmosphereTester(final WicketTester wicketTester, Page page) { this.wicketTester = wicketTester; WebApplication application = wicketTester.getApplication(); TesterBroadcaster broadcaster = createBroadcaster(); if (EventBus.isInstalled(application)) { this.eventBus = EventBus.get(application); this.eventBus.setBroadcaster(broadcaster); } else { this.eventBus = new EventBus(application, broadcaster); } initialize(wicketTester, page); }
@Test public void testLoadingCustomGuiceModule() { assertEquals(CustomTestModule.RANDOM_STRING, ((OrienteerWebApplication)tester.getApplication()) .getServiceInstance(CustomTestModule.ITestInterface.class).getKey()); }
@Before public void setUp() { tester = new WicketTester(); tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("utf-8"); page = new DummyPage(); page.setTypeBuilder(this::buildBaseType); page.setInstanceCreator(this::createAndPopulateInstance); tester.startPage(page); form = tester.newFormTester("form"); }
Args.notNull(page, "page"); WebApplication webApplication = wicketTester.getApplication(); if (webApplication.getWicketFilter().getFilterPath() == null)
Args.notNull(resourceName, "resourceName"); WebApplication webApplication = wicketTester.getApplication(); if (webApplication.getWicketFilter().getFilterPath() == null)
Args.notNull(page, "page"); WebApplication webApplication = wicketTester.getApplication(); if (webApplication.getWicketFilter().getFilterPath() == null)
Args.notNull(resourceName, "resourceName"); WebApplication webApplication = wicketTester.getApplication(); if (webApplication.getWicketFilter().getFilterPath() == null)
@Before public void setupTests() { login(); tester.getApplication().getMarkupSettings().setStripWicketTags(false); tester.startPage(StatusPage.class); }
@Before public void performLogin() { tester.startPage(SchemaPage.class); if(tester.getLastRenderedPage() instanceof LoginPage) { FormTester formTester = tester.newFormTester("container:loginPanel:form"); IOrientDbSettings settings = ((OrienteerWebApplication)tester.getApplication()).getOrientDbSettings(); formTester.setValue("username", settings.getAdminUserName()); formTester.setValue("password", settings.getAdminPassword()); tester.clickLink("container:loginPanel:form:loginButtonsPanel:loginButton:command", true); } tester.assertRenderedPage(SchemaPage.class); }