You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2013/05/23 15:35:58 UTC

svn commit: r1485701 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java

Author: mreutegg
Date: Thu May 23 13:35:58 2013
New Revision: 1485701

URL: http://svn.apache.org/r1485701
Log:
OAK-841: Indexing empty string fails with "there's already a child node with name ':index'"
- Test case (currently ignored)

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java   (with props)

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java?rev=1485701&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java Thu May 23 13:35:58 2013
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.property;
+
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
+import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getOrCreateOakIndex;
+
+/**
+ * Test for OAK-841
+ */
+public class EmptyPropertyTest extends AbstractQueryTest {
+
+    @Override
+    protected ContentRepository createRepository() {
+        return new Oak()
+                .with(new InitialContent())
+                .with(new RepositoryInitializer() {
+                    @Override
+                    public NodeState initialize(NodeState state) {
+                        NodeBuilder root = state.builder();
+                        createIndexDefinition(getOrCreateOakIndex(root), "prop",
+                                true, false, ImmutableList.of("prop"), null);
+                        return root.getNodeState();
+                    }
+                }).with(new OpenSecurityProvider())
+                .with(new PropertyIndexProvider())
+                .with(new PropertyIndexEditorProvider())
+                .createContentRepository();
+    }
+
+    @Ignore
+    @Test
+    public void emptyStringValue() throws CommitFailedException {
+        Tree t = root.getTree("/");
+        t.addChild("node-1").setProperty("prop", "value");
+        root.commit();
+
+        t = root.getTree("/");
+        t.addChild("node-2").setProperty("prop", "");
+        root.commit();
+    }
+}
+
+

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Re: svn commit: r1485701 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java

Posted by Alex Parvulescu <al...@gmail.com>.
The MultipleIndicesTest is a query test. The problem mentioned here is an
index related issue.

The init code is as simple as it could be, see attached patch on the jira
issue.
All you need to get an empty initial state is this:
  NodeState root = new InitialContent().initialize(EMPTY_NODE);

next you can add any index config you need, without having to go through
the entire repo bootstrap.

best,
akex





On Thu, May 23, 2013 at 4:27 PM, Marcel Reutegger <mr...@adobe.com>wrote:

> > It was easier for me to copy the initialization code from
> > MultipleIndicesTest. this also made the actual test method
> > very easy to read and understand.
>
> on second thought, this indicates the new test could go into
> MultipleIndicesTest and we avoid the cost of an additional
> repo setup.
>
> regards
>  marcel
>

RE: svn commit: r1485701 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java

Posted by Marcel Reutegger <mr...@adobe.com>.
> It was easier for me to copy the initialization code from
> MultipleIndicesTest. this also made the actual test method
> very easy to read and understand.

on second thought, this indicates the new test could go into
MultipleIndicesTest and we avoid the cost of an additional
repo setup.

regards
 marcel

RE: svn commit: r1485701 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi,

I looked at the PropertyIndexTest first, but the code to setup
the test wasn't straight forward to me. PropertyIndexTest
actually doesn't have a common setup method for its tests.
It was easier for me to copy the initialization code from
MultipleIndicesTest. this also made the actual test method
very easy to read and understand.

regards
 marcel

> -----Original Message-----
> From: Alex Parvulescu [mailto:alex.parvulescu@gmail.com]
> Sent: Donnerstag, 23. Mai 2013 16:15
> To: oak-dev@jackrabbit.apache.org
> Subject: Re: svn commit: r1485701 - /jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> 
> I'm wondering if we need to bootstrap the entire repo when there are
> enough
> elements for a simple test in the existing PropertyIndexTest
> 
> alex
> 
> 
> On Thu, May 23, 2013 at 3:35 PM, <mr...@apache.org> wrote:
> 
> > Author: mreutegg
> > Date: Thu May 23 13:35:58 2013
> > New Revision: 1485701
> >
> > URL: http://svn.apache.org/r1485701
> > Log:
> > OAK-841: Indexing empty string fails with "there's already a child node
> > with name ':index'"
> > - Test case (currently ignored)
> >
> > Added:
> >
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> >   (with props)
> >
> > Added:
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> > URL:
> > http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java?rev=1485701&view=auto
> >
> >
> ==========================================================
> ====================
> > ---
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> > (added)
> > +++
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> > Thu May 23 13:35:58 2013
> > @@ -0,0 +1,73 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
> or
> > implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +package org.apache.jackrabbit.oak.plugins.index.property;
> > +
> > +import org.apache.jackrabbit.oak.Oak;
> > +import org.apache.jackrabbit.oak.api.CommitFailedException;
> > +import org.apache.jackrabbit.oak.api.ContentRepository;
> > +import org.apache.jackrabbit.oak.api.Tree;
> > +import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
> > +import org.apache.jackrabbit.oak.query.AbstractQueryTest;
> > +import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
> > +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
> > +import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
> > +import org.apache.jackrabbit.oak.spi.state.NodeState;
> > +import org.junit.Ignore;
> > +import org.junit.Test;
> > +
> > +import com.google.common.collect.ImmutableList;
> > +
> > +import static
> > org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
> > +import static
> > org.apache.jackrabbit.oak.plugins.index.IndexUtils.getOrCreateOakIndex;
> > +
> > +/**
> > + * Test for OAK-841
> > + */
> > +public class EmptyPropertyTest extends AbstractQueryTest {
> > +
> > +    @Override
> > +    protected ContentRepository createRepository() {
> > +        return new Oak()
> > +                .with(new InitialContent())
> > +                .with(new RepositoryInitializer() {
> > +                    @Override
> > +                    public NodeState initialize(NodeState state) {
> > +                        NodeBuilder root = state.builder();
> > +                        createIndexDefinition(getOrCreateOakIndex(root),
> > "prop",
> > +                                true, false, ImmutableList.of("prop"),
> > null);
> > +                        return root.getNodeState();
> > +                    }
> > +                }).with(new OpenSecurityProvider())
> > +                .with(new PropertyIndexProvider())
> > +                .with(new PropertyIndexEditorProvider())
> > +                .createContentRepository();
> > +    }
> > +
> > +    @Ignore
> > +    @Test
> > +    public void emptyStringValue() throws CommitFailedException {
> > +        Tree t = root.getTree("/");
> > +        t.addChild("node-1").setProperty("prop", "value");
> > +        root.commit();
> > +
> > +        t = root.getTree("/");
> > +        t.addChild("node-2").setProperty("prop", "");
> > +        root.commit();
> > +    }
> > +}
> > +
> > +
> >
> > Propchange:
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> >
> > ------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> > Propchange:
> > jackrabbit/oak/trunk/oak-
> core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/Empt
> yPropertyTest.java
> >
> > ------------------------------------------------------------------------------
> >     svn:keywords = Author Date Id Revision Rev URL
> >
> >
> >

Re: svn commit: r1485701 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java

Posted by Alex Parvulescu <al...@gmail.com>.
I'm wondering if we need to bootstrap the entire repo when there are enough
elements for a simple test in the existing PropertyIndexTest

alex


On Thu, May 23, 2013 at 3:35 PM, <mr...@apache.org> wrote:

> Author: mreutegg
> Date: Thu May 23 13:35:58 2013
> New Revision: 1485701
>
> URL: http://svn.apache.org/r1485701
> Log:
> OAK-841: Indexing empty string fails with "there's already a child node
> with name ':index'"
> - Test case (currently ignored)
>
> Added:
>
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
>   (with props)
>
> Added:
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
> URL:
> http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java?rev=1485701&view=auto
>
> ==============================================================================
> ---
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
> (added)
> +++
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
> Thu May 23 13:35:58 2013
> @@ -0,0 +1,73 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.jackrabbit.oak.plugins.index.property;
> +
> +import org.apache.jackrabbit.oak.Oak;
> +import org.apache.jackrabbit.oak.api.CommitFailedException;
> +import org.apache.jackrabbit.oak.api.ContentRepository;
> +import org.apache.jackrabbit.oak.api.Tree;
> +import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
> +import org.apache.jackrabbit.oak.query.AbstractQueryTest;
> +import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
> +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
> +import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
> +import org.apache.jackrabbit.oak.spi.state.NodeState;
> +import org.junit.Ignore;
> +import org.junit.Test;
> +
> +import com.google.common.collect.ImmutableList;
> +
> +import static
> org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
> +import static
> org.apache.jackrabbit.oak.plugins.index.IndexUtils.getOrCreateOakIndex;
> +
> +/**
> + * Test for OAK-841
> + */
> +public class EmptyPropertyTest extends AbstractQueryTest {
> +
> +    @Override
> +    protected ContentRepository createRepository() {
> +        return new Oak()
> +                .with(new InitialContent())
> +                .with(new RepositoryInitializer() {
> +                    @Override
> +                    public NodeState initialize(NodeState state) {
> +                        NodeBuilder root = state.builder();
> +                        createIndexDefinition(getOrCreateOakIndex(root),
> "prop",
> +                                true, false, ImmutableList.of("prop"),
> null);
> +                        return root.getNodeState();
> +                    }
> +                }).with(new OpenSecurityProvider())
> +                .with(new PropertyIndexProvider())
> +                .with(new PropertyIndexEditorProvider())
> +                .createContentRepository();
> +    }
> +
> +    @Ignore
> +    @Test
> +    public void emptyStringValue() throws CommitFailedException {
> +        Tree t = root.getTree("/");
> +        t.addChild("node-1").setProperty("prop", "value");
> +        root.commit();
> +
> +        t = root.getTree("/");
> +        t.addChild("node-2").setProperty("prop", "");
> +        root.commit();
> +    }
> +}
> +
> +
>
> Propchange:
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
>
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange:
> jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/EmptyPropertyTest.java
>
> ------------------------------------------------------------------------------
>     svn:keywords = Author Date Id Revision Rev URL
>
>
>