Search in sources :

Example 1 with UiSession

use of org.eclipse.scout.rt.ui.html.UiSession in project scout.rt by eclipse.

the class JsonAdapterRegistryTest method testCreateDisposeInSameRequest.

@Test
public void testCreateDisposeInSameRequest() throws Exception {
    UiSession session = new UiSessionMock();
    IStringField model = new AbstractStringField() {
    };
    IJsonAdapter<?> adapter = session.getOrCreateJsonAdapter(model, null);
    // Note: Additionally, registry contains the "root adapter"
    assertEquals(2, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(1, session.currentJsonResponse().adapterMap().size());
    assertEquals(0, session.currentJsonResponse().eventList().size());
    model.setDisplayText("Test");
    assertEquals(2, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(1, session.currentJsonResponse().adapterMap().size());
    assertEquals(1, session.currentJsonResponse().eventList().size());
    adapter.dispose();
    assertEquals(1, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(0, session.currentJsonResponse().adapterMap().size());
    assertEquals(0, session.currentJsonResponse().eventList().size());
}
Also used : UiSessionMock(org.eclipse.scout.rt.ui.html.json.fixtures.UiSessionMock) IStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) UiSession(org.eclipse.scout.rt.ui.html.UiSession) Test(org.junit.Test)

Aggregations

AbstractStringField (org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField)1 IStringField (org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField)1 UiSession (org.eclipse.scout.rt.ui.html.UiSession)1 UiSessionMock (org.eclipse.scout.rt.ui.html.json.fixtures.UiSessionMock)1 Test (org.junit.Test)1