@@ -0,0 +1,2965 @@
+/*%0A *%0A *  *  Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)%0A *  *%0A *  *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  *  you may not use this file except in compliance with the License.%0A *  *  You may obtain a copy of the License at%0A *  *%0A *  *       http://www.apache.org/licenses/LICENSE-2.0%0A *  *%0A *  *  Unless required by applicable law or agreed to in writing, software%0A *  *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  *  See the License for the specific language governing permissions and%0A *  *  limitations under the License.%0A *  *%0A *  * For more information: http://www.orientechnologies.com%0A *  %0A */%0A%0Apackage com.orientechnologies.orient.server.distributed;%0A%0Aimport com.orientechnologies.orient.core.sql.OCommandSQL;%0Aimport com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;%0Aimport com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;%0Aimport com.tinkerpop.blueprints.impls.orient.OrientVertex;%0Aimport junit.framework.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.util.Iterator;%0A%0A/**%0A * Start 2 servers and execute query across the cluster%0A */%0Apublic class ServerClusterQueryTest extends AbstractServerClusterTest %7B%0A  final static int     SERVERS = 2;%0A  private OrientVertex v1;%0A  private OrientVertex v2;%0A%0A  public String getDatabaseName() %7B%0A    return %22distributed-queries%22;%0A  %7D%0A%0A  @Test%0A  public void test() throws Exception %7B%0A    init(SERVERS);%0A    prepare(false);%0A    execute();%0A  %7D%0A%0A  @Override%0A  protected void executeTest() throws Exception %7B%0A    createDatabase();%0A    checkNestedQueryContext();%0A  %7D%0A%0A  private void createDatabase() %7B%0A    OrientGraphFactory factory = new OrientGraphFactory(%22plocal:target/server0/databases/%22 + getDatabaseName());%0A    OrientGraphNoTx g = factory.getNoTx();%0A%0A    try %7B%0A      g.createVertexType(%22V1%22);%0A      g.createEdgeType(%22E1%22);%0A      v1 = g.addVertex(%22class:V1%22);%0A      v2 = g.addVertex(%22class:V2%22);%0A%0A      v1.addEdge(%22E1%22, v2);%0A    %7D finally %7B%0A      g.shutdown();%0A    %7D%0A  %7D%0A%0A  private void checkNestedQueryContext() %7B%0A    for (int s = 0; s %3C SERVERS; ++s) %7B%0A      OrientGraphFactory factory = new OrientGraphFactory(%22plocal:target/server%22 + s + %22/databases/%22 + getDatabaseName());%0A      OrientGraphNoTx g = factory.getNoTx();%0A%0A      try %7B%0A        final Iterable%3COrientVertex%3E result = g.command(new OCommandSQL(%22select *, $depth as d from (traverse in('E1') from ?)%22))%0A            .execute(v2.getIdentity());%0A%0A        final Iterator%3COrientVertex%3E it = result.iterator();%0A        Assert.assertTrue(it.hasNext());%0A%0A        final OrientVertex r1 = it.next();%0A        Assert.assertTrue(it.hasNext());%0A        final OrientVertex r2 = it.next();%0A        Assert.assertFalse(it.hasNext());%0A%0A        Assert.assertEquals(r1.getProperty(%22d%22), 0);%0A        Assert.assertEquals(r2.getProperty(%22d%22), 1);%0A%0A      %7D finally %7B%0A        g.shutdown();%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Test case for issue #4425