/**
 * Copyright (c) 2002-2011 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j 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 org.neo4j.server.web;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.UniformInterfaceException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.Node;
import org.neo4j.kernel.AbstractGraphDatabase;
import org.neo4j.server.WrappingNeoServerBootstrapper;
import org.neo4j.server.configuration.Configurator;
import org.neo4j.server.configuration.EmbeddedServerConfigurator;
import org.neo4j.test.ImpermanentGraphDatabase;

public class ExecutionTimeLimitTest
{
// ------------------------------ FIELDS ------------------------------

    private WrappingNeoServerBootstrapper testBootstrapper;
    private AbstractGraphDatabase db;
    private long wait;

// -------------------------- OTHER METHODS --------------------------

    @Test(expected = UniformInterfaceException.class)
    public void expectLimitation()
    {
        wait = 1000;
        Client.create().resource( "http://localhost:7474/db/data/node/0" )
                .header( "accept", "application/json" )
                .get( String.class );
    }

    @Test(expected = UniformInterfaceException.class)
    public void expectLimitationByHeader()
    {
        wait = 200;
        Client.create().resource( "http://localhost:7474/db/data/node/0" )
                .header( "accept", "application/json" )
                .header( "max-execution-time", "100" )
                .get( String.class );
    }

    @Test
    public void expectNoLimitation()
    {
        wait = 200;
        Client.create().resource( "http://localhost:7474/db/data/node/0" )
                .header( "accept", "application/json" )
                .get( String.class );
    }

    @Before
    public void setUp() throws Exception
    {
        db = new ImpermanentGraphDatabase()
        {
            @Override
            public Node getNodeById( long id )
            {
                try
                {
                    Thread.sleep( wait );
                } catch ( InterruptedException e )
                {
                    throw new RuntimeException( e );
                }
                return super.getNodeById( id );
            }
        };

        EmbeddedServerConfigurator config = new EmbeddedServerConfigurator( db );
        config.configuration().setProperty( Configurator
                .WEBSERVER_LIMIT_EXECUTION_TIME_PROPERTY_KEY, 500 );
        testBootstrapper = new WrappingNeoServerBootstrapper( db, config );
        testBootstrapper.start();
    }

    @After
    public void tearDown()
    {
        testBootstrapper.stop();
        db.shutdown();
    }
}

@@ -1709,17 +1709,17 @@
  wait = 
-1
+2
 000;%0A   
@@ -1762,33 +1762,33 @@
 ://localhost:747
-4
+6
 /db/data/node/0%22
@@ -3122,33 +3122,110 @@
 igurator
-%0A                
+.WEBSERVER_PORT_PROPERTY_KEY, 7476 );%0A        config.configuration().setProperty( Configurator
 .WEBSERV
@@ -3266,9 +3266,10 @@
 EY, 
-5
+10
 00 )

use other test-port fixtest: longer-timeouts