Exemplo n.º 1
0
  @Test
  public void shouldNotIndexNotQueryableConnector() throws Exception {
    federationManager.createProjection(
        "/testRoot", "mock-source-non-queryable", MockConnector.DOC2_LOCATION, "federated2");

    Workspace workspace = session.getWorkspace();
    workspace.reindex();

    QueryManager queryManager = workspace.getQueryManager();
    Query query =
        queryManager.createQuery(
            "select * FROM [nt:base] WHERE [jcr:path] LIKE '/testRoot/federated2'", Query.JCR_SQL2);
    assertEquals(0, query.execute().getNodes().getSize());

    query =
        queryManager.createQuery(
            "select * FROM [nt:base] WHERE [jcr:path] LIKE '/testRoot/federated2/federated3'",
            Query.JCR_SQL2);
    assertEquals(0, query.execute().getNodes().getSize());

    Node externalNode = session.getNode("/testRoot/federated2/federated3");
    externalNode.setProperty("test", "a value");
    session.save();

    query =
        queryManager.createQuery(
            "select * FROM [nt:base] as a WHERE a.test='a value'", Query.JCR_SQL2);
    assertEquals(0, query.execute().getNodes().getSize());
  }
Exemplo n.º 2
0
  @Test
  public void shouldIndexQueryableBranches() throws Exception {
    Node git = gitNode();
    Workspace workspace = session.getWorkspace();

    // force reindexing of tags and check that they haven't been indexed
    workspace.reindex(git.getPath() + "/tags");
    Query query =
        workspace
            .getQueryManager()
            .createQuery(
                "SELECT * FROM [nt:base] WHERE [jcr:path] LIKE '%/tags/%'", Query.JCR_SQL2);
    assertEquals(0, query.execute().getNodes().getSize());

    // force reindexing of branches and check that they haven't been indexed
    workspace.reindex(git.getPath() + "/branches");
    query =
        workspace
            .getQueryManager()
            .createQuery(
                "SELECT * FROM [nt:base] WHERE [jcr:path] LIKE '%/branches/%'", Query.JCR_SQL2);
    assertEquals(0, query.execute().getNodes().getSize());

    // force reindexing of a file under master/tree and check that it has been indexed
    // (indexing everything under /tree/master is way too expensive)
    workspace.reindex(git.getPath() + "/tree/master/.gitignore");
    query =
        workspace
            .getQueryManager()
            .createQuery(
                "SELECT * FROM [nt:base] WHERE [jcr:path] LIKE '%/tree/master/%'", Query.JCR_SQL2);
    assertTrue(query.execute().getNodes().getSize() > 0);

    // force reindexing of a file under another configured branch and check that it has been indexed
    workspace.reindex(git.getPath() + "/tree/2.x/.gitignore");
    query =
        workspace
            .getQueryManager()
            .createQuery(
                "SELECT * FROM [nt:base] WHERE [jcr:path] LIKE '%/tree/2.x/%'", Query.JCR_SQL2);
    assertTrue(query.execute().getNodes().getSize() > 0);
  }
Exemplo n.º 3
0
  @Test
  public void shouldNotIndexNotQueryableDocument() throws Exception {
    federationManager.createProjection(
        "/testRoot", SOURCE_NAME, MockConnector.NONT_QUERYABLE_DOC_LOCATION, "nonQueryableDoc");

    Workspace workspace = session.getWorkspace();
    workspace.reindex();

    Node externalNode = assertNodeFound("/testRoot/nonQueryableDoc");

    QueryManager queryManager = workspace.getQueryManager();
    Query query =
        queryManager.createQuery(
            "select * FROM [nt:base] WHERE [jcr:path] LIKE '/testRoot/nonQueryableDoc'",
            Query.JCR_SQL2);
    validateQuery().rowCount(0).validate(query, query.execute());

    // change the document and re-run the query
    externalNode.setProperty("test", "a value");
    session.save();
    validateQuery().rowCount(0).validate(query, query.execute());
  }