-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODE-838 Fixed the XPathQueryResult class in a similar way to what wa…
…s done to the JcrSqlQueryResult class for MODE-773: simply keep a list of the types (like the names) in the subclass. Added a new unit test to verify the desired behavior, and all unit and integration tests pass. git-svn-id: https://svn.jboss.org/repos/modeshape/trunk@2072 76366958-4244-0410-ad5e-bbfabb93f86b
- Loading branch information
Randall Hauch
committed
Jul 31, 2010
1 parent
8a25404
commit 142e1f8
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
modeshape-jcr/src/test/java/org/modeshape/jcr/query/XPathQueryResultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* ModeShape (http://www.modeshape.org) | ||
* See the COPYRIGHT.txt file distributed with this work for information | ||
* regarding copyright ownership. Some portions may be licensed | ||
* to Red Hat, Inc. under one or more contributor license agreements. | ||
* See the AUTHORS.txt file in the distribution for a full listing of | ||
* individual contributors. | ||
* | ||
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape | ||
* is licensed to you under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* ModeShape is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.modeshape.jcr.query; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.modeshape.graph.query.QueryResults; | ||
import org.modeshape.graph.query.QueryResults.Columns; | ||
import org.modeshape.graph.query.model.Column; | ||
import org.modeshape.graph.query.model.SelectorName; | ||
import org.modeshape.graph.query.process.QueryResultColumns; | ||
import org.modeshape.graph.query.validate.Schemata; | ||
|
||
public class XPathQueryResultTest { | ||
|
||
private XPathQueryResult result; | ||
private JcrQueryContext context; | ||
private String query; | ||
private QueryResults graphResult; | ||
private Schemata schemata; | ||
private Columns resultColumns; | ||
private List<String> columnTypes; | ||
private List<String> columnNames; | ||
private List<Column> columns; | ||
|
||
@Before | ||
public void beforeEach() { | ||
schemata = mock(Schemata.class); | ||
context = mock(JcrQueryContext.class); | ||
query = "SELECT jcr:primaryType, foo:bar FROM nt:unstructured"; | ||
graphResult = mock(QueryResults.class); | ||
columnTypes = Arrays.asList("STRING", "LONG"); | ||
columnNames = Arrays.asList("jcr:primaryType", "foo:bar"); | ||
SelectorName tableName = new SelectorName("nt:unstructured"); | ||
columns = Arrays.asList(new Column(tableName, columnNames.get(0), columnNames.get(0)), new Column(tableName, | ||
columnNames.get(1), | ||
columnNames.get(1))); | ||
resultColumns = new QueryResultColumns(columns, columnTypes, true); | ||
when(graphResult.getColumns()).thenReturn(resultColumns); | ||
|
||
result = new XPathQueryResult(context, query, graphResult, schemata); | ||
} | ||
|
||
@Test | ||
public void shouldHaveSameNumberOfColumnNamesAsTypes() { | ||
assertThat(result.getColumnNames(), is(new String[] {"jcr:path", "jcr:score", "jcr:primaryType", "foo:bar"})); | ||
assertThat(result.getColumnTypes(), is(new String[] {"STRING", "DOUBLE", "STRING", "LONG"})); | ||
} | ||
} |