Hide Forgot
Steps to Reproduce: We can use the [FileSystemRepositoryIntegrationTest.java|https://github.com/ModeShape/modeshape/blob/master/modeshape-integration-tests/src/test/java/org/modeshape/test/integration/filesystem/FileSystemRepositoryIntegrationTest.java] to illustrate the issue, let us add some folders ie:folder1 & folder2 into the repository before running the unit tests. {code:java} @Override public void beforeEach() throws Exception { // Delete the directory used for the FS store ... FileUtil.delete("target/fsRepoWithProps"); // Now make the root directory ... new File("target/fsRepoWithProps/root").mkdirs(); new File("target/fsRepoWithProps/root/defaultWorkspace/folder1").mkdirs(); new File("target/fsRepoWithProps/root/defaultWorkspace/folder2").mkdirs(); super.beforeEach(); } {code} Let us create a new unit @Test TestQueryingExistingContent() as below: {code:java} @Test public void TestQueryingExistingContent() throws Exception { startEngineUsing("config/configRepositoryForFileSystemWithExtraProperties.xml"); Session session = session(); //Create a new Node (after session is started) session.getRootNode().addNode("NewFolder", "nt:folder"); session.save(); //Query all nodes String sql = "SELECT * FROM [nt:base]"; Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); QueryResult result = query.execute(); System.out.println(result.toString()); logout(); } {code} The result of @Test TestQueryingExistingContent() :- {code} ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.modeshape.test.integration.filesystem.FileSystemRepositoryIntegrationTest +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ | # | jcr:primaryType | jcr:path | jcr:name | jcr:score | mode:localName | mode:depth | Location(nt:base) | Score(nt:base) | +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ | 1 | mode:root | / | | 1.0 | | 0 | </ && [{http://www.modeshape.org/1.0}uuid = cafebabe-cafe-babe-cafe-babecafebabe]> | 1.0 | | 2 | nt:folder | /NewFolder | NewFolder | 1.0 | NewFolder | 1 | /{}NewFolder | 1.0 | +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ {code} As shown above, only the Root node and the newly created "NewFolder" node are returned by the Query. The Query won't address the existing "folder1" or "folder2", we can even put some text file into "folder1" or "folder2", it won't show either. So, all existing nodes (except Root node) before session start won't be addressed by the Query. Putting Thread.sleep(3000) before Query.execute() won't help either. *Pls noted that for @Test shouldFindAllNodesWhenQueryingContent(), it doesn't address any existing nodes inside the Repository, all its print out via printQuery("SELECT * FROM [nt:base]", 5L, Collections.<String, String>emptyMap()); only return Root node and its newly created nodes after session started (Total 5 rows). However, this @Test still PASS, but by right, it should FAIL because we are expecting 7 rows returned due to the existing "folder1" & "folder2" and is not match with "5L". But of course, if we change the printQuery() -> "5L" to "7L", then this @Test will FAIL with Error:"Expected different number of rows from 'SELECT * FROM [nt:base]". project_key: SOA - The Query is not addressing those existing nodes inside the FileSystem Connector's repository before the Session start. So, the query will just return Root node even though the repository already have multiple folder or files. - The Query is only address those nodes created (save or not saved) after Session start. - This Query problem confirmed happen to FileSystem connector (as tested so far using Standalone or App Server), whereas for Disk,Database,InMemory connectors, the Query is working just fine. Not tested with other type of connector yet. - Putting Thread.sleep(3000) before Query.execute won't help. - Related unit @Test is at \modeshape-integration-tests\src\test\java\org\modeshape\test\integration\filesystem\FileSystemRepositoryIntegrationTest.java
Link: Added: This issue Cloned from MODE-1263
Workflow: Removed: GIT Pull Request workflow Added: jira Security: Added: Public
Committed to ModeShape 2.5.x branch: CommitID: 52153ce2135d860a5efdc0848232c4b92bedb717
10/11/2011 Passing Unit Test.