Package org.apache.oodt.cas.crawl.action

Examples of org.apache.oodt.cas.crawl.action.CrawlerAction


   public void testValidateActions() throws CrawlerActionException {
      // Test case invalid action.
      ProductCrawler pc = createDummyCrawler();
      pc.actionRepo = createMock(CrawlerActionRepo.class);

      CrawlerAction action = createMock(CrawlerAction.class);
      action.validate();
      expectLastCall().andThrow(new CrawlerActionException());
      expect(action.getId()).andReturn("ActionId");
      replay(action);

      expect(pc.actionRepo.getActions()).andReturn(
            Sets.newHashSet(action));
      replay(pc.actionRepo);
      try {
         pc.validateActions();
         fail("Should have thrown RuntimeException");
      } catch (RuntimeException e) { /* expect throw */ }
      verify(pc.actionRepo);
      verify(action);

      // Test case valid action.
      pc = createDummyCrawler();
      pc.actionRepo = createMock(CrawlerActionRepo.class);
      action = createMock(CrawlerAction.class);
      expect(pc.actionRepo.getActions()).andReturn(
            Sets.newHashSet(action));
      action.validate();
      replay(pc.actionRepo);
      replay(action);
      pc.validateActions();
      verify(pc.actionRepo);
      verify(action);
View Full Code Here


      // Test actionRepo == null.
      assertTrue(pc.performPreIngestActions(p, m));

      // Test actionRepo != null and performAction return true.
      CrawlerAction action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(true);
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPreIngestActions())
         .andReturn(Lists.newArrayList(action));
      replay(pc.actionRepo);

      assertTrue(pc.performPreIngestActions(p, m));
      verify(action);
      verify(pc.actionRepo);

      // Test actionRepo != null and performAction return false.
      action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(false);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPreIngestActions())
         .andReturn(Lists.newArrayList(action));
View Full Code Here

      // Test actionRepo == null.
      assertTrue(pc.performPostIngestOnSuccessActions(p, m));

      // Test actionRepo != null and performAction return true.
      CrawlerAction action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(true);
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPostIngestOnSuccessActions())
         .andReturn(Lists.newArrayList(action));
      replay(pc.actionRepo);

      assertTrue(pc.performPostIngestOnSuccessActions(p, m));
      verify(action);
      verify(pc.actionRepo);

      // Test actionRepo != null and performAction return false.
      action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(false);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPostIngestOnSuccessActions())
         .andReturn(Lists.newArrayList(action));
View Full Code Here

      // Test actionRepo == null.
      assertTrue(pc.performPostIngestOnFailActions(p, m));

      // Test actionRepo != null and performAction return true.
      CrawlerAction action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(true);
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPostIngestOnFailActions())
         .andReturn(Lists.newArrayList(action));
      replay(pc.actionRepo);

      assertTrue(pc.performPostIngestOnFailActions(p, m));
      verify(action);
      verify(pc.actionRepo);

      // Test actionRepo != null and performAction return false.
      action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(false);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      replay(action);

      pc.actionRepo = createMock(CrawlerActionRepo.class);
      expect(pc.actionRepo.getPostIngestOnFailActions())
         .andReturn(Lists.newArrayList(action));
View Full Code Here

      // Test no actions.
      assertTrue(pc.performProductCrawlerActions(
            Collections.<CrawlerAction>emptyList(), p, m));

      // Test 1 action pass.
      CrawlerAction action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(true);
      replay(action);
      assertTrue(pc.performProductCrawlerActions(
            Lists.newArrayList(action), p, m));
      verify(action);

      // Test 1 action fail.
      action = createMock(CrawlerAction.class);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      expect(action.performAction(p, m)).andReturn(false);
      expect(action.getId()).andReturn("ActionId");
      expect(action.getDescription()).andReturn("Action Description");
      replay(action);
      assertFalse(pc.performProductCrawlerActions(
            Lists.newArrayList(action), p, m));
      verify(action);

      // Test 1 action pass and 1 action fail.
      CrawlerAction passAction = createMock(CrawlerAction.class);
      expect(passAction.getId()).andReturn("ActionId");
      expect(passAction.getDescription()).andReturn("Action Description");
      expect(passAction.performAction(p, m)).andReturn(true);
      replay(passAction);
      CrawlerAction failAction = createMock(CrawlerAction.class);
      expect(failAction.getId()).andReturn("ActionId");
      expect(failAction.getDescription()).andReturn("Action Description");
      expect(failAction.performAction(p, m)).andReturn(false);
      expect(failAction.getId()).andReturn("ActionId");
      expect(failAction.getDescription()).andReturn("Action Description");
      replay(failAction);
      assertFalse(pc.performProductCrawlerActions(
            Lists.newArrayList(passAction, failAction), p, m));
      verify(passAction);
      verify(failAction);
View Full Code Here

            pc.getClientTransferer());
      assertEquals("http://localhost:9000", pc.getFilemgrUrl());
      assertEquals(
            Sets.newHashSet("DeleteDataFile", "MoveMetadataFileToFailureDir"),
            Sets.newHashSet(pc.getActionIds()));
      CrawlerAction action = (CrawlerAction) pc.getApplicationContext().getBean("DeleteDataFile");
      assertNotNull(action);
      MoveFile moveFileAction = (MoveFile) pc.getApplicationContext().getBean("MoveMetadataFileToFailureDir");
      Properties properties = new Properties();
      properties.load(new FileInputStream(new File(
            "src/main/resources/examples/Crawler/action-beans.properties")));
View Full Code Here

      String[] actionIds = this.getApplicationContext().getBeanNamesForType(
            CrawlerAction.class);
    PrintStream ps = new PrintStream(this.getOutStream());
    ps.println("Actions:");
    for (String actionId : actionIds) {
        CrawlerAction ca = (CrawlerAction) this.getApplicationContext()
                .getBean(actionId);
        ps.println("  Action:");
        ps.println("    Id: " + ca.getId());
        ps.println("    Description: " + ca.getDescription());
        ps.println("    Phases: " + ca.getPhases());
        if (ca instanceof MimeTypeCrawlerAction)
            ps.println("    MimeTypes: "
                    + ((MimeTypeCrawlerAction) ca).getMimeTypes());
        ps.println();
    }
View Full Code Here

        String[] actionIds = this.getApplicationContext().getBeanNamesForType(
                CrawlerAction.class);
        PrintStream ps = new PrintStream(this.getOutStream());
        ps.println("Actions:");
        for (String actionId : actionIds) {
            CrawlerAction ca = (CrawlerAction) this.getApplicationContext()
                    .getBean(actionId);
            ps.println("  Action:");
            ps.println("    Id: " + ca.getId());
            ps.println("    Description: " + ca.getDescription());
            ps.println("    Phases: " + ca.getPhases());
            if (ca instanceof MimeTypeCrawlerAction)
                ps.println("    MimeTypes: "
                        + ((MimeTypeCrawlerAction) ca).getMimeTypes());
            ps.println();
        }
View Full Code Here

            pc.getClientTransferer());
      assertEquals("http://localhost:9000", pc.getFilemgrUrl());
      assertEquals(
            Sets.newHashSet("DeleteDataFile", "MoveMetadataFileToFailureDir"),
            Sets.newHashSet(pc.getActionIds()));
      CrawlerAction action = (CrawlerAction) pc.getApplicationContext().getBean("DeleteDataFile");
      assertNotNull(action);
      MoveFile moveFileAction = (MoveFile) pc.getApplicationContext().getBean("MoveMetadataFileToFailureDir");
      Properties properties = new Properties();
      properties.load(new FileInputStream(new File(
            "src/main/resources/examples/Crawler/action-beans.properties")));
View Full Code Here

   public void testValidateActions() throws CrawlerActionException {
      // Test case invalid action.
      ProductCrawler pc = createDummyCrawler();
      pc.actionRepo = createMock(CrawlerActionRepo.class);

      CrawlerAction action = createMock(CrawlerAction.class);
      action.validate();
      expectLastCall().andThrow(new CrawlerActionException());
      expect(action.getId()).andReturn("ActionId");
      replay(action);

      expect(pc.actionRepo.getActions()).andReturn(
            Sets.newHashSet(action));
      replay(pc.actionRepo);
      try {
         pc.validateActions();
         fail("Should have thrown RuntimeException");
      } catch (RuntimeException e) { /* expect throw */ }
      verify(pc.actionRepo);
      verify(action);

      // Test case valid action.
      pc = createDummyCrawler();
      pc.actionRepo = createMock(CrawlerActionRepo.class);
      action = createMock(CrawlerAction.class);
      expect(pc.actionRepo.getActions()).andReturn(
            Sets.newHashSet(action));
      action.validate();
      replay(pc.actionRepo);
      replay(action);
      pc.validateActions();
      verify(pc.actionRepo);
      verify(action);
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.crawl.action.CrawlerAction

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.