Package gobo

Examples of gobo.ControllerTester


    datastore.put(bulkData);

    String[] kinds = { "TestKind1" };
    SpreadsheetEntry ssEntry = SpreadsheetUtil.createBlunkSpreadsheet(authSubToken, kinds);
    try {
      ControllerTester tester = new ControllerTester();
      Key controlKey =
        TaskQueueUtil.prepareDumpControlKey("TestKind1", ssEntry.getKey(), authSubToken);
      tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
      String run = tester.start("/tasks/dump");
      assertNull(run);

      LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
      String defaultQueueName = QueueFactory.getDefaultQueue().getQueueName();
      QueueStateInfo qsi = ltq.getQueueStateInfo().get(defaultQueueName);
      List<TaskStateInfo> taskInfo = qsi.getTaskInfo();
      assertThat(taskInfo.get(0).getUrl(), equalTo("/tasks/dump.gobo?controlKey="
        + KeyFactory.keyToString(controlKey)));

      TaskQueueUtil.removeTasks();

      // 2nd time.
      run = tester.start("/tasks/dump");
      assertNull(run);

      ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
      defaultQueueName = QueueFactory.getDefaultQueue().getQueueName();
      qsi = ltq.getQueueStateInfo().get(defaultQueueName);
View Full Code Here


    String[] kinds = { "TestKind1" };
    SpreadsheetEntry ssEntry = SpreadsheetUtil.createSpreadsheet(authSubToken, kinds);

    try {
      ControllerTester tester = new ControllerTester();
      Key controlKey =
        TaskQueueUtil.prepareDumpControlKey("TestKind1", ssEntry.getKey(), authSubToken);
      tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
      String run = tester.start("/tasks/dump");
      assertNull(run);

      LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
      String defaultQueueName = QueueFactory.getDefaultQueue().getQueueName();
      QueueStateInfo qsi = ltq.getQueueStateInfo().get(defaultQueueName);
View Full Code Here

  @Test(expected = EntityNotFoundException.class)
  public void runOverRetryCountTest() throws Exception {

    Key controlKey = TaskQueueUtil.prepareDropControlKey("TestKind1");

    ControllerTester tester = new ControllerTester();
    tester.request.setHeader("X-AppEngine-TaskRetryCount", "11");
    tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
    String run = tester.start("/tasks/dump");
    assertNull(run);

    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    ds.get(controlKey);
 
View Full Code Here

    SpreadsheetEntry ssEntry = SpreadsheetUtil.createSpreadsheet(authSubToken, kinds);
    try {
      Key controlKey =
        TaskQueueUtil.prepareDumpControlKey("TestKind1", ssEntry.getKey(), authSubToken);

      ControllerTester tester = new ControllerTester();
      tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));

      String run = tester.start("/tasks/dumpEnd");
      assertNull(run);

      LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
      String defaultQueueName = QueueFactory.getDefaultQueue().getQueueName();
      QueueStateInfo qsi = ltq.getQueueStateInfo().get(defaultQueueName);
View Full Code Here

  final String authSubToken = bundle.getString("token");

  @Test
  public void singleTaskTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);

    String run = tester.start("/dump/started");
    assertNotNull(run);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void runTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    String run = tester.start("/dump/index");
    assertNotNull(run);
    List<Map<String, Object>> list = (List) tester.request.getAttribute("list");
    assertNull(list);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void runAuthWithoutDataTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);

    String run = tester.start("/dump/index");
    assertNotNull(run);
    List<Map<String, Object>> list = (List) tester.request.getAttribute("list");
    assertThat(list.size(), is(0));

  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void runAuthWithDataTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);

    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    Entity entity = new Entity(KeyFactory.createKey("TestKind", 1));
    ds.put(entity);

    String run = tester.start("/dump/index");
    assertNotNull(run);
    List<Map<String, Object>> list = (List) tester.request.getAttribute("list");
    assertThat(list.size(), is(1));

    Map row = list.get(0);
View Full Code Here

  final String authSubToken = bundle.getString("token");
 
  @Test
  public void runAuthSingleTaskTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);
   
    tester.request.setParameter("kindArray", TestDataUtil.TEST_KIND);
    String run = tester.start("/dump/start");
    assertNotNull(run);
   
    TaskQueueUtil.removeTasks();
  }
View Full Code Here

  }

  @Test
  public void runAuthMoreThan5TasksTest() throws Exception {

    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);

    String[] kinds =
      {
        "Kind1",
        "Kind2",
        "Kind3",
        "kind4",
        "Kind5",
        "Kind6",
        "Kind7",
        "Kind8",
        "Kind9",
        "Kind10" };
    tester.request.setParameter("kindArray", kinds);

    String run = tester.start("/dump/start");
    assertNotNull(run);
   
    TaskQueueUtil.removeTasks();
  }
View Full Code Here

TOP

Related Classes of gobo.ControllerTester

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.