public void testStartupRequestWithParameter() throws Exception {
    RWTFactory.getEntryPointManager().registerByPath("/rap", DefaultEntryPoint.class, null);
    Fixture.fakeNewGetRequest();
    Fixture.fakeRequestParam("param", "value");
    RWTFactory.getServiceManager().getHandler().service();

    Fixture.fakeNewRequest();
    Fixture.fakeRequestParam("param", null);
    Fixture.fakeRequestParam(RequestParams.RWT_INITIALIZE, "true");
    RWTFactory.getServiceManager().getHandler().service();

    assertEquals("value", ContextProvider.getRequest().getParameter("param"));
  }
  public void testGetCurrentEntryPointParameter_withStartupParameter() {
    RWTFactory.getEntryPointManager().registerByName("foo", entryPointFactory);
    Fixture.fakeRequestParam(RequestParams.STARTUP, "foo");

    Map<String, String> properties = EntryPointUtil.getCurrentEntryPointProperties();

    assertTrue(properties.isEmpty());
  }
  public void testGetCurrentEntryPoint_withStartupParameter() {
    RWTFactory.getEntryPointManager().registerByName("foo", entryPointFactory);
    Fixture.fakeRequestParam(RequestParams.STARTUP, "foo");

    IEntryPoint result = EntryPointUtil.getCurrentEntryPoint();

    verify(entryPointFactory).create();
    assertSame(entryPoint, result);
  }
  public void testGetCurrentEntryPoint_withNonExistingEntryPointName() {
    Fixture.fakeRequestParam(RequestParams.STARTUP, "foo");

    try {
      EntryPointUtil.getCurrentEntryPoint();
      fail();
    } catch (IllegalArgumentException expected) {
      assertEquals("Entry point not found: foo", expected.getMessage());
    }
  }
  public void testGetCurrentEntryPoint_parameterOverridesServletPath() {
    RWTFactory.getEntryPointManager().registerByName("foo", entryPointFactory);
    IEntryPoint entryPointByPath = mockEntryPoint();
    IEntryPointFactory entryPointFactoryByPath = mockEntryPointFactory(entryPointByPath);
    RWTFactory.getEntryPointManager().registerByPath("/bar", entryPointFactoryByPath, null);
    fakeServletPath("/bar");
    Fixture.fakeRequestParam(RequestParams.STARTUP, "foo");

    IEntryPoint result = EntryPointUtil.getCurrentEntryPoint();

    // Request parameter takes precedence over servlet path
    verify(entryPointFactoryByPath, times(0)).create();
    verify(entryPointFactory).create();
    assertSame(entryPoint, result);
  }
 private void testSelectionEvent(final Scale scale) {
   final StringBuilder log = new StringBuilder();
   SelectionListener selectionListener =
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           assertEquals(scale, event.getSource());
           assertEquals(null, event.item);
           assertEquals(SWT.NONE, event.detail);
           assertEquals(0, event.x);
           assertEquals(0, event.y);
           assertEquals(0, event.width);
           assertEquals(0, event.height);
           assertEquals(true, event.doit);
           log.append("widgetSelected");
         }
       };
   scale.addSelectionListener(selectionListener);
   String scaleId = WidgetUtil.getId(scale);
   Fixture.fakeRequestParam(JSConst.EVENT_WIDGET_SELECTED, scaleId);
   Fixture.readDataAndProcessAction(scale);
   assertEquals("widgetSelected", log.toString());
 }