From do-not-reply at jboss.org Tue Feb 9 03:54:21 2010 Content-Type: multipart/mixed; boundary="===============4694117621783681693==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: exo-jcr-commits at lists.jboss.org Subject: [exo-jcr-commits] exo-jcr SVN: r1736 - jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional. Date: Tue, 09 Feb 2010 03:54:21 -0500 Message-ID: <201002090854.o198sLYb012511@svn01.web.mwc.hst.phx2.redhat.com> --===============4694117621783681693== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: skabashnyuk Date: 2010-02-09 03:54:21 -0500 (Tue, 09 Feb 2010) New Revision: 1736 Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/= jcr/cluster/functional/TestEditedParentSearch.java Log: EXOJCR-395 : add info Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/servi= ces/jcr/cluster/functional/TestEditedParentSearch.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services= /jcr/cluster/functional/TestEditedParentSearch.java = (rev 0) +++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services= /jcr/cluster/functional/TestEditedParentSearch.java 2010-02-09 08:54:21 UTC= (rev 1736) @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2010 eXo Platform SAS. + * + * This is free software; you can redistribute it and/or modify it + * 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. + * + * This software 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.exoplatform.services.jcr.cluster.functional; + +import org.exoplatform.services.jcr.JcrImplBaseTest; +import org.exoplatform.services.jcr.core.CredentialsImpl; +import org.exoplatform.services.jcr.impl.core.ItemImpl; +import org.exoplatform.services.jcr.impl.core.NodeImpl; +import org.exoplatform.services.jcr.impl.core.SessionImpl; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import javax.jcr.Node; +import javax.jcr.query.Query; +import javax.jcr.query.QueryResult; + +/** + * @author Sergey K= abashnyuk + * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks= m $ + * + */ +public class TestEditedParentSearch extends JcrImplBaseTest +{ + /** + * Maximum number of nodes. + */ + private static final int MAX_NODES_COUNT =3D 1000; + + private static final String TEST_ROOT =3D "TestEditedParentSearch"; + + private static final String PROP1_NAME =3D "p1"; + + private static final String PROP2_NAME =3D "p2"; + + private static final String PROP1_VALUE =3D "v1"; + + private static final String PROP2_VALUE =3D "v2"; + + private List paths; + + /** + * Test Eduted parent search. + * @throws Exception + */ + public void testEditedParentSearch() throws Exception + { + Node testRoot =3D root.addNode(TEST_ROOT); + session.save(); + paths =3D new ArrayList(); + + System.out.println("Initial (y/n) :"); + BufferedReader reader =3D new BufferedReader(new InputStreamReader(S= ystem.in)); + String line =3D reader.readLine(); + if (line.equals("y")) + { + + for (int i =3D 0; i < MAX_NODES_COUNT; i++) + { + Node nodel1 =3D testRoot.addNode("NODE_L1_" + i); + Node nodel2 =3D nodel1.addNode("Node_L2"); + nodel2.setProperty(PROP2_NAME, PROP2_VALUE); + session.save(); + paths.add(nodel2.getPath()); + } + } + else + { + for (int i =3D 0; i < MAX_NODES_COUNT; i++) + { + paths.add("/" + TEST_ROOT + "/" + "NODE_L1_" + i + "/" + "Node= _L2"); + } + + } + Thread searchAgent =3D new Thread(new SearchAgent()); + searchAgent.setName("searchAgent"); + Thread editAgent =3D new Thread(new EditAgent()); + editAgent.setName("editAgent"); + editAgent.start(); + searchAgent.start(); + + Thread.sleep(60 * 60 * 1000); + } + + private class EditAgent implements Runnable + { + + /** + * @see java.lang.Runnable#run() + */ + public void run() + { + + CredentialsImpl agentCredentials =3D new CredentialsImpl("admin",= "admin".toCharArray()); + Random random =3D new Random(); + + try + { + SessionImpl editSession =3D (SessionImpl)repository.login(agen= tCredentials, "ws"); + while (true) + { + + ItemImpl item =3D editSession.getItem(paths.get(random.next= Int(paths.size()))); + NodeImpl parentNode =3D item.getParent(); + parentNode.setProperty(PROP1_NAME, PROP1_VALUE); + editSession.save(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + private class SearchAgent implements Runnable + { + + /** + * @see java.lang.Runnable#run() + */ + public void run() + { + try + { + CredentialsImpl agentCredentials =3D new CredentialsImpl("admi= n", "admin".toCharArray()); + SessionImpl searchSession =3D (SessionImpl)repository.login(ag= entCredentials, "ws"); + while (true) + { + + Node testRoot =3D searchSession.getRootNode().getNode(TEST_= ROOT); + // prepare nodes + + Query q =3D + searchSession.getWorkspace().getQueryManager().createQue= ry( + "SELECT * FROM nt:base WHERE " + PROP2_NAME + "=3D'" = + PROP2_VALUE + "' AND jcr:path LIKE '" + + testRoot.getPath() + "/%'", Query.SQL); + long start =3D System.currentTimeMillis(); + QueryResult res =3D q.execute(); + long sqlsize =3D res.getNodes().getSize(); + log.info("size=3D" + sqlsize + " time=3D" + (System.current= TimeMillis() - start)); + } + + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + } + +} Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exo= platform/services/jcr/cluster/functional/TestEditedParentSearch.java ___________________________________________________________________ Name: svn:mime-type + text/plain --===============4694117621783681693==--