Package org.geomajas.command

Examples of org.geomajas.command.CommandResponse


  @Test
  public void testLog() throws Exception {
    LogRequest request = new LogRequest();
    request.setLevel(LogRequest.LEVEL_INFO);
    request.setStatement("Test log command");
    CommandResponse response = dispatcher.execute(LogRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());

    request.setLevel(LogRequest.LEVEL_DEBUG);
    request.setStatement("Test debug log command");
    response = dispatcher.execute(LogRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());

    request.setLevel(LogRequest.LEVEL_WARN);
    request.setStatement("Test warn log command");
    response = dispatcher.execute(LogRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());

    request.setLevel(LogRequest.LEVEL_ERROR);
    request.setStatement("Test error log command");
    response = dispatcher.execute(LogRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
  }
View Full Code Here


  private SecurityTestCommand securityCommand;

  @Test
  public void testValidToken() {
    securityService.put("someToken", createTestAuthentication());
    CommandResponse response = commandDispatcher.execute("test.SecurityTestCommand", null, "someToken", null);
    Assert.assertEquals(0, response.getErrors().size());
  }
View Full Code Here

  }
 
  @Test
  public void testBadCommand() {
    securityService.put("someToken", createTestAuthentication());
    CommandResponse response = commandDispatcher.execute("test.BadCommand", null, "someToken", null);
    Assert.assertEquals(1, response.getErrors().size());
    Throwable error = response.getErrors().get(0);
    Assert.assertTrue(error instanceof GeomajasException);
    Assert.assertEquals(ExceptionCode.COMMAND_ACCESS_DENIED, ((GeomajasException) error).getExceptionCode());
  }
View Full Code Here

  }

  @Test
  public void testInValidToken() {
    securityService.put("someToken", createTestAuthentication());
    CommandResponse response = commandDispatcher.execute("test.SecurityTestCommand", null, "invalid", null);
    Assert.assertEquals(1, response.getErrors().size());
    Throwable error = response.getErrors().get(0);
    Assert.assertTrue(error instanceof GeomajasSecurityException);
    Assert.assertEquals(ExceptionCode.CREDENTIALS_MISSING_OR_INVALID,
        ((GeomajasSecurityException) error).getExceptionCode());
  }
View Full Code Here

        ((GeomajasSecurityException) error).getExceptionCode());
  }

  @Test
  public void testNullToken() {
    CommandResponse response = commandDispatcher.execute("test.SecurityTestCommand", null, null, null);
    Assert.assertEquals(1, response.getErrors().size());
    Throwable error = response.getErrors().get(0);
    Assert.assertTrue(error instanceof GeomajasSecurityException);
    Assert.assertEquals(ExceptionCode.CREDENTIALS_MISSING_OR_INVALID,
        ((GeomajasSecurityException) error).getExceptionCode());
  }
View Full Code Here

      public void run() {
        Assert.assertEquals("someToken", securityContext.getToken());
      }

    });
    CommandResponse response = commandDispatcher.execute("test.SecurityTestCommand", null, "someToken", null);
    Assert.assertEquals(0, response.getErrors().size());
  }
View Full Code Here

   * Execute a GWT RPC command request, and return the response. These request come from the client, and the response
   * is sent back to the client. We use a {@link CommandDispatcher} to actually execute the command.
   */
  public CommandResponse execute(Command request) {
    if (request != null) {
      CommandResponse result = null;
      result = commandDispatcher.execute(request.getCommandName(), request.getCommandRequest(),
          request.getUserToken(), request.getLocale());
      return result;
    }
    return null;
View Full Code Here

  }

  @Test
  public void testInvalidRequest() throws Exception {
    SearchByPointRequest request = new SearchByPointRequest();
    CommandResponse response = dispatcher.execute(SearchByPointRequest.COMMAND, request, null, "en");
    Assert.assertTrue(response.isError());
    List<Throwable> errors = response.getErrors();
    Assert.assertNotNull(errors);
    Assert.assertEquals(1, errors.size());
    Throwable error = errors.get(0);
    Assert.assertTrue(error instanceof GeomajasException);
    Assert.assertEquals(ExceptionCode.PARAMETER_MISSING, ((GeomajasException) error).getExceptionCode());
View Full Code Here

    request.setBbox(new Bbox(-3211986.0066263545, 98246.25012821658, 1.065471024672729E7, 3365675.229452881));
    request.setCrs("EPSG:900913");
    request.setLayerIds(new String[] {layer});
    request.setLocation(new Coordinate(672238.022713162, 2554015.0948743597));
    request.setScale(1.022083167709322E-4);
    CommandResponse response = dispatcher.execute(SearchByPointRequest.COMMAND, request, null, "en");
    Assert.assertFalse(response.isError());
    Assert.assertTrue(response instanceof SearchByPointResponse);
    SearchByPointResponse sbp = (SearchByPointResponse) response;
    Map<String, List<Feature>> map = sbp.getFeatureMap();
    Assert.assertNotNull(map);
    List<Feature> features = map.get(layer);
View Full Code Here

  public void expandPointTest() throws Exception {
    GetLocationForStringRequest request = new GetLocationForStringRequest();
    request.setCrs("EPSG:900913");
    request.setLocation("booischot");

    CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
        "en");
    Assert.assertNotNull(commandResponse);
    Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
    GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
    Assert.assertTrue(response.isLocationFound());
View Full Code Here

TOP

Related Classes of org.geomajas.command.CommandResponse

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.