Java Code Examples for org.apache.wicket.util.tester.WicketTester

The following are top voted examples for showing how to use org.apache.wicket.util.tester.WicketTester. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 7 votes vote down vote up
@Test
public void testNumberButton(){
	WicketTester tester = createTester();
	final Boxed<Integer> pageBox = new Boxed<Integer>();
	
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
			pageBox.value=page.getObject();
		}
	};
	paginator.setTotalResults(Model.of(100));
	paginator.setNumberResultsPerPage(10);
	tester.startComponentInPage(paginator);
	tester.clickLink("paginator:page:4:link");
	assertEquals(4, (int) pageBox.value);
	tester.assertEnabled("paginator:last:link");
	tester.assertEnabled("paginator:next:link");
	tester.assertEnabled("paginator:previous:link");
	tester.assertEnabled("paginator:first:link");
	tester.assertLabel("paginator:page:2:link:label", "5");
}
 
Example 2
Project: ansible-docker-talk   File: TestHomePage.java   View source code 6 votes vote down vote up
@Before
public void setUp() {
    applicationContextMock = new ApplicationContextMock();
    WicketApplication wicketApp = new WicketApplication();
    wicketApp.getComponentInstantiationListeners()
    .add(new SpringComponentInjector(wicketApp,applicationContextMock));
    tester = new WicketTester(wicketApp);

    applicationContextMock.putBean(new PersonRepository(){
        @Override
        public List<Person> findAllPersons() {
          return Collections.emptyList();
        }
    });

}
 
Example 3
Project: Unicorn   File: DependenciesPanelTest.java   View source code 6 votes vote down vote up
public void setUp() throws Exception{
    super.setUp();
    Persistor.useTestEnvironment();
    attributes.add(baseAttribute);
    attributes.add(depAttribute);
    AttributeTypeTree attributeTree = new AttributeTypeTree(attributes);
    eventType = new EapEventType("TestType", attributeTree);
    ArrayList<EapEventType> eventTypes = new ArrayList<>();
    eventTypes.add(eventType);
    EapEventType.save(eventTypes);
    tester = new WicketTester(new UNICORNApplication());
    tester.startPage(GeneratorPage.class);
    tester.startComponentInPage(new DependenciesPanel("dependenciesPanel" , new GeneratorPage()));
    // get form
    List<Form> list = new ArrayList<>();
    Page x = tester.getLastRenderedPage();
    for (Component form : x.visitChildren(Form.class)) {
        list.add((Form) form);
    }
    formPath = list.get(0).getPageRelativePath();
    listViewPath = formPath + ":dependenciesContainer:dependenciesListview";
}
 
Example 4
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testRenderComponent(){
	WicketTester tester = createTester();
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
		}
	};
	paginator.setTotalResults(Model.of(100));
	tester.startComponentInPage(paginator);
	tester.assertDisabled("paginator:first:link");
	tester.assertDisabled("paginator:previous:link");
	tester.assertEnabled("paginator:next:link");
	tester.assertEnabled("paginator:last:link");
}
 
Example 5
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testLastButton(){
	WicketTester tester = createTester();
	final Boxed<Integer> pageBox = new Boxed<Integer>();
	
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
			pageBox.value=page.getObject();
		}
	};
	paginator.setTotalResults(Model.of(100));
	paginator.setNumberResultsPerPage(10);
	tester.startComponentInPage(paginator);
	
	tester.clickLink("paginator:last:link");
	assertEquals(9, (int) pageBox.value);
	tester.assertDisabled("paginator:last:link");
	tester.assertDisabled("paginator:next:link");
	tester.assertEnabled("paginator:previous:link");
	tester.assertEnabled("paginator:first:link");
	
}
 
Example 6
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testNextButton(){
	WicketTester tester = createTester();
	final Boxed<Integer> pageBox = new Boxed<Integer>();
	
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
			pageBox.value=page.getObject();
		}
	};
	paginator.setTotalResults(Model.of(100));
	tester.startComponentInPage(paginator);
	tester.clickLink("paginator:next:link");
	assertEquals(1, (int) pageBox.value);
	tester.assertEnabled("paginator:last:link");
	tester.assertEnabled("paginator:next:link");
	tester.assertEnabled("paginator:previous:link");
	tester.assertEnabled("paginator:first:link");
}
 
Example 7
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testPreviousButton(){
	WicketTester tester = createTester();
	final Boxed<Integer> pageBox = new Boxed<Integer>();
	
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
			pageBox.value=page.getObject();
		}
	};
	paginator.setTotalResults(Model.of(100));
	paginator.setModelObject(2);
	tester.startComponentInPage(paginator);
	tester.clickLink("paginator:previous:link");
	assertEquals(1, (int) pageBox.value);
	tester.assertEnabled("paginator:last:link");
	tester.assertEnabled("paginator:next:link");
	tester.assertEnabled("paginator:previous:link");
	tester.assertEnabled("paginator:first:link");
}
 
Example 8
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testFirstButton(){
	WicketTester tester = createTester();
	final Boxed<Integer> pageBox = new Boxed<Integer>();
	
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;

		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
			pageBox.value=page.getObject();
		}
	};
	paginator.setTotalResults(Model.of(100));
	paginator.setModelObject(2);
	tester.startComponentInPage(paginator);
	tester.clickLink("paginator:first:link");
	assertEquals(0, (int) pageBox.value);
	tester.assertEnabled("paginator:last:link");
	tester.assertEnabled("paginator:next:link");
	tester.assertDisabled("paginator:previous:link");
	tester.assertDisabled("paginator:first:link");
}
 
Example 9
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
@Test
public void testShowHiddenComponents(){
	WicketTester tester = createTester();
	BootstrapPaginator paginator = new BootstrapPaginator("paginator") {
		private static final long serialVersionUID = -4486050808642574868L;
		
		@Override
		public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
		}
	};
	
	paginator.setTotalResults(Model.of(100));
	paginator.setShowLastButton(false);
	paginator.setShowFirstButton(false);
	paginator.setShowNextButton(false);
	paginator.setShowPreviousButton(false);
	
	tester.startComponentInPage(paginator);
	tester.assertInvisible("paginator:first:link");
	tester.assertInvisible("paginator:previous:link");
	tester.assertInvisible("paginator:next:link");
	tester.assertInvisible("paginator:last:link");
}
 
Example 10
Project: pm-wicket-utils   File: BootstrapPaginatorTest.java   View source code 6 votes vote down vote up
private WicketTester createTester(){
	WicketTester tester = new WicketTester(new WebApplication() {
		
		@Override
		public Class<? extends Page> getHomePage() {
			return null;
		}
	}){
		@Override
		protected String createPageMarkup(String componentId) {
			return "<div class=\"pagination pagination-small pagination-right\" wicket:id=\"paginator\">"+
					"</div>";
		}
	};
	
	return tester;
}
 
Example 11
Project: wicket-orientdb   File: WicketOrientDbFilterTesterScope.java   View source code 6 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            WicketTester tester = create();
            List<OClass> testClasses = Lists.newArrayList();
            try {
                testClasses = initTestClasses();
                base.evaluate();
            } finally {
                deleteClassesAndDocuments(testClasses);
                tester.destroy();
            }
        }
    };
}
 
Example 12
Project: wicket-leaflet   File: LeafletAjaxBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testGetVariable() {
    final WicketTester tester = getTester();

    TestAjaxBehavior behavior = new TestAjaxBehavior("testA");
    Map map = new Map("map");
    map.add(behavior);

    tester.startComponentInPage(map);

    MockHttpServletRequest request = this.prepareRequest(tester, behavior, "testA", "testValue");
    tester.processRequest(request);

    StringValue actual = behavior.actualVariableValue;
    assertThat(actual.isEmpty()).isFalse();
    assertThat(actual.toString()).isEqualTo("testValue");
}
 
Example 13
Project: wicket-leaflet   File: LeafletAjaxBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testGetMissingVariable() {
    final WicketTester tester = getTester();

    TestAjaxBehavior behavior = new TestAjaxBehavior("testB");
    Map map = new Map("map");
    map.add(behavior);

    tester.startComponentInPage(map);

    MockHttpServletRequest request = prepareRequest(tester, behavior, "testA", "testA");
    tester.processRequest(request);

    StringValue missingValue = behavior.actualVariableValue;
    assertThat(missingValue.isEmpty()).isTrue();
}
 
Example 14
Project: wicket-leaflet   File: LocationEventBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testRespondToLocationEvent() {
    WicketTester tester = this.getTester();

    final Map map = new Map("map");
    final TestLocationEventBehavior behavior = new TestLocationEventBehavior();
    map.add(behavior);

    tester.startComponentInPage(map);

    MockHttpServletRequest request = this.prepareRequest(tester, behavior, MapEventType.LOCATION_FOUND, this.locationEvent);
    tester.processRequest(request);

    assertThat(behavior.actualLocationEvent)
            .isNotNull()
            .isEqualToComparingFieldByField(this.locationEvent);
    assertThat(behavior.actualError).isNull();
}
 
Example 15
Project: wicket-leaflet   File: LocationEventBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testRespondToLocationError() {
    WicketTester tester = this.getTester();

    final Map map = new Map("map");
    final TestLocationEventBehavior behavior = new TestLocationEventBehavior();
    map.add(behavior);

    tester.startComponentInPage(map);

    MockHttpServletRequest request = this.prepareRequest(tester, behavior, MapEventType.LOCATION_ERROR, this.errorEvent);
    tester.processRequest(request);

    assertThat(behavior.actualError)
            .isNotNull()
            .isEqualToComparingFieldByField(this.errorEvent);
    assertThat(behavior.actualLocationEvent).isNull();
}
 
Example 16
Project: wicket-leaflet   File: LocationEventBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testDontRespondToEmptyErrorEvent() {
    WicketTester tester = this.getTester();

    final Map map = new Map("map");
    final TestLocationEventBehavior behavior = new TestLocationEventBehavior();
    map.add(behavior);

    tester.startComponentInPage(map);

    MockHttpServletRequest request = this.prepareRequest(tester, behavior, MapEventType.LOCATION_ERROR.getJavascriptName(), "");
    tester.processRequest(request);

    assertThat(behavior.actualError).isNull();
    assertThat(behavior.actualLocationEvent).isNull();
}
 
Example 17
Project: wicket-leaflet   File: LeafletAjaxEventBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testDontTriggerEventOnMissingJson() {
    final WicketTester tester = this.getTester();

    final TestAjaxEventBehavior behavior = new TestAjaxEventBehavior(MapEventType.CLICK);
    final Map map = new Map("map");
    map.add(behavior);

    tester.startComponentInPage(map);

    final MockHttpServletRequest request = this.prepareRequest(tester, behavior,
            MapEventType.CLICK.getJavascriptName(), "");

    tester.processRequest(request);

    assertThat(behavior.wasTriggered).isFalse();
}
 
Example 18
Project: wicket-leaflet   File: LeafletAjaxEventBehaviorTest.java   View source code 6 votes vote down vote up
@Test
public void testOnResponseTriggersEvent() {
    final WicketTester tester = this.getTester();

    final TestAjaxEventBehavior behavior = new TestAjaxEventBehavior(MapEventType.CLICK);
    final Map map = new Map("map");
    map.add(behavior);

    tester.startComponentInPage(map);
    final PlainEvent jsonEvent = PlainEvent.of(MapEventType.CLICK);

    final MockHttpServletRequest request = this.prepareRequest(tester, behavior, MapEventType.CLICK, jsonEvent);
    tester.processRequest(request);

    assertThat(behavior.wasTriggered).isTrue();
    assertThat(behavior.lastEvent).isEqualToComparingFieldByField(jsonEvent);
}
 
Example 19
Project: wicket-leaflet   File: AbstractLeafletTest.java   View source code 6 votes vote down vote up
/**
    * Prepares request that triggers AJAX behavior and contains parameter with given name and value.
    *
    * @param tester the wicket tester which triggers behavior
    * @param behavior the behavior that should be triggered
    * @param parameterName the name of parameter
    * @param parameterValue the value of parameter
    * @return mock HTTP request that triggers given behavior
    */
   protected MockHttpServletRequest prepareRequest(WicketTester tester, AbstractAjaxBehavior behavior,
           String parameterName, String parameterValue) {
       MockHttpServletRequest request = new MockHttpServletRequest(tester.getApplication(), tester.getHttpSession(), tester.getServletContext());

       Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding()));

       // make url suitable for wicket tester use. usually this involves stripping any leading ..
// segments to make the url absolute
       for (Iterator<String> segments = url.getSegments().iterator(); segments.hasNext();) {
           String segment = segments.next();
           if (segment.equals("..") || segment.equals(".")) {
               segments.remove();
           }
       }

       request.addHeader("Wicket-Ajax", "true");
       request.addHeader("Wicket-Ajax-BaseURL", url.toString());
       request.setUrl(url);

       request.setParameter(parameterName, parameterValue);

       return request;
   }
 
Example 20
Project: wicket-crudifier   File: BootstrapCrudifierFormTest.java   View source code 6 votes vote down vote up
@SuppressWarnings("serial")
@Test
public void testRender() {
	WicketTester tester = createTester();
	
	final Entity2[] entities = new Entity2[]{ new Entity2(1),new Entity2(3), new Entity2(2)};
	
	Set<Entity2> entitiesSet = new HashSet<Entity2>();
	entitiesSet.add(entities[0]);
	entitiesSet.add(entities[1]);
	
	Entity entity = new Entity(false, 0, "", entities[0], entitiesSet, Entity.Enume.ENUM1 );
	
	final EntityProvider<Entity2> providerEntity2 = new EntityProvider<Entity2>() {
		public List<Entity2> load() {
			return Arrays.asList(entities);
		}
	};
	
	tester.startComponentInPage(new CrudifierForm<Entity>("crud", Model.of(entity)) {
		@Override 
		public EntityProvider<?> getEntityProvider(String name) {
			return providerEntity2;
		}
	});
}
 
Example 21
Project: wicket-crudifier   File: BootstrapCrudifierFormTest.java   View source code 6 votes vote down vote up
private WicketTester createTester(){
WicketTester tester = new WicketTester(new WebApplication() {
	
	@Override
	public Class<? extends Page> getHomePage() {
		return null;
	}
	
	@Override
	public Session newSession(Request request, Response response) {
		Session session = super.newSession(request, response);
		session.setLocale(Locale.FRENCH);
		return session;
	}
}){
 
Example 22
Project: flex-ui   File: AjaxLazyComponentPanelTest.java   View source code 6 votes vote down vote up
@Test
public void ajaxLazyComponentPanel_behavesCorrectly() {
    WicketTester tester = getWicketTester();

    AjaxLazyComponentPanel panel =
        new AjaxLazyComponentPanel("panel", id -> new Label(id, "lazy panel test").setRenderBodyOnly(true));

    tester.startComponentInPage(panel);

    TagTester content = tester.getTagByWicketId("content");
    System.out.println(content.getMarkup());

    assertNotNull(content);
    assertTrue("Container missing css class 'spinner'", content.getAttributeContains("class", "spinner"));
    assertEquals("<i style=\"font-size: 32px\" class=\"fa fa-cog fa-spin\"></i>", content.getValue());

    AjaxLazyLoadPanelTester.executeAjaxLazyLoadPanel(tester, panel.getParent());
    // tester.debugComponentTrees();

    tester.assertLabel("panel:content", "lazy panel test");
}
 
Example 23
Project: wickject   File: FailFastTest.java   View source code 6 votes vote down vote up
@Test
public void ensureThrowsWithSpecificMessageWhenMissingProvides() {

  WicketTester tester = new WicketTester();

  Wickjector injector = Wickject.addInjectorTo(tester);
  injector.provides(Integer.valueOf(42), Integer.class);

  String actual = "";

  try {
    new Foo();
  } catch (IllegalStateException ex) {
    Assert.assertTrue(ex instanceof IllegalStateException);
    actual = ex.getMessage();
  } finally {
    String expected = "Found a field 'no' in the class com.studiomediatech.wickject.FailFastTest.Foo of type java.lang.String without a provided object.";
    Assert.assertEquals(expected, actual);
  }
}
 
Example 24
Project: serverside-todomvc   File: ItemsLeftCountLabelTest.java   View source code 6 votes vote down vote up
@Test
public void testItemsLeftCountLabelCaptions() {

  WicketTester tester = new WicketTester();

  IModel<Integer> countModel = new Model<Integer>();
  String id = "id";
  ItemsLeftCountLabel label = new ItemsLeftCountLabel(id, countModel);

  countModel.setObject(0);
  tester.startComponentInPage(label);
  tester.assertLabel(id, "items left");

  countModel.setObject(1);
  tester.startComponentInPage(label);
  tester.assertLabel(id, "item left");

  countModel.setObject(3);
  tester.startComponentInPage(label);
  tester.assertLabel(id, "items left");
}
 
Example 25
Project: serverside-todomvc   File: TodoTextLabelTest.java   View source code 6 votes vote down vote up
@Test
public void testTodoTextLabel() {

  WicketTester tester = new WicketTester();
  Todo todo = new Todo();
  IModel<Todo> todoModel = new Model<Todo>();
  String id = "id";
  TodoTextLabel label = new TodoTextLabel(id, todoModel);

  todoModel.setObject(null);
  tester.startComponentInPage(label);
  tester.assertLabel(id, "");

  todoModel.setObject(todo);
  tester.startComponentInPage(label);
  tester.assertLabel(id, "");

  todo.setTodo("foo bar");
  tester.startComponentInPage(label);
  tester.assertLabel(id, "foo bar");
}
 
Example 26
Project: hippo   File: BlankAttachmentFieldValidatorTest.java   View source code 5 votes vote down vote up
private void initialiseWicketApplication() {

        // This initialises various statically stored values that Wicket uses,
        // most notably, Session and Application whose absence was causing NullPointerException during call to
        // org.hippoecm.frontend.editor.validator.plugins.AbstractCmsValidator.getTranslation(java.lang.String).
        new WicketTester(new WebApplication() {
            public Class<? extends Page> getHomePage() {
                return null;
            }
        });
    }
 
Example 27
Project: hippo   File: BlankStaticDropdownSelectionFieldValidatorTest.java   View source code 5 votes vote down vote up
private void initialiseWicketApplication() {

        // This initialises various statically stored values that Wicket uses,
        // most notably, Session and Application whose absence was causing NullPointerException during call to
        // org.hippoecm.frontend.editor.validator.plugins.AbstractCmsValidator.getTranslation(java.lang.String).
        new WicketTester(new WebApplication() {
            public Class<? extends Page> getHomePage() {
                return null;
            }
        });
    }
 
Example 28
Project: hippo   File: CoverageDatesValidatorTest.java   View source code 5 votes vote down vote up
private void initialiseWicketApplication() {
    // This initialises various statically stored values that Wicket uses,
    // most notably, Session and Application whose absence was causing NullPointerException during call to
    // org.hippoecm.frontend.editor.validator.plugins.AbstractCmsValidator.getTranslation(java.lang.String).
    new WicketTester(new WebApplication() {
        public Class<? extends Page> getHomePage() {
            return null;
        }
    });
}
 
Example 29
Project: hippo   File: BlankRelatedLinkFieldValidatorTest.java   View source code 5 votes vote down vote up
private void initialiseWicketApplication() {
    // This initialises various statically stored values that Wicket uses,
    // most notably, Session and Application whose absence was causing NullPointerException during call to
    // org.hippoecm.frontend.editor.validator.plugins.AbstractCmsValidator.getTranslation(java.lang.String).
    new WicketTester(new WebApplication() {
        public Class<? extends Page> getHomePage() {
            return null;
        }
    });
}
 
Example 30
Project: vlo-curation   File: TestRecordPage.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
    tester = new WicketTester(application);

    document = new SolrDocument();
    document.setField(FacetConstants.FIELD_ID, "documentId");

    params = new PageParameters();
    params.set(VloWebAppParameters.DOCUMENT_ID, "documentId");
}
 
Example 31
Project: owsi-core-parent   File: WicketTesterTestExecutionListener.java   View source code 5 votes vote down vote up
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
	Object testInstance = testContext.getTestInstance();
	if (! (testInstance instanceof IWicketTestCase)) {
		throw new IllegalStateException("This execution listener can only be used on an " + IWicketTestCase.class.getSimpleName());
	}
	IWicketTestCase testCase = (IWicketTestCase) testContext.getTestInstance();
	WicketTester tester = (WicketTester) testContext.getAttribute(WICKET_TESTER_ATTRIBUTE);
	if (!(tester instanceof WicketTester)) {
		throw new IllegalStateException("Missing or invalid wicket tester - someone messed up with the test context.");
	}
	testCase.setWicketTester((WicketTester)tester);
}
 
Example 32
Project: owsi-core-parent   File: WicketTesterTestExecutionListener.java   View source code 5 votes vote down vote up
@Override
public void afterTestClass(TestContext testContext) throws Exception {
	WicketTester tester = (WicketTester) testContext.getAttribute(WICKET_TESTER_ATTRIBUTE);
	if (!(tester instanceof WicketTester)) {
		throw new IllegalStateException("Missing or invalid wicket tester - someone messed up with the test context.");
	}
	tester.destroy();
}
 
Example 33
Project: openmeetings   File: AbstractWicketTester.java   View source code 5 votes vote down vote up
public static WicketTester getWicketTester(long langId) {
	WebApplication app = (WebApplication)ensureApplication(langId);

	WicketTester tester = new WicketTester(app, app.getServletContext());
	setInitComplete(true);
	return tester;
}
 
Example 34
Project: openmeetings   File: AbstractWicketTester.java   View source code 5 votes vote down vote up
public static void destroy(WicketTester tester) {
	if (tester != null) {
		ServletContext sc = tester.getServletContext();
		try {
			((XmlWebApplicationContext)sc.getAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).close();
		} catch (Exception e) {
			log.error("Unexpected error while destroying XmlWebApplicationContext", e);
		}
		tester.destroy();
	}
}
 
Example 35
Project: openmeetings   File: AbstractWicketTester.java   View source code 5 votes vote down vote up
public static <T extends Serializable> ButtonAjaxBehavior getButtonBehavior(WicketTester tester, String path, String name) {
	Args.notNull(path, "path");
	Args.notNull(name, "name");
	@SuppressWarnings("unchecked")
	AbstractDialog<T> dialog = (AbstractDialog<T>)tester.getComponentFromLastRenderedPage(path);
	List<ButtonAjaxBehavior> bl = dialog.getBehaviors(ButtonAjaxBehavior.class);
	for (ButtonAjaxBehavior bb : bl) {
		if (name.equals(bb.getButton().getName())) {
			return bb;
		}
	}
	fail(String.format("Button '%s' not found for dialog '%s'", name, path));
	return null;
}
 
Example 36
Project: openmeetings   File: AbstractWicketTester.java   View source code 5 votes vote down vote up
public static void checkErrors(WicketTester tester, int count) {
	List<FeedbackMessage> errors = getErrors(tester);
	if (count != errors.size()) {
		for (FeedbackMessage fm : errors) {
			log.debug("Error {}", fm);
		}
	}
	assertEquals(String.format("There should be exactly %s errors", count), count, errors.size());
}
 
Example 37
Project: invesdwin-nowicket   File: AExampleTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpOnce() throws Exception {
    Assertions.assertThat(wicketTester).isNull();
    //make @Configurable and PropertyChangeSupport aspect work
    AExampleTest.springContext = SpringApplication.run(Main.class, "--server.port=" + getTestServerPort());
    //wicketTester might sometimes still be needed
    AExampleTest.wicketTester = new WicketTester(new ExampleWebApplication());
    //the guiServiceTester is useful to test modals and other things
    AExampleTest.guiServiceTester = new GuiServiceTester();
    GuiService.setGuiServiceOverride(guiServiceTester);
}
 
Example 38
Project: elpaaso-core   File: ReleaseOverrideProfilePanelTest.java   View source code 5 votes vote down vote up
@Before
public void init() {
	ApplicationContextMock context = new ApplicationContextMock();
	context.putBean(managePaasUser);
	context.putBean("authenticationManager",authenticationManager);
	context.putBean(manageApplicationRelease);
	PaasTestApplication application = new PaasTestApplication(context);
	tester = new WicketTester(application);
}
 
Example 39
Project: elpaaso-core   File: DesignerArchitectureConfigSetPanelTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
	// we need to set-up a wicket tester and do some minimal configuration in order to create tested panel
	
	// a wicketTester is required to instantiate a wicket panel
       tester = new WicketTester(); 
       
       // a parentPage is required with a logicalDeployment to initialize the config panel
       DesignerHelperPage parentPage = mock(DesignerHelperPage.class);
       LogicalDeployment ld = mock(LogicalDeployment.class);
	when(parentPage.getLogicalDeployment()).thenReturn(ld );
	
	configPanel = new DesignerArchitectureConfigSetPanel("test", parentPage , null);
}
 
Example 40
Project: ontopia   File: StartPageTest.java   View source code 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  tester = new WicketTester(new OntopolyApplication());
  tester.startPage(StartPage.class);
  tester.assertNoErrorMessage();
}