Package org.geomajas.command

Examples of org.geomajas.command.CommandResponse


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

    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


    GetLocationForStringRequest request = new GetLocationForStringRequest();
    request.setCrs("EPSG:900913");
    request.setLocation("bla");
    request.setServicePattern("alt1");

    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

    GetLocationForStringRequest request = new GetLocationForStringRequest();
    request.setCrs("EPSG:900913");
    request.setLocation("bla");
    request.setServicePattern(".?.?.?2");

    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

    GetLocationForStringRequest request = new GetLocationForStringRequest();
    request.setCrs("EPSG:900913");
    request.setLocation("bla");
    request.setServicePattern("alt.?");

    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

    GetLocationForStringRequest request = new GetLocationForStringRequest();
    request.setCrs("EPSG:900913");
    request.setLocation("bla");
    request.setServicePattern("a");

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

  // assure we are logged in as a specific user to set correct authorizations
  public void login(String name) {
    LoginRequest request = new LoginRequest();
    request.setLogin(name);
    request.setPassword(name);
    CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, "en");
    Assert.assertFalse(response.isError());
    Assert.assertTrue(response instanceof LoginResponse);
    securityManager.createSecurityContext(((LoginResponse)response).getToken());
  }
View Full Code Here

  // assure we are logged in as a specific user to set correct authorizations
  public void login(String name) {
    LoginRequest request = new LoginRequest();
    request.setLogin(name);
    request.setPassword(name);
    CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, "en");
    Assert.assertFalse(response.isError());
    Assert.assertTrue(response instanceof LoginResponse);
    securityManager.createSecurityContext(((LoginResponse)response).getToken());
  }
View Full Code Here

  @Test
  public void testLogAllowed() throws Exception {
    LoginRequest request = new LoginRequest();
    request.setLogin("luc");
    request.setPassword("luc");
    CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, null);
    Assert.assertTrue(response instanceof LoginResponse);
    Assert.assertFalse(response.isError());
    String token = ((LoginResponse)response).getToken();
    Assert.assertNotNull(token);
    Assert.assertNull(securityContext.getToken());

    LogRequest logRequest = new LogRequest();
    logRequest.setStatement("test log command access");
    response = commandDispatcher.execute(LogRequest.COMMAND, logRequest, token, "en");
    Assert.assertFalse(response.isError());
    Assert.assertNull(securityContext.getToken());

    // this test to verify the command itself (should fail here as "luc" should be logged in).
    response = commandDispatcher.execute("command.MarinoLoggedIn", null, token, "en");
    Assert.assertTrue(response.isError());
    Assert.assertTrue(response.getErrors().get(0) instanceof GeomajasException);
    Assert.assertEquals(ExceptionCode.TEST, ((GeomajasException)response.getErrors().get(0)).getExceptionCode());
    Assert.assertNull(securityContext.getToken());
  }
View Full Code Here

  @Test
  public void testLogNotAllowed() throws Exception {
    LoginRequest request = new LoginRequest();
    request.setLogin("marino");
    request.setPassword("marino");
    CommandResponse response = commandDispatcher.execute(LoginRequest.COMMAND, request, null, null);
    Assert.assertTrue(response instanceof LoginResponse);
    Assert.assertFalse(response.isError());
    String token = ((LoginResponse)response).getToken();
    Assert.assertNotNull(token);
    Assert.assertNull(securityContext.getToken());

    LogRequest logRequest = new LogRequest();
    logRequest.setStatement("test log command access");
    response = commandDispatcher.execute("command.general.Log", logRequest, token, "en");
    Assert.assertTrue(response.isError());
    Assert.assertEquals("User marino is not authorized to use the command command.general.Log.",
        response.getErrorMessages().get(0)); // needs to be updated when messages file is changed
    Assert.assertNull(securityContext.getToken());

    response = commandDispatcher.execute("command.MarinoLoggedIn", null, token, "en");
    Assert.assertFalse(response.isError());
    Assert.assertNull(securityContext.getToken());
  }
View Full Code Here

  // assure we are logged in as a specific user to set correct authorizations
  public void login(String name) {
    LoginRequest request = new LoginRequest();
    request.setLogin(name);
    request.setPassword(name);
    CommandResponse response = commandDispatcher.execute("command.staticsecurity.Login", request, null, "en");
    Assert.assertFalse(response.isError());
    Assert.assertTrue(response instanceof LoginResponse);
    securityManager.createSecurityContext(((LoginResponse)response).getToken());
  }
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.