Package org.apache.wicket.util.tester

Examples of org.apache.wicket.util.tester.WicketTester


{
  private WicketTester tester;

  @Override
  public void setUp() throws InstantiationException, IllegalAccessException {
    tester = new WicketTester(new WicketPushApplication());
  }
View Full Code Here


  }

  @Test
  public void testUrlVersionStoredInRequestCycle()
  {
    WicketTester tester = new WicketTester();
    tester.getApplication().getResourceSettings().setCachingStrategy(strategy);

    try
    {
      PageParameters urlParameters = new PageParameters();
      urlParameters.add(versionParameter, "9A0364B9E99BB480DD25E1F0284C8555");
      ResourceUrl resourceUrl = new ResourceUrl("some-resource.txt", urlParameters);
      strategy.undecorateUrl(resourceUrl);

      String version = tester.getRequestCycle().getMetaData(IResourceCachingStrategy.URL_VERSION);

      assertEquals("9A0364B9E99BB480DD25E1F0284C8555", version);
    }
    finally
    {
      tester.destroy();
    }
  }
View Full Code Here

  }

  @Test
  public void testUrlVersionStoredInRequestCycle()
  {
    WicketTester tester = new WicketTester();
    tester.getApplication().getResourceSettings().setCachingStrategy(strategy);

    try
    {
      ResourceUrl resourceUrl = new ResourceUrl("some-resource--vers--9A0364B9E99BB480DD25E1F0284C8555.txt", new PageParameters());
      strategy.undecorateUrl(resourceUrl);

      String version = tester.getRequestCycle().getMetaData(IResourceCachingStrategy.URL_VERSION);

      assertEquals("9A0364B9E99BB480DD25E1F0284C8555", version);
    }
    finally
    {
      tester.destroy();
    }
  }
View Full Code Here

  @Test
  public void instantiateJustOnce()
  {
    final AtomicInteger constructorsCalls = new AtomicInteger(0);

    WicketTester tester = new WicketTester(new TestApplication());

    assertEquals(0, constructorsCalls.get());

    tester.startPage(new TestPage(constructorsCalls));

    assertEquals(1, constructorsCalls.get());

    tester.assertRenderedPage(TestPage.class);

    assertEquals(1, constructorsCalls.get());
  }
View Full Code Here

  private WicketTester tester;

  @Before
  public void setUp()
  {
    tester = new WicketTester(new WicketApplication());
  }
View Full Code Here

    @Before
    public void initTester() {
        StaticWebApplicationContext mockedContext = new StaticWebApplicationContext();

        tester = new WicketTester(new TestAppFuseWicketApplication(mockedContext));
        //ensure english locale regardless of local system locale
        tester.getSession().setLocale(Locale.ENGLISH);

        initSpringBeans(mockedContext);
    }
View Full Code Here

       
        context = new ApplicationContextMock();
        context.putBean("bus", bus);
        context.putBean("lotteryQueryService", lotteryQueryService);

        tester = new WicketTester(new WicketApplication(context));
    }
View Full Code Here

     * Tests BeanForm with an IModel that represents a List. Form should use a BeanTablePanel rather
     * than BeanGridPanel.
     */
    public void testBeanFormWithListModel()
    {
        WicketTester tester = new WicketTester();

        final ContainerModelTestPage page = new ContainerModelTestPage();

        SerializableBean[] beans = new SerializableBean[20];
        for (int i = 0; i < beans.length; i++) {
            beans[i] = new SerializableBean("Name" + i, "XYZ" + i);
        }
       
        IModel<Serializable> beanModel = new Model<Serializable>((Serializable)(Object) Arrays.asList(beans));
       
        BeanMetaData meta = new BeanMetaData(SerializableBean.class, null, page, null, false);
        BeanForm form = new BeanForm("beanForm", beanModel, meta);

        page.add(form);
       
        tester.startPage(new ITestPageSource() {
            private static final long serialVersionUID = 1L;
            public Page getTestPage()
            {
                return page;
            }
View Full Code Here

     * Tests BeanForm with a List. Form should use a BeanTablePanel rather
     * than BeanGridPanel.
     */
    public void testBeanFormWithList()
    {
        WicketTester tester = new WicketTester();

        final ContainerModelTestPage page = new ContainerModelTestPage();

        SerializableBean[] beans = new SerializableBean[20];
        for (int i = 0; i < beans.length; i++) {
            beans[i] = new SerializableBean("Name" + i, "XYZ" + i);
        }
       
        BeanMetaData meta = new BeanMetaData(SerializableBean.class, null, page, null, false);
        BeanForm form = new BeanForm("beanForm", Arrays.asList(beans), meta);

        page.add(form);
       
        tester.startPage(new ITestPageSource() {
            private static final long serialVersionUID = 1L;
            public Page getTestPage()
            {
                return page;
            }
View Full Code Here

    /**
     * Tests BeanForm with a LoadableDetachableModel instead of a direct bean.
     */
    public void testBeanFormWithLoadableDetachableModel()
    {
        WicketTester tester = new WicketTester();

        final ContainerModelTestPage page = new ContainerModelTestPage();
       

        TestLoadableDetachableObjectModel nestedModel = new TestLoadableDetachableObjectModel();
        BeanMetaData meta = new BeanMetaData(nestedModel.getObject().getClass(), null, page, null, false);
        BeanForm form = new BeanForm("beanForm", nestedModel, meta);

        page.add(form);
       
        tester.startPage(new ITestPageSource() {
            private static final long serialVersionUID = 1L;
            public Page getTestPage()
            {
                return page;
            }
        });
       
        //tester.debugComponentTrees();

        // Check elements, labels.
        String firstRowPath = "beanForm:f:tabs:r:0";
        String namePath = firstRowPath + ":c:0:c";
        String nameFieldPath = namePath + ":c";
       
        tester.assertLabel(namePath + ":l", "Name");
        tester.assertComponent(nameFieldPath, InputField.class);
        Component nameField = tester.getComponentFromLastRenderedPage(nameFieldPath);

        String serialNumPath = firstRowPath + ":c:1:c";
        String serialNumFieldPath = serialNumPath + ":c";
        tester.assertLabel(serialNumPath + ":l", "Serial Number");
        tester.assertComponent(serialNumFieldPath, InputField.class);
        Component serialNumField = tester.getComponentFromLastRenderedPage(serialNumFieldPath);
       
        // Check attaching/detaching component's model (BeanPropertyModel).
        BeanPropertyModel nameFieldModel = (BeanPropertyModel) nameField.getDefaultModel();
       
        assertFalse(nestedModel.isAttached());
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.tester.WicketTester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.