GWT rpc callback does not call after calling in GWTTestCase

24 views
Skip to first unread message

Saeed Zarinfam

unread,
Jan 7, 2013, 6:04:23 AM1/7/13
to google-we...@googlegroups.com
I have written a GWTTestCase like this:

    public void testClickButton() {
        SampleView view = new SampleView();
        RootPanel.get().add(view);
        view.textBox.setText("Saeed Zarinfam");

        assertEquals("", view.label.getText());

    //        ButtonElement.as(view.button.getElement()).click();
        view.button.getElement().<ButtonElement>cast().click();

        assertEquals("Bean \"OCTO\" has been created", view.label.getText());
    }

When i run this test it connect to my servlet (i added some log on my servlet) but the RPC callback does not call in my `SampleView`, junit say:
   
    expected: <Bean "OCTO" has been created>, actual: <>

This is my callback in button click handler:

    @UiHandler("button")
    void onClick(ClickEvent e) {
       
        labelTest.setText("click button");
       
        AsyncCallback<FooBean> callback = new AsyncCallback<FooBean>() {
            public void onFailure(Throwable caught) {
                // Show the RPC error message to the user
                labelTest.setText("call fail");
                label.setText("Failure : " + caught.getMessage());
            }

            public void onSuccess(FooBean result) {
                labelTest.setText("call success");
                label.setText("Bean \"" + result.getName() + "\" has been created");
            }
        };

        // Make the call. Control flow will continue immediately and later
        // 'callback' will be invoked when the RPC completes.
        service.createBean("OCTO", callback);
       
       
    }

Why GWT rpc callback does not call in this case?
       

Thomas Broyer

unread,
Jan 7, 2013, 6:15:46 AM1/7/13
to google-we...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages