From: <die...@us...> - 2013-06-27 09:34:17
|
Revision: 4268 http://openutils.svn.sourceforge.net/openutils/?rev=4268&view=rev Author: diego_schivo Date: 2013-06-27 09:34:10 +0000 (Thu, 27 Jun 2013) Log Message: ----------- CRIT-54 unit-test + fix Modified Paths: -------------- magnoliamodules/trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java Added Paths: ----------- magnoliamodules/trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.escape-sign.xml Removed Paths: ------------- magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.n?\194?\176-21.xml Modified: magnoliamodules/trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java =================================================================== --- magnoliamodules/trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2013-06-26 07:09:51 UTC (rev 4267) +++ magnoliamodules/trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2013-06-27 09:34:10 UTC (rev 4268) @@ -150,6 +150,11 @@ { encodedPath.append("_x00b0_"); } + // CRIT-54 + else if (inXpathCondition <= 0 && ch == '$') + { + encodedPath.append("_x0024_"); + } else { Added: magnoliamodules/trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java =================================================================== --- magnoliamodules/trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java (rev 0) +++ magnoliamodules/trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java 2013-06-27 09:34:10 UTC (rev 4268) @@ -0,0 +1,120 @@ +/** + * + * Criteria API for Magnolia CMS (http://www.openmindlab.com/lab/products/mgnlcriteria.html) + * Copyright(C) 2009-2013, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.sourceforge.openutils.mgnlcriteria.jcr.query; + +import info.magnolia.cms.core.MgnlNodeType; +import info.magnolia.cms.i18n.DefaultI18nContentSupport; +import info.magnolia.cms.i18n.I18nContentSupport; +import info.magnolia.cms.security.MgnlRoleManager; +import info.magnolia.cms.security.Realm; +import info.magnolia.cms.security.SecuritySupport; +import info.magnolia.cms.security.SecuritySupportImpl; +import info.magnolia.cms.security.SystemUserManager; +import info.magnolia.context.MgnlContext; +import info.magnolia.repository.RepositoryConstants; +import info.magnolia.test.ComponentsTestUtil; +import it.openutils.mgnlutils.test.RepositoryTestConfiguration; +import it.openutils.mgnlutils.test.TestNgRepositoryTestcase; + +import javax.jcr.Node; + +import net.sourceforge.openutils.mgnlcriteria.jcr.query.criterion.Restrictions; +import net.sourceforge.openutils.mgnlcriteria.tests.CriteriaTestUtils; + +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +/** + * @author dschivo + */ +@RepositoryTestConfiguration(jackrabbitRepositoryConfig = "/crit-repository/jackrabbit-test-configuration.xml", repositoryConfig = "/crit-repository/test-repositories.xml", bootstrapFiles = { + "/crit-bootstrap/website.escape-sign.xml", + "/crit-bootstrap/userroles.anonymous.xml", + "/crit-bootstrap/users.system.anonymous.xml" }) +public class EscapeSignTest extends TestNgRepositoryTestcase +{ + + /** + * {@inheritDoc} + */ + @Override + @BeforeClass + public void setUp() throws Exception + { + super.setUp(); + + // Nodes in this workspace: + // - escape-sign (title=escape-sign) + // --- fo°o (title=fo°o) + // ----- bar (title=bar) + // --- fo$o (title=fo$o) + // ----- baz (title=baz) + MgnlContext.getJCRSession(RepositoryConstants.WEBSITE).save(); + + ComponentsTestUtil.setInstance(I18nContentSupport.class, new DefaultI18nContentSupport()); + + // info.magnolia.cms.security.SecurityTest.setUp() + final SecuritySupportImpl sec = new SecuritySupportImpl(); + sec.addUserManager(Realm.REALM_SYSTEM.getName(), new SystemUserManager()); + sec.setRoleManager(new MgnlRoleManager()); + ComponentsTestUtil.setInstance(SecuritySupport.class, sec); + } + + /** + * CRIT-53 + * @throws Exception + */ + @Test + public void testDegree() throws Exception + { + Criteria criteria = JCRCriteriaFactory + .createCriteria() + .setWorkspace(RepositoryConstants.WEBSITE) + .setBasePath("/jcr:root/escape-sign/fo°o/*") + .add(Restrictions.eq("@jcr:primaryType", MgnlNodeType.NT_CONTENT)); + AdvancedResult result = criteria.execute(); + ResultIterator< ? extends Node> iterator = result.getItems(); + Assert.assertTrue(iterator.hasNext()); + Node resultNode = iterator.next(); + Assert.assertEquals(CriteriaTestUtils.title(resultNode), "bar"); + } + + /** + * CRIT-54 + * @throws Exception + */ + @Test + public void testDollar() throws Exception + { + Criteria criteria = JCRCriteriaFactory + .createCriteria() + .setWorkspace(RepositoryConstants.WEBSITE) + .setBasePath("/jcr:root/escape-sign/fo$o/*") + .add(Restrictions.eq("@jcr:primaryType", MgnlNodeType.NT_CONTENT)); + AdvancedResult result = criteria.execute(); + ResultIterator< ? extends Node> iterator = result.getItems(); + Assert.assertTrue(iterator.hasNext()); + Node resultNode = iterator.next(); + Assert.assertEquals(CriteriaTestUtils.title(resultNode), "baz"); + } + +} Property changes on: magnoliamodules/trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.escape-sign.xml =================================================================== --- magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.escape-sign.xml (rev 0) +++ magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.escape-sign.xml 2013-06-27 09:34:10 UTC (rev 4268) @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="escape-sign" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:content</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>6097bd5d-db7c-4aad-9c2f-3196f739f4db</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="title" sv:type="String"> + <sv:value>escape-sign</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2013-06-27T11:19:11.366+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2013-06-27T11:20:06.486+02:00</sv:value> + </sv:property> + </sv:node> + <sv:node sv:name="fo°o"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:content</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>1abf4df8-c80d-4678-83d6-49d15ff96bd1</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="title" sv:type="String"> + <sv:value>fo°o</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2013-06-25T16:32:26.039+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2013-06-27T11:20:09.940+02:00</sv:value> + </sv:property> + </sv:node> + <sv:node sv:name="bar"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:content</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>9e18493e-206f-470b-a855-c5b40eaf0c11</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="title" sv:type="String"> + <sv:value>bar</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2013-06-25T16:32:34.955+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2013-06-27T11:20:14.028+02:00</sv:value> + </sv:property> + </sv:node> + </sv:node> + </sv:node> + <sv:node sv:name="fo$o"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:content</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>d56d7990-f019-4e4c-a6ee-d9a54749f0e6</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="title" sv:type="String"> + <sv:value>fo$o</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2013-06-25T16:32:26.039+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2013-06-27T11:20:17.500+02:00</sv:value> + </sv:property> + </sv:node> + <sv:node sv:name="baz"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:content</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>68973b3b-c68a-4746-bbe7-316ec65f6cbf</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="title" sv:type="String"> + <sv:value>baz</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2013-06-25T16:32:34.955+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2013-06-27T11:20:22.361+02:00</sv:value> + </sv:property> + </sv:node> + </sv:node> + </sv:node> +</sv:node> Property changes on: magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.escape-sign.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/xml \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Deleted: magnoliamodules/trunk/openutils-mgnlcriteria/src/test/resources/crit-bootstrap/website.n?\194?\176-21.xml =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |