reduce fragility of tests
Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
4147e3734e
commit
ec51926622
|
@ -19,6 +19,7 @@
|
||||||
package org.eclipse.jetty.http2.hpack;
|
package org.eclipse.jetty.http2.hpack;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.BadMessageException;
|
import org.eclipse.jetty.http.BadMessageException;
|
||||||
import org.eclipse.jetty.http.DateGenerator;
|
import org.eclipse.jetty.http.DateGenerator;
|
||||||
|
@ -42,7 +43,7 @@ public class HpackTest
|
||||||
{
|
{
|
||||||
final static HttpField ServerJetty = new PreEncodedHttpField(HttpHeader.SERVER,"jetty");
|
final static HttpField ServerJetty = new PreEncodedHttpField(HttpHeader.SERVER,"jetty");
|
||||||
final static HttpField XPowerJetty = new PreEncodedHttpField(HttpHeader.X_POWERED_BY,"jetty");
|
final static HttpField XPowerJetty = new PreEncodedHttpField(HttpHeader.X_POWERED_BY,"jetty");
|
||||||
final static HttpField Date = new PreEncodedHttpField(HttpHeader.DATE,DateGenerator.formatDate(System.currentTimeMillis()));
|
final static HttpField Date = new PreEncodedHttpField(HttpHeader.DATE,DateGenerator.formatDate(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeDecodeResponseTest()
|
public void encodeDecodeResponseTest()
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class SelectChannelEndPointTest
|
||||||
EndPoint _endp = getEndPoint();
|
EndPoint _endp = getEndPoint();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_last = System.currentTimeMillis();
|
_last = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
boolean progress = true;
|
boolean progress = true;
|
||||||
while (progress)
|
while (progress)
|
||||||
{
|
{
|
||||||
|
@ -293,7 +293,7 @@ public class SelectChannelEndPointTest
|
||||||
|
|
||||||
// wait for read timeout
|
// wait for read timeout
|
||||||
client.setSoTimeout(500);
|
client.setSoTimeout(500);
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.getInputStream().read();
|
client.getInputStream().read();
|
||||||
|
@ -301,7 +301,7 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
long duration = System.currentTimeMillis() - start;
|
long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
Assert.assertThat("timeout duration", duration, greaterThanOrEqualTo(400L));
|
Assert.assertThat("timeout duration", duration, greaterThanOrEqualTo(400L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for read timeout
|
// wait for read timeout
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.getInputStream().read();
|
client.getInputStream().read();
|
||||||
|
@ -359,7 +359,7 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
assertTrue(System.currentTimeMillis() - start >= 400);
|
assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start >= 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write then shutdown
|
// write then shutdown
|
||||||
|
@ -403,7 +403,7 @@ public class SelectChannelEndPointTest
|
||||||
_lastEndPoint.setIdleTimeout(10 * specifiedTimeout);
|
_lastEndPoint.setIdleTimeout(10 * specifiedTimeout);
|
||||||
Thread.sleep((11 * specifiedTimeout) / 10);
|
Thread.sleep((11 * specifiedTimeout) / 10);
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int b = clientInputStream.read();
|
int b = clientInputStream.read();
|
||||||
|
@ -411,7 +411,7 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
int elapsed = Long.valueOf(System.currentTimeMillis() - start).intValue();
|
int elapsed = Long.valueOf(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start).intValue();
|
||||||
Assert.assertThat("Expected timeout", elapsed, greaterThanOrEqualTo(3 * specifiedTimeout / 4));
|
Assert.assertThat("Expected timeout", elapsed, greaterThanOrEqualTo(3 * specifiedTimeout / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,9 +431,11 @@ public class SelectChannelEndPointTest
|
||||||
@Test
|
@Test
|
||||||
public void testIdle() throws Exception
|
public void testIdle() throws Exception
|
||||||
{
|
{
|
||||||
|
int idleTimeout = 1000;
|
||||||
|
|
||||||
Socket client = newClient();
|
Socket client = newClient();
|
||||||
|
|
||||||
client.setSoTimeout(3000);
|
client.setSoTimeout(idleTimeout*10);
|
||||||
|
|
||||||
SocketChannel server = _connector.accept();
|
SocketChannel server = _connector.accept();
|
||||||
server.configureBlocking(false);
|
server.configureBlocking(false);
|
||||||
|
@ -452,14 +454,13 @@ public class SelectChannelEndPointTest
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(_lastEndPointLatch.await(1, TimeUnit.SECONDS));
|
Assert.assertTrue(_lastEndPointLatch.await(1, TimeUnit.SECONDS));
|
||||||
int idleTimeout = 500;
|
|
||||||
_lastEndPoint.setIdleTimeout(idleTimeout);
|
_lastEndPoint.setIdleTimeout(idleTimeout);
|
||||||
|
|
||||||
// read until idle shutdown received
|
// read until idle shutdown received
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
int b = client.getInputStream().read();
|
int b = client.getInputStream().read();
|
||||||
assertEquals(-1, b);
|
assertEquals(-1, b);
|
||||||
long idle = System.currentTimeMillis() - start;
|
long idle = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
assertTrue(idle > idleTimeout / 2);
|
assertTrue(idle > idleTimeout / 2);
|
||||||
assertTrue(idle < idleTimeout * 2);
|
assertTrue(idle < idleTimeout * 2);
|
||||||
|
|
||||||
|
@ -509,10 +510,10 @@ public class SelectChannelEndPointTest
|
||||||
clientOutputStream.flush();
|
clientOutputStream.flush();
|
||||||
|
|
||||||
// read until idle shutdown received
|
// read until idle shutdown received
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
int b = clientInputStream.read();
|
int b = clientInputStream.read();
|
||||||
assertEquals('E', b);
|
assertEquals('E', b);
|
||||||
long idle = System.currentTimeMillis() - start;
|
long idle = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
assertTrue(idle > idleTimeout / 2);
|
assertTrue(idle > idleTimeout / 2);
|
||||||
assertTrue(idle < idleTimeout * 2);
|
assertTrue(idle < idleTimeout * 2);
|
||||||
|
|
||||||
|
@ -551,7 +552,7 @@ public class SelectChannelEndPointTest
|
||||||
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
|
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
|
||||||
final CountDownLatch latch = new CountDownLatch(writes);
|
final CountDownLatch latch = new CountDownLatch(writes);
|
||||||
final InputStream in = new BufferedInputStream(client.getInputStream());
|
final InputStream in = new BufferedInputStream(client.getInputStream());
|
||||||
final long start = System.currentTimeMillis();
|
final long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
out.write(bytes);
|
out.write(bytes);
|
||||||
out.write(count);
|
out.write(count);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
@ -586,7 +587,7 @@ public class SelectChannelEndPointTest
|
||||||
count = count * 10 + (b - '0');
|
count = count * 10 + (b - '0');
|
||||||
b = in.read();
|
b = in.read();
|
||||||
}
|
}
|
||||||
last = System.currentTimeMillis();
|
last = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
//if (latch.getCount()%1000==0)
|
//if (latch.getCount()%1000==0)
|
||||||
// System.out.println(writes-latch.getCount());
|
// System.out.println(writes-latch.getCount());
|
||||||
|
@ -597,7 +598,7 @@ public class SelectChannelEndPointTest
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
System.err.println("count=" + count);
|
System.err.println("count=" + count);
|
||||||
System.err.println("latch=" + latch.getCount());
|
System.err.println("latch=" + latch.getCount());
|
||||||
System.err.println("time=" + (now - start));
|
System.err.println("time=" + (now - start));
|
||||||
|
|
|
@ -120,8 +120,8 @@ public class ThreadMonitorTest
|
||||||
public void spin()
|
public void spin()
|
||||||
{
|
{
|
||||||
long result=-1;
|
long result=-1;
|
||||||
long end=System.currentTimeMillis()+DURATION+1000;
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime())+DURATION+1000;
|
||||||
while (!done && System.currentTimeMillis()<end)
|
while (!done && TimeUnit.NANOSECONDS.toMillis(System.nanoTime())<end)
|
||||||
{
|
{
|
||||||
for (int i=0;i<1000000000;i++)
|
for (int i=0;i<1000000000;i++)
|
||||||
result^=i;
|
result^=i;
|
||||||
|
|
|
@ -79,9 +79,9 @@ public class PropertyUserStoreTest
|
||||||
|
|
||||||
public void awaitCount(int expectedCount) throws InterruptedException
|
public void awaitCount(int expectedCount) throws InterruptedException
|
||||||
{
|
{
|
||||||
long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10);
|
long timeout = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) + TimeUnit.SECONDS.toMillis(10);
|
||||||
|
|
||||||
while (userCount.get() != expectedCount && (System.currentTimeMillis() < timeout))
|
while (userCount.get() != expectedCount && (TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) < timeout))
|
||||||
{
|
{
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,6 +302,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
|
||||||
public PreparedStatement getExpiredSessionsStatement (Connection connection, String canonicalContextPath, String vhost, long expiry)
|
public PreparedStatement getExpiredSessionsStatement (Connection connection, String canonicalContextPath, String vhost, long expiry)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
// TODO expiry should be a delay rather than an absolute time.
|
||||||
|
|
||||||
if (_dbAdaptor == null)
|
if (_dbAdaptor == null)
|
||||||
throw new IllegalStateException("No DB adaptor");
|
throw new IllegalStateException("No DB adaptor");
|
||||||
|
|
||||||
|
@ -324,6 +326,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
|
||||||
public PreparedStatement getMyExpiredSessionsStatement (Connection connection, SessionContext sessionContext, long expiry)
|
public PreparedStatement getMyExpiredSessionsStatement (Connection connection, SessionContext sessionContext, long expiry)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
// TODO expiry should be a delay rather than an absolute time.
|
||||||
|
|
||||||
if (_dbAdaptor == null)
|
if (_dbAdaptor == null)
|
||||||
throw new IllegalStateException("No DB adaptor");
|
throw new IllegalStateException("No DB adaptor");
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.AsyncEvent;
|
import javax.servlet.AsyncEvent;
|
||||||
|
@ -133,7 +134,7 @@ public class AsyncStressTest
|
||||||
int period = _random.nextInt(290)+10;
|
int period = _random.nextInt(290)+10;
|
||||||
String uri=__paths[p][0].replace("<PERIOD>",Integer.toString(period));
|
String uri=__paths[p][0].replace("<PERIOD>",Integer.toString(period));
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String request =
|
String request =
|
||||||
"GET "+uri+" HTTP/1.1\r\n"+
|
"GET "+uri+" HTTP/1.1\r\n"+
|
||||||
"Host: localhost\r\n"+
|
"Host: localhost\r\n"+
|
||||||
|
|
|
@ -101,14 +101,14 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
"\r\n").getBytes("utf-8"));
|
"\r\n").getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
IO.toString(is);
|
IO.toString(is);
|
||||||
|
|
||||||
Thread.sleep(sleepTime);
|
Thread.sleep(sleepTime);
|
||||||
Assert.assertEquals(-1, is.read());
|
Assert.assertEquals(-1, is.read());
|
||||||
|
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start > minimumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start > minimumTestRuntime);
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start < maximumTestRuntime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=60000)
|
@Test(timeout=60000)
|
||||||
|
@ -134,14 +134,14 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
os.write(contentB);
|
os.write(contentB);
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
IO.toString(is);
|
IO.toString(is);
|
||||||
|
|
||||||
Thread.sleep(sleepTime);
|
Thread.sleep(sleepTime);
|
||||||
Assert.assertEquals(-1, is.read());
|
Assert.assertEquals(-1, is.read());
|
||||||
|
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start > minimumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start > minimumTestRuntime);
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start < maximumTestRuntime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=60000)
|
@Test(timeout=60000)
|
||||||
|
@ -273,8 +273,8 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
// further writes will get broken pipe or similar
|
// further writes will get broken pipe or similar
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long end=System.currentTimeMillis()+MAX_IDLE_TIME+3000;
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime())+MAX_IDLE_TIME+3000;
|
||||||
while (System.currentTimeMillis()<end)
|
while (TimeUnit.NANOSECONDS.toMillis(System.nanoTime())<end)
|
||||||
{
|
{
|
||||||
os.write("THIS DATA SHOULD NOT BE PARSED!\n\n".getBytes("utf-8"));
|
os.write("THIS DATA SHOULD NOT BE PARSED!\n\n".getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
@ -395,7 +395,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
.getBytes("utf-8"));
|
.getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(250);
|
Thread.sleep(250);
|
||||||
|
@ -420,7 +420,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
long duration=System.currentTimeMillis() - start;
|
long duration=TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
Assert.assertThat(duration,Matchers.greaterThan(500L));
|
Assert.assertThat(duration,Matchers.greaterThan(500L));
|
||||||
|
|
||||||
// read the response
|
// read the response
|
||||||
|
@ -454,7 +454,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
.getBytes("utf-8"));
|
.getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
|
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
|
||||||
{
|
{
|
||||||
Thread.sleep(300);
|
Thread.sleep(300);
|
||||||
|
@ -478,7 +478,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
long duration=System.currentTimeMillis() - start;
|
long duration=TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
Assert.assertThat(duration,Matchers.greaterThan(500L));
|
Assert.assertThat(duration,Matchers.greaterThan(500L));
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -526,7 +526,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
if (i%1028==0)
|
if (i%1028==0)
|
||||||
{
|
{
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
// System.err.println("read "+System.currentTimeMillis());
|
// System.err.println("read "+TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||||
}
|
}
|
||||||
line=is.readLine();
|
line=is.readLine();
|
||||||
Assert.assertThat(line,Matchers.notNullValue());
|
Assert.assertThat(line,Matchers.notNullValue());
|
||||||
|
@ -562,7 +562,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
while(line.length()!=0)
|
while(line.length()!=0)
|
||||||
line=is.readLine();
|
line=is.readLine();
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class,AbstractConnection.class))
|
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class,AbstractConnection.class))
|
||||||
{
|
{
|
||||||
for (int i=0;i<(128*1024);i++)
|
for (int i=0;i<(128*1024);i++)
|
||||||
|
@ -570,7 +570,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
if (i%1028==0)
|
if (i%1028==0)
|
||||||
{
|
{
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
// System.err.println("read "+System.currentTimeMillis());
|
// System.err.println("read "+TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||||
}
|
}
|
||||||
line=is.readLine();
|
line=is.readLine();
|
||||||
if (line==null)
|
if (line==null)
|
||||||
|
@ -579,7 +579,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
}
|
}
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{}
|
{}
|
||||||
long end=System.currentTimeMillis();
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long duration = end-start;
|
long duration = end-start;
|
||||||
Assert.assertThat(duration,Matchers.lessThan(20L*128L));
|
Assert.assertThat(duration,Matchers.lessThan(20L*128L));
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
Thread.sleep(sleepTime);
|
Thread.sleep(sleepTime);
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String response = IO.toString(is);
|
String response = IO.toString(is);
|
||||||
|
@ -613,7 +613,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start < maximumTestRuntime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
Assert.assertFalse(client.isClosed());
|
Assert.assertFalse(client.isClosed());
|
||||||
|
|
||||||
Thread.sleep(sleepTime);
|
Thread.sleep(sleepTime);
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String response = IO.toString(is);
|
String response = IO.toString(is);
|
||||||
|
@ -642,7 +642,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
Assert.assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start < maximumTestRuntime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
"\r\n").getBytes("utf-8"));
|
"\r\n").getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String response = IO.toString(is);
|
String response = IO.toString(is);
|
||||||
|
@ -681,7 +681,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
int duration = (int)(System.currentTimeMillis() - start);
|
int duration = (int)(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start);
|
||||||
Assert.assertThat(duration,Matchers.greaterThanOrEqualTo(MAX_IDLE_TIME));
|
Assert.assertThat(duration,Matchers.greaterThanOrEqualTo(MAX_IDLE_TIME));
|
||||||
Assert.assertThat(duration,Matchers.lessThan(maximumTestRuntime));
|
Assert.assertThat(duration,Matchers.lessThan(maximumTestRuntime));
|
||||||
}
|
}
|
||||||
|
@ -707,7 +707,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
"1234567890").getBytes("utf-8"));
|
"1234567890").getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String response = IO.toString(is);
|
String response = IO.toString(is);
|
||||||
|
@ -722,7 +722,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
int duration = (int)(System.currentTimeMillis() - start);
|
int duration = (int)(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start);
|
||||||
Assert.assertThat(duration+100,Matchers.greaterThanOrEqualTo(MAX_IDLE_TIME));
|
Assert.assertThat(duration+100,Matchers.greaterThanOrEqualTo(MAX_IDLE_TIME));
|
||||||
Assert.assertThat(duration-100,Matchers.lessThan(maximumTestRuntime));
|
Assert.assertThat(duration-100,Matchers.lessThan(maximumTestRuntime));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.nio.channels.SelectableChannel;
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -90,7 +91,7 @@ public class ExtendedServerTest extends HttpServerTestBase
|
||||||
@Override
|
@Override
|
||||||
public Runnable onSelected()
|
public Runnable onSelected()
|
||||||
{
|
{
|
||||||
_lastSelected=System.currentTimeMillis();
|
_lastSelected=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
return super.onSelected();
|
return super.onSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,11 +132,11 @@ public class ExtendedServerTest extends HttpServerTestBase
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
os.write("GET / HTTP/1.0\r\n".getBytes(StandardCharsets.ISO_8859_1));
|
os.write("GET / HTTP/1.0\r\n".getBytes(StandardCharsets.ISO_8859_1));
|
||||||
os.flush();
|
os.flush();
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
long end=System.currentTimeMillis();
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
os.write("\r\n".getBytes(StandardCharsets.ISO_8859_1));
|
os.write("\r\n".getBytes(StandardCharsets.ISO_8859_1));
|
||||||
|
|
||||||
// Read the response.
|
// Read the response.
|
||||||
|
|
|
@ -722,9 +722,9 @@ public class HttpConnectionTest
|
||||||
"5;\r\n"+
|
"5;\r\n"+
|
||||||
"12345\r\n";
|
"12345\r\n";
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String response = connector.getResponse(requests, 2000, TimeUnit.MILLISECONDS);
|
String response = connector.getResponse(requests, 2000, TimeUnit.MILLISECONDS);
|
||||||
if ((System.currentTimeMillis()-start)>=2000)
|
if ((TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start)>=2000)
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
|
||||||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||||
|
|
|
@ -1561,13 +1561,13 @@ public class RequestTest
|
||||||
"\r\n"+
|
"\r\n"+
|
||||||
buf;
|
buf;
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String rawResponse = _connector.getResponse(request);
|
String rawResponse = _connector.getResponse(request);
|
||||||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||||
assertThat("Response.status", response.getStatus(), is(400));
|
assertThat("Response.status", response.getStatus(), is(400));
|
||||||
assertThat("Response body content", response.getContent(),containsString(BadMessageException.class.getName()));
|
assertThat("Response body content", response.getContent(),containsString(BadMessageException.class.getName()));
|
||||||
assertThat("Response body content", response.getContent(),containsString(IllegalStateException.class.getName()));
|
assertThat("Response body content", response.getContent(),containsString(IllegalStateException.class.getName()));
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
assertTrue((now-start)<5000);
|
assertTrue((now-start)<5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1605,13 +1605,13 @@ public class RequestTest
|
||||||
"\r\n"+
|
"\r\n"+
|
||||||
buf;
|
buf;
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String rawResponse = _connector.getResponse(request);
|
String rawResponse = _connector.getResponse(request);
|
||||||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||||
assertThat("Response.status", response.getStatus(), is(400));
|
assertThat("Response.status", response.getStatus(), is(400));
|
||||||
assertThat("Response body content", response.getContent(),containsString(BadMessageException.class.getName()));
|
assertThat("Response body content", response.getContent(),containsString(BadMessageException.class.getName()));
|
||||||
assertThat("Response body content", response.getContent(),containsString(IllegalStateException.class.getName()));
|
assertThat("Response body content", response.getContent(),containsString(IllegalStateException.class.getName()));
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
assertTrue((now-start)<5000);
|
assertTrue((now-start)<5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,9 +123,9 @@ public class ServerConnectorTimeoutTest extends ConnectorTimeoutTest
|
||||||
socket.setSoTimeout(10 * MAX_IDLE_TIME);
|
socket.setSoTimeout(10 * MAX_IDLE_TIME);
|
||||||
socket.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8));
|
socket.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8));
|
||||||
InputStream inputStream = socket.getInputStream();
|
InputStream inputStream = socket.getInputStream();
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String response = IO.toString(inputStream);
|
String response = IO.toString(inputStream);
|
||||||
long timeElapsed = System.currentTimeMillis() - start;
|
long timeElapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
Assert.assertTrue("Time elapsed should be at least MAX_IDLE_TIME",timeElapsed > MAX_IDLE_TIME);
|
Assert.assertTrue("Time elapsed should be at least MAX_IDLE_TIME",timeElapsed > MAX_IDLE_TIME);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.net.Socket;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -344,12 +345,12 @@ public class StressTest
|
||||||
{
|
{
|
||||||
if (persistent)
|
if (persistent)
|
||||||
{
|
{
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
Socket socket= new Socket("localhost", _connector.getLocalPort());
|
Socket socket= new Socket("localhost", _connector.getLocalPort());
|
||||||
socket.setSoTimeout(30000);
|
socket.setSoTimeout(30000);
|
||||||
socket.setSoLinger(false,0);
|
socket.setSoLinger(false,0);
|
||||||
|
|
||||||
long connected=System.currentTimeMillis();
|
long connected=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
for (int i=0;i<__tests.length;i++)
|
for (int i=0;i<__tests.length;i++)
|
||||||
{
|
{
|
||||||
|
@ -367,12 +368,12 @@ public class StressTest
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
long written=System.currentTimeMillis();
|
long written=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
String response = IO.toString(socket.getInputStream());
|
String response = IO.toString(socket.getInputStream());
|
||||||
socket.close();
|
socket.close();
|
||||||
|
|
||||||
long end=System.currentTimeMillis();
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
int bodies = count(response,"HTTP/1.1 200 OK");
|
int bodies = count(response,"HTTP/1.1 200 OK");
|
||||||
if (__tests.length!=bodies)
|
if (__tests.length!=bodies)
|
||||||
|
@ -406,7 +407,7 @@ public class StressTest
|
||||||
{
|
{
|
||||||
String uri=__tests[i]+"/"+name+"/"+i;
|
String uri=__tests[i]+"/"+name+"/"+i;
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String close="Connection: close\r\n";
|
String close="Connection: close\r\n";
|
||||||
String request =
|
String request =
|
||||||
"GET "+uri+" HTTP/1.1\r\n"+
|
"GET "+uri+" HTTP/1.1\r\n"+
|
||||||
|
@ -418,16 +419,16 @@ public class StressTest
|
||||||
socket.setSoTimeout(10000);
|
socket.setSoTimeout(10000);
|
||||||
socket.setSoLinger(false,0);
|
socket.setSoLinger(false,0);
|
||||||
|
|
||||||
_latencies[0].add(new Long(System.currentTimeMillis()-start));
|
_latencies[0].add(new Long(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start));
|
||||||
|
|
||||||
socket.getOutputStream().write(request.getBytes());
|
socket.getOutputStream().write(request.getBytes());
|
||||||
socket.getOutputStream().flush();
|
socket.getOutputStream().flush();
|
||||||
|
|
||||||
_latencies[1].add(new Long(System.currentTimeMillis()-start));
|
_latencies[1].add(new Long(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start));
|
||||||
|
|
||||||
String response = IO.toString(socket.getInputStream());
|
String response = IO.toString(socket.getInputStream());
|
||||||
socket.close();
|
socket.close();
|
||||||
long end=System.currentTimeMillis();
|
long end=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
String endOfResponse = "\r\n\r\n";
|
String endOfResponse = "\r\n\r\n";
|
||||||
assertTrue("response = '" + response + "'", response.contains(endOfResponse));
|
assertTrue("response = '" + response + "'", response.contains(endOfResponse));
|
||||||
|
@ -459,7 +460,7 @@ public class StressTest
|
||||||
@Override
|
@Override
|
||||||
public void handle(String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long start=Long.parseLong(baseRequest.getHeader("start"));
|
long start=Long.parseLong(baseRequest.getHeader("start"));
|
||||||
long received=baseRequest.getTimeStamp();
|
long received=baseRequest.getTimeStamp();
|
||||||
|
|
||||||
|
@ -474,7 +475,7 @@ public class StressTest
|
||||||
response.getOutputStream().print("DATA "+request.getPathInfo()+"\n\n");
|
response.getOutputStream().print("DATA "+request.getPathInfo()+"\n\n");
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
|
|
||||||
_latencies[4].add(new Long(System.currentTimeMillis()-start));
|
_latencies[4].add(new Long(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server.session;
|
package org.eclipse.jetty.server.session;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -189,7 +186,7 @@ public class FileSessionManagerTest
|
||||||
//not be removed by the startup process
|
//not be removed by the startup process
|
||||||
exp = System.currentTimeMillis() - 1000L;
|
exp = System.currentTimeMillis() - 1000L;
|
||||||
String name6 = Long.toString(exp)+"_foo_0.0.0.0_abcdefg";
|
String name6 = Long.toString(exp)+"_foo_0.0.0.0_abcdefg";
|
||||||
File f6 = new File(testDir, name5);
|
File f6 = new File(testDir, name6);
|
||||||
if (f6.exists())
|
if (f6.exists())
|
||||||
Assert.assertTrue(f6.delete());
|
Assert.assertTrue(f6.delete());
|
||||||
f6.createNewFile();
|
f6.createNewFile();
|
||||||
|
@ -237,7 +234,7 @@ public class FileSessionManagerTest
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
//create a file for session abc that expired 5sec ago
|
//create a file for session abc that expired 5sec ago
|
||||||
long exp = now -5000L;
|
long exp = now - 5000L;
|
||||||
String name1 = Long.toString(exp)+"__0.0.0.0_abc";
|
String name1 = Long.toString(exp)+"__0.0.0.0_abc";
|
||||||
File f1 = new File(testDir, name1);
|
File f1 = new File(testDir, name1);
|
||||||
if (f1.exists())
|
if (f1.exists())
|
||||||
|
@ -285,7 +282,7 @@ public class FileSessionManagerTest
|
||||||
|
|
||||||
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
|
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
|
||||||
FS.ensureEmpty(testDir);
|
FS.ensureEmpty(testDir);
|
||||||
String expectedFilename = (System.currentTimeMillis()+ 10000)+"__0.0.0.0_validFile123";
|
String expectedFilename = (System.currentTimeMillis() + 10000)+"__0.0.0.0_validFile123";
|
||||||
|
|
||||||
Assert.assertTrue(new File(testDir, expectedFilename).createNewFile());
|
Assert.assertTrue(new File(testDir, expectedFilename).createNewFile());
|
||||||
Assert.assertTrue("File should exist!", new File(testDir, expectedFilename).exists());
|
Assert.assertTrue("File should exist!", new File(testDir, expectedFilename).exists());
|
||||||
|
@ -299,7 +296,7 @@ public class FileSessionManagerTest
|
||||||
ds.setStoreDir(testDir);
|
ds.setStoreDir(testDir);
|
||||||
handler.start();
|
handler.start();
|
||||||
|
|
||||||
Session session = handler.getSession("validFile123");
|
handler.getSession("validFile123");
|
||||||
|
|
||||||
Assert.assertTrue("File shouldn't exist!", !new File(testDir,expectedFilename).exists());
|
Assert.assertTrue("File shouldn't exist!", !new File(testDir,expectedFilename).exists());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.junit.Test;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SessionCookieTest
|
* SessionCookieTest
|
||||||
*/
|
*/
|
||||||
|
@ -169,7 +171,7 @@ public class SessionCookieTest
|
||||||
mgr.setSessionCache(store);
|
mgr.setSessionCache(store);
|
||||||
mgr.setSessionIdManager(idMgr);
|
mgr.setSessionIdManager(idMgr);
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
Session session = new Session(null, new SessionData("123", "_foo", "0.0.0.0", now, now, now, 30));
|
Session session = new Session(null, new SessionData("123", "_foo", "0.0.0.0", now, now, now, 30));
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class SSLSelectChannelConnectorLoadTest
|
||||||
tasks[i] = threadPool.submit(workers[i]);
|
tasks[i] = threadPool.submit(workers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -135,7 +135,7 @@ public class SSLSelectChannelConnectorLoadTest
|
||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
//System.err.println();
|
//System.err.println();
|
||||||
//System.err.println("Elapsed time: " + TimeUnit.MILLISECONDS.toSeconds(end - start) + "s");
|
//System.err.println("Elapsed time: " + TimeUnit.MILLISECONDS.toSeconds(end - start) + "s");
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public class SSLSelectChannelConnectorLoadTest
|
||||||
tasks[i] = threadPool.submit(workers[i]);
|
tasks[i] = threadPool.submit(workers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -181,7 +181,7 @@ public class SSLSelectChannelConnectorLoadTest
|
||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
// System.err.println();
|
// System.err.println();
|
||||||
// System.err.println("Elapsed time: " + TimeUnit.MILLISECONDS.toSeconds(end - start) + "s");
|
// System.err.println("Elapsed time: " + TimeUnit.MILLISECONDS.toSeconds(end - start) + "s");
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,11 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
||||||
@Override
|
@Override
|
||||||
protected Socket newSocket(String host, int port) throws Exception
|
protected Socket newSocket(String host, int port) throws Exception
|
||||||
{
|
{
|
||||||
return __sslContext.getSocketFactory().createSocket(host,port);
|
Socket socket = __sslContext.getSocketFactory().createSocket(host,port);
|
||||||
|
socket.setSoTimeout(10000);
|
||||||
|
socket.setTcpNoDelay(true);
|
||||||
|
socket.setSoLinger(false,0);
|
||||||
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class GzipDefaultTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tester.start();
|
tester.start();
|
||||||
HttpTester.Response http = tester.assertIsResponseGzipCompressed("GET","file.txt",System.currentTimeMillis() - 4000);
|
HttpTester.Response http = tester.assertIsResponseGzipCompressed("GET","file.txt",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - 4000);
|
||||||
Assert.assertEquals("Accept-Encoding, User-Agent",http.get("Vary"));
|
Assert.assertEquals("Accept-Encoding, User-Agent",http.get("Vary"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -304,7 +304,7 @@ public class GzipDefaultTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tester.start();
|
tester.start();
|
||||||
HttpTester.Response http = tester.assertIsResponseGzipCompressed("GET","test.svg",System.currentTimeMillis() - 4000);
|
HttpTester.Response http = tester.assertIsResponseGzipCompressed("GET","test.svg",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - 4000);
|
||||||
Assert.assertEquals("Accept-Encoding, User-Agent",http.get("Vary"));
|
Assert.assertEquals("Accept-Encoding, User-Agent",http.get("Vary"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.HttpConfiguration;
|
import org.eclipse.jetty.server.HttpConfiguration;
|
||||||
import org.eclipse.jetty.server.LocalConnector;
|
import org.eclipse.jetty.server.LocalConnector;
|
||||||
|
@ -108,9 +109,9 @@ public class DataRateLimitedServletTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
String response = connector.getResponse("GET /context/stream/content.txt HTTP/1.0\r\n\r\n");
|
String response = connector.getResponse("GET /context/stream/content.txt HTTP/1.0\r\n\r\n");
|
||||||
long duration=System.currentTimeMillis()-start;
|
long duration=TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start;
|
||||||
|
|
||||||
assertThat("Response",response,containsString("200 OK"));
|
assertThat("Response",response,containsString("200 OK"));
|
||||||
assertThat("Response Length",response.length(),greaterThan(1024*1024));
|
assertThat("Response Length",response.length(),greaterThan(1024*1024));
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertThat;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.FilterConfig;
|
import javax.servlet.FilterConfig;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
@ -170,7 +171,7 @@ public class DoSFilterTest extends AbstractDoSFilterTest
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
Thread.sleep(sleep);
|
Thread.sleep(sleep);
|
||||||
if (rateTracker.isRateExceeded(System.currentTimeMillis()))
|
if (rateTracker.isRateExceeded(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())))
|
||||||
exceeded = true;
|
exceeded = true;
|
||||||
}
|
}
|
||||||
return exceeded;
|
return exceeded;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class JSONPojoConvertorFactoryTest
|
||||||
jsonIn.addConvertor(Enum.class, new JSONEnumConvertor());
|
jsonIn.addConvertor(Enum.class, new JSONEnumConvertor());
|
||||||
|
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = new Integer(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001l;
|
||||||
|
@ -89,7 +90,7 @@ public class JSONPojoConvertorFactoryTest
|
||||||
jsonIn.addConvertor(Enum.class, new JSONEnumConvertor());
|
jsonIn.addConvertor(Enum.class, new JSONEnumConvertor());
|
||||||
|
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = new Integer(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001l;
|
||||||
|
|
|
@ -23,6 +23,8 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ public class JSONPojoConvertorTest
|
||||||
// json.addConvertor(Enum.class, new JSONEnumConvertor(true));
|
// json.addConvertor(Enum.class, new JSONEnumConvertor(true));
|
||||||
|
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = new Integer(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001l;
|
||||||
|
@ -89,7 +91,7 @@ public class JSONPojoConvertorTest
|
||||||
new String[]{"boolean2"}));
|
new String[]{"boolean2"}));
|
||||||
|
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = new Integer(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001l;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class DateCacheTest
|
||||||
|
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long end=now+3000;
|
long end=now+3000;
|
||||||
String f=dc.formatNow(now);
|
String f=dc.formatNow(now);
|
||||||
String last=f;
|
String last=f;
|
||||||
|
@ -67,7 +67,7 @@ public class DateCacheTest
|
||||||
misses++;
|
misses++;
|
||||||
|
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
now=System.currentTimeMillis();
|
now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
}
|
}
|
||||||
Assert.assertThat(hits,Matchers.greaterThan(misses));
|
Assert.assertThat(hits,Matchers.greaterThan(misses));
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class FutureCallbackTest
|
||||||
{
|
{
|
||||||
FutureCallback fcb= new FutureCallback();
|
FutureCallback fcb= new FutureCallback();
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get(500,TimeUnit.MILLISECONDS);
|
fcb.get(500,TimeUnit.MILLISECONDS);
|
||||||
|
@ -52,7 +52,7 @@ public class FutureCallbackTest
|
||||||
catch(TimeoutException e)
|
catch(TimeoutException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(50L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(50L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,9 +63,9 @@ public class FutureCallbackTest
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertFalse(fcb.isCancelled());
|
Assert.assertFalse(fcb.isCancelled());
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
Assert.assertEquals(null,fcb.get());
|
Assert.assertEquals(null,fcb.get());
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(500L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(500L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -84,10 +84,10 @@ public class FutureCallbackTest
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
Assert.assertEquals(null,fcb.get(10000,TimeUnit.MILLISECONDS));
|
Assert.assertEquals(null,fcb.get(10000,TimeUnit.MILLISECONDS));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(1000L));
|
||||||
|
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertFalse(fcb.isCancelled());
|
Assert.assertFalse(fcb.isCancelled());
|
||||||
|
@ -104,7 +104,7 @@ public class FutureCallbackTest
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertFalse(fcb.isCancelled());
|
Assert.assertFalse(fcb.isCancelled());
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get();
|
fcb.get();
|
||||||
|
@ -114,7 +114,7 @@ public class FutureCallbackTest
|
||||||
{
|
{
|
||||||
Assert.assertEquals(ex,ee.getCause());
|
Assert.assertEquals(ex,ee.getCause());
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(100L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(100L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,7 +134,7 @@ public class FutureCallbackTest
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get(10000,TimeUnit.MILLISECONDS);
|
fcb.get(10000,TimeUnit.MILLISECONDS);
|
||||||
|
@ -144,8 +144,8 @@ public class FutureCallbackTest
|
||||||
{
|
{
|
||||||
Assert.assertEquals(ex,ee.getCause());
|
Assert.assertEquals(ex,ee.getCause());
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(5000L));
|
||||||
|
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertFalse(fcb.isCancelled());
|
Assert.assertFalse(fcb.isCancelled());
|
||||||
|
@ -161,7 +161,7 @@ public class FutureCallbackTest
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertTrue(fcb.isCancelled());
|
Assert.assertTrue(fcb.isCancelled());
|
||||||
|
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get();
|
fcb.get();
|
||||||
|
@ -171,7 +171,7 @@ public class FutureCallbackTest
|
||||||
{
|
{
|
||||||
Assert.assertThat(e.getCause(),Matchers.instanceOf(CancellationException.class));
|
Assert.assertThat(e.getCause(),Matchers.instanceOf(CancellationException.class));
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(100L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(100L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -190,7 +190,7 @@ public class FutureCallbackTest
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fcb.get(10000,TimeUnit.MILLISECONDS);
|
fcb.get(10000,TimeUnit.MILLISECONDS);
|
||||||
|
@ -200,8 +200,8 @@ public class FutureCallbackTest
|
||||||
{
|
{
|
||||||
Assert.assertThat(e.getCause(),Matchers.instanceOf(CancellationException.class));
|
Assert.assertThat(e.getCause(),Matchers.instanceOf(CancellationException.class));
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(1000L));
|
||||||
|
|
||||||
Assert.assertTrue(fcb.isDone());
|
Assert.assertTrue(fcb.isDone());
|
||||||
Assert.assertTrue(fcb.isCancelled());
|
Assert.assertTrue(fcb.isCancelled());
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.MultipartConfigElement;
|
import javax.servlet.MultipartConfigElement;
|
||||||
import javax.servlet.ReadListener;
|
import javax.servlet.ReadListener;
|
||||||
|
@ -57,7 +58,7 @@ public class MultiPartInputStreamTest
|
||||||
private static final String FILENAME = "stuff.txt";
|
private static final String FILENAME = "stuff.txt";
|
||||||
protected String _contentType = "multipart/form-data, boundary=AaB03x";
|
protected String _contentType = "multipart/form-data, boundary=AaB03x";
|
||||||
protected String _multi = createMultipartRequestString(FILENAME);
|
protected String _multi = createMultipartRequestString(FILENAME);
|
||||||
protected String _dirname = System.getProperty("java.io.tmpdir")+File.separator+"myfiles-"+System.currentTimeMillis();
|
protected String _dirname = System.getProperty("java.io.tmpdir")+File.separator+"myfiles-"+TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
protected File _tmpDir = new File(_dirname);
|
protected File _tmpDir = new File(_dirname);
|
||||||
|
|
||||||
public MultiPartInputStreamTest ()
|
public MultiPartInputStreamTest ()
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.OutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||||
import org.eclipse.jetty.toolchain.test.FS;
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
@ -239,7 +240,7 @@ public class ScannerTest
|
||||||
|
|
||||||
|
|
||||||
// Create a new file by writing to it.
|
// Create a new file by writing to it.
|
||||||
long now = System.currentTimeMillis();
|
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
File file = new File(_directory,"st");
|
File file = new File(_directory,"st");
|
||||||
try (OutputStream out = new FileOutputStream(file,true))
|
try (OutputStream out = new FileOutputStream(file,true))
|
||||||
{
|
{
|
||||||
|
@ -300,7 +301,7 @@ public class ScannerTest
|
||||||
{
|
{
|
||||||
File file = new File(_directory,string);
|
File file = new File(_directory,string);
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
file.setLastModified(System.currentTimeMillis());
|
file.setLastModified(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||||
else
|
else
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class SharedBlockingCallbackTest
|
||||||
try (Blocker blocker=sbcb.acquire())
|
try (Blocker blocker=sbcb.acquire())
|
||||||
{
|
{
|
||||||
blocker.succeeded();
|
blocker.succeeded();
|
||||||
start=System.currentTimeMillis();
|
start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
blocker.block();
|
blocker.block();
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(500L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(500L));
|
||||||
Assert.assertEquals(0,notComplete.get());
|
Assert.assertEquals(0,notComplete.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,11 +94,11 @@ public class SharedBlockingCallbackTest
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
start=System.currentTimeMillis();
|
start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
blocker.block();
|
blocker.block();
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(1000L));
|
||||||
Assert.assertEquals(0,notComplete.get());
|
Assert.assertEquals(0,notComplete.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ public class SharedBlockingCallbackTest
|
||||||
}
|
}
|
||||||
catch(IOException ee)
|
catch(IOException ee)
|
||||||
{
|
{
|
||||||
start=System.currentTimeMillis();
|
start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
Assert.assertEquals(ex,ee.getCause());
|
Assert.assertEquals(ex,ee.getCause());
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(100L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(100L));
|
||||||
Assert.assertEquals(0,notComplete.get());
|
Assert.assertEquals(0,notComplete.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class SharedBlockingCallbackTest
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
start=System.currentTimeMillis();
|
start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
blocker.block();
|
blocker.block();
|
||||||
}
|
}
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
@ -158,8 +158,8 @@ public class SharedBlockingCallbackTest
|
||||||
{
|
{
|
||||||
Assert.assertEquals(ex,ee.getCause());
|
Assert.assertEquals(ex,ee.getCause());
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(1000L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(1000L));
|
||||||
Assert.assertEquals(0,notComplete.get());
|
Assert.assertEquals(0,notComplete.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,16 +193,16 @@ public class SharedBlockingCallbackTest
|
||||||
|
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start=System.currentTimeMillis();
|
long start=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try (Blocker blocker=sbcb.acquire())
|
try (Blocker blocker=sbcb.acquire())
|
||||||
{
|
{
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.greaterThan(10L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.greaterThan(10L));
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(500L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(500L));
|
||||||
|
|
||||||
blocker.succeeded();
|
blocker.succeeded();
|
||||||
blocker.block();
|
blocker.block();
|
||||||
}
|
}
|
||||||
Assert.assertThat(System.currentTimeMillis()-start,Matchers.lessThan(600L));
|
Assert.assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())-start,Matchers.lessThan(600L));
|
||||||
Assert.assertEquals(0,notComplete.get());
|
Assert.assertEquals(0,notComplete.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -175,31 +176,31 @@ public class StringUtilTest
|
||||||
Utf8StringBuffer strbuf = new Utf8StringBuffer(bytes.length);
|
Utf8StringBuffer strbuf = new Utf8StringBuffer(bytes.length);
|
||||||
for (int i=0;i<10;i++)
|
for (int i=0;i<10;i++)
|
||||||
{
|
{
|
||||||
long s1=System.currentTimeMillis();
|
long s1=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
for (int j=1000000; j-->0;)
|
for (int j=1000000; j-->0;)
|
||||||
{
|
{
|
||||||
calc+=new String(bytes,0,bytes.length,StandardCharsets.UTF_8).hashCode();
|
calc+=new String(bytes,0,bytes.length,StandardCharsets.UTF_8).hashCode();
|
||||||
}
|
}
|
||||||
long s2=System.currentTimeMillis();
|
long s2=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
for (int j=1000000; j-->0;)
|
for (int j=1000000; j-->0;)
|
||||||
{
|
{
|
||||||
calc+=StringUtil.toUTF8String(bytes,0,bytes.length).hashCode();
|
calc+=StringUtil.toUTF8String(bytes,0,bytes.length).hashCode();
|
||||||
}
|
}
|
||||||
long s3=System.currentTimeMillis();
|
long s3=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
for (int j=1000000; j-->0;)
|
for (int j=1000000; j-->0;)
|
||||||
{
|
{
|
||||||
Utf8StringBuffer buffer = new Utf8StringBuffer(bytes.length);
|
Utf8StringBuffer buffer = new Utf8StringBuffer(bytes.length);
|
||||||
buffer.append(bytes,0,bytes.length);
|
buffer.append(bytes,0,bytes.length);
|
||||||
calc+=buffer.toString().hashCode();
|
calc+=buffer.toString().hashCode();
|
||||||
}
|
}
|
||||||
long s4=System.currentTimeMillis();
|
long s4=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
for (int j=1000000; j-->0;)
|
for (int j=1000000; j-->0;)
|
||||||
{
|
{
|
||||||
strbuf.reset();
|
strbuf.reset();
|
||||||
strbuf.append(bytes,0,bytes.length);
|
strbuf.append(bytes,0,bytes.length);
|
||||||
calc+=strbuf.toString().hashCode();
|
calc+=strbuf.toString().hashCode();
|
||||||
}
|
}
|
||||||
long s5=System.currentTimeMillis();
|
long s5=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
System.err.println((s2-s1)+", "+(s3-s2)+", "+(s4-s3)+", "+(s5-s4));
|
System.err.println((s2-s1)+", "+(s3-s2)+", "+(s4-s3)+", "+(s5-s4));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -187,13 +189,13 @@ public class LifeCycleListenerTest
|
||||||
public void lifeCycleStarted(LifeCycle event)
|
public void lifeCycleStarted(LifeCycle event)
|
||||||
{
|
{
|
||||||
started = true;
|
started = true;
|
||||||
startedTime = System.currentTimeMillis();
|
startedTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lifeCycleStarting(LifeCycle event)
|
public void lifeCycleStarting(LifeCycle event)
|
||||||
{
|
{
|
||||||
starting = true;
|
starting = true;
|
||||||
startingTime = System.currentTimeMillis();
|
startingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
// need to sleep to make sure the starting and started times are not
|
// need to sleep to make sure the starting and started times are not
|
||||||
// the same
|
// the same
|
||||||
|
@ -210,13 +212,13 @@ public class LifeCycleListenerTest
|
||||||
public void lifeCycleStopped(LifeCycle event)
|
public void lifeCycleStopped(LifeCycle event)
|
||||||
{
|
{
|
||||||
stopped = true;
|
stopped = true;
|
||||||
stoppedTime = System.currentTimeMillis();
|
stoppedTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lifeCycleStopping(LifeCycle event)
|
public void lifeCycleStopping(LifeCycle event)
|
||||||
{
|
{
|
||||||
stopping = true;
|
stopping = true;
|
||||||
stoppingTime = System.currentTimeMillis();
|
stoppingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
|
|
||||||
// need to sleep to make sure the stopping and stopped times are not
|
// need to sleep to make sure the stopping and stopped times are not
|
||||||
// the same
|
// the same
|
||||||
|
|
|
@ -220,9 +220,9 @@ public class QueuedThreadPoolTest
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
long beforeStop = System.currentTimeMillis();
|
long beforeStop = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
tp.stop();
|
tp.stop();
|
||||||
long afterStop = System.currentTimeMillis();
|
long afterStop = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
assertTrue(tp.isStopped());
|
assertTrue(tp.isStopped());
|
||||||
assertTrue(afterStop - beforeStop < 1000);
|
assertTrue(afterStop - beforeStop < 1000);
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public class QueuedThreadPoolTest
|
||||||
|
|
||||||
private void waitForIdle(QueuedThreadPool tp, int idle)
|
private void waitForIdle(QueuedThreadPool tp, int idle)
|
||||||
{
|
{
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long start=now;
|
long start=now;
|
||||||
while (tp.getIdleThreads()!=idle && (now-start)<10000)
|
while (tp.getIdleThreads()!=idle && (now-start)<10000)
|
||||||
{
|
{
|
||||||
|
@ -240,14 +240,14 @@ public class QueuedThreadPoolTest
|
||||||
}
|
}
|
||||||
catch(InterruptedException e)
|
catch(InterruptedException e)
|
||||||
{}
|
{}
|
||||||
now=System.currentTimeMillis();
|
now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
}
|
}
|
||||||
Assert.assertEquals(idle, tp.getIdleThreads());
|
Assert.assertEquals(idle, tp.getIdleThreads());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForThreads(QueuedThreadPool tp, int threads)
|
private void waitForThreads(QueuedThreadPool tp, int threads)
|
||||||
{
|
{
|
||||||
long now=System.currentTimeMillis();
|
long now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long start=now;
|
long start=now;
|
||||||
while (tp.getThreads()!=threads && (now-start)<10000)
|
while (tp.getThreads()!=threads && (now-start)<10000)
|
||||||
{
|
{
|
||||||
|
@ -257,7 +257,7 @@ public class QueuedThreadPoolTest
|
||||||
}
|
}
|
||||||
catch(InterruptedException e)
|
catch(InterruptedException e)
|
||||||
{}
|
{}
|
||||||
now=System.currentTimeMillis();
|
now=TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
}
|
}
|
||||||
assertEquals(threads,tp.getThreads());
|
assertEquals(threads,tp.getThreads());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -58,6 +59,7 @@ public class ReservedThreadExecutorTest
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
|
System.gc();
|
||||||
_executor = new TestExecutor();
|
_executor = new TestExecutor();
|
||||||
_reservedExecutor = new ReservedThreadExecutor(_executor, SIZE);
|
_reservedExecutor = new ReservedThreadExecutor(_executor, SIZE);
|
||||||
_reservedExecutor.start();
|
_reservedExecutor.start();
|
||||||
|
@ -152,46 +154,30 @@ public class ReservedThreadExecutorTest
|
||||||
_reservedExecutor.setIdleTimeout(IDLE,TimeUnit.MILLISECONDS);
|
_reservedExecutor.setIdleTimeout(IDLE,TimeUnit.MILLISECONDS);
|
||||||
_reservedExecutor.start();
|
_reservedExecutor.start();
|
||||||
|
|
||||||
// Reserved threads are lazily started.
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_executor._queue.size(), is(0));
|
_reservedExecutor.tryExecute(NOOP);
|
||||||
|
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(false));
|
|
||||||
_executor.execute();
|
_executor.execute();
|
||||||
waitForNoPending();
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
|
_reservedExecutor.tryExecute(NOOP);
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
Runnable waitForLatch = ()->{try {latch.await();} catch(Exception e){}};
|
|
||||||
assertThat(_reservedExecutor.tryExecute(waitForLatch),is(true));
|
|
||||||
_executor.execute();
|
_executor.execute();
|
||||||
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(false));
|
_reservedExecutor.tryExecute(NOOP);
|
||||||
_executor.execute();
|
_executor.execute();
|
||||||
waitForNoPending();
|
|
||||||
|
|
||||||
latch.countDown();
|
|
||||||
waitForAvailable(2);
|
|
||||||
|
|
||||||
// Check that regular moderate activity keeps the pool a moderate size
|
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(true));
|
_reservedExecutor.tryExecute(NOOP);
|
||||||
waitForAvailable(2);
|
_executor.execute();
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(true));
|
_reservedExecutor.tryExecute(NOOP);
|
||||||
|
_executor.execute();
|
||||||
|
|
||||||
waitForAvailable(1);
|
waitForAvailable(1);
|
||||||
|
int available = _reservedExecutor.getAvailable();
|
||||||
|
|
||||||
|
assertThat(available,Matchers.greaterThan(0));
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(true));
|
|
||||||
waitForAvailable(1);
|
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(true));
|
|
||||||
waitForAvailable(1);
|
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
TimeUnit.MILLISECONDS.sleep(IDLE/2);
|
||||||
assertThat(_reservedExecutor.tryExecute(NOOP),is(true));
|
assertThat(_reservedExecutor.getAvailable(),Matchers.lessThan(available));
|
||||||
waitForAvailable(1);
|
|
||||||
|
|
||||||
// check fully idle goes to zero
|
|
||||||
TimeUnit.MILLISECONDS.sleep(IDLE);
|
|
||||||
assertThat(_reservedExecutor.getAvailable(),is(0));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForNoPending() throws InterruptedException
|
protected void waitForNoPending() throws InterruptedException
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class SchedulerTest
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception
|
public void before() throws Exception
|
||||||
{
|
{
|
||||||
|
System.gc();
|
||||||
_scheduler.start();
|
_scheduler.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class DigestPostTest
|
||||||
int n=result.indexOf("nonce=");
|
int n=result.indexOf("nonce=");
|
||||||
String nonce=result.substring(n+7,result.indexOf('"',n+7));
|
String nonce=result.substring(n+7,result.indexOf('"',n+7));
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
byte[] b= md.digest(String.valueOf(System.currentTimeMillis()).getBytes(org.eclipse.jetty.util.StringUtil.__ISO_8859_1));
|
byte[] b= md.digest(String.valueOf(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())).getBytes(org.eclipse.jetty.util.StringUtil.__ISO_8859_1));
|
||||||
String cnonce=encode(b);
|
String cnonce=encode(b);
|
||||||
String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
|
String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
|
||||||
newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
|
newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
|
||||||
|
@ -244,7 +244,7 @@ public class DigestPostTest
|
||||||
int n=result.indexOf("nonce=");
|
int n=result.indexOf("nonce=");
|
||||||
String nonce=result.substring(n+7,result.indexOf('"',n+7));
|
String nonce=result.substring(n+7,result.indexOf('"',n+7));
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
byte[] b= md.digest(String.valueOf(System.currentTimeMillis()).getBytes(StringUtil.__ISO_8859_1));
|
byte[] b= md.digest(String.valueOf(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())).getBytes(StringUtil.__ISO_8859_1));
|
||||||
String cnonce=encode(b);
|
String cnonce=encode(b);
|
||||||
String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
|
String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
|
||||||
newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
|
newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class DataSourceLoginServiceTest
|
||||||
|
|
||||||
stopClient();
|
stopClient();
|
||||||
|
|
||||||
String newpwd = String.valueOf(System.currentTimeMillis());
|
String newpwd = String.valueOf(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||||
|
|
||||||
changePassword("jetty", newpwd);
|
changePassword("jetty", newpwd);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -35,7 +37,7 @@ public class ClusteredLastAccessTimeTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -39,7 +41,7 @@ public class ClusteredOrphanedSessionTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -38,7 +40,7 @@ public class ClusteredSessionMigrationTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -39,7 +41,7 @@ public class ClusteredSessionScavengingTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
|
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -39,7 +41,7 @@ public class ModifyMaxInactiveIntervalTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.junit.After;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NonClusteredSessionScavengingTest
|
* NonClusteredSessionScavengingTest
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +69,7 @@ public class NonClusteredSessionScavengingTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
|
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -37,7 +39,7 @@ public class SessionExpiryTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.hazelcast.session;
|
package org.eclipse.jetty.hazelcast.session;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
|
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -39,7 +41,7 @@ public class SessionInvalidateCreateScavengeTest
|
||||||
public SessionDataStoreFactory createSessionDataStoreFactory()
|
public SessionDataStoreFactory createSessionDataStoreFactory()
|
||||||
{
|
{
|
||||||
factory = new HazelcastSessionDataStoreFactory();
|
factory = new HazelcastSessionDataStoreFactory();
|
||||||
factory.setMapName( Long.toString( System.currentTimeMillis() ) );
|
factory.setMapName( Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) ) );
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredLastAccessTimeTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -32,7 +35,7 @@ public class ClientLastAccessTimeTest
|
||||||
extends AbstractClusteredLastAccessTimeTest
|
extends AbstractClusteredLastAccessTimeTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
|
import org.eclipse.jetty.server.session.AbstractModifyMaxInactiveIntervalTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -36,7 +39,7 @@ public class ClientModifyMaxInactiveIntervalTest
|
||||||
extends AbstractModifyMaxInactiveIntervalTest
|
extends AbstractModifyMaxInactiveIntervalTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.Before;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ClientNonClusteredSessionScavengingTest
|
public class ClientNonClusteredSessionScavengingTest
|
||||||
extends AbstractNonClusteredSessionScavengingTest
|
extends AbstractNonClusteredSessionScavengingTest
|
||||||
{
|
{
|
||||||
|
@ -60,7 +62,7 @@ public class ClientNonClusteredSessionScavengingTest
|
||||||
fail( e.getMessage() );
|
fail( e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredOrphanedSessionTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -33,7 +36,7 @@ public class ClientOrphanedSessionTest
|
||||||
extends AbstractClusteredOrphanedSessionTest
|
extends AbstractClusteredOrphanedSessionTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
|
import org.eclipse.jetty.server.session.AbstractSessionExpiryTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -33,7 +36,7 @@ public class ClientSessionExpiryTest
|
||||||
extends AbstractSessionExpiryTest
|
extends AbstractSessionExpiryTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
|
import org.eclipse.jetty.server.session.AbstractSessionInvalidateCreateScavengeTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -32,7 +35,7 @@ import org.junit.Before;
|
||||||
public class ClientSessionInvalidateCreateScavengeTest
|
public class ClientSessionInvalidateCreateScavengeTest
|
||||||
extends AbstractSessionInvalidateCreateScavengeTest
|
extends AbstractSessionInvalidateCreateScavengeTest
|
||||||
{
|
{
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredSessionMigrationTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -35,7 +38,7 @@ import org.junit.Before;
|
||||||
public class ClientSessionMigrationTest
|
public class ClientSessionMigrationTest
|
||||||
extends AbstractClusteredSessionMigrationTest
|
extends AbstractClusteredSessionMigrationTest
|
||||||
{
|
{
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.hazelcast.config.Config;
|
||||||
import com.hazelcast.config.MapConfig;
|
import com.hazelcast.config.MapConfig;
|
||||||
import com.hazelcast.core.Hazelcast;
|
import com.hazelcast.core.Hazelcast;
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
import com.hazelcast.core.HazelcastInstance;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
import org.eclipse.jetty.hazelcast.session.HazelcastSessionDataStoreFactory;
|
||||||
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
|
import org.eclipse.jetty.server.session.AbstractClusteredSessionScavengingTest;
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
|
@ -33,7 +36,7 @@ public class ClientSessionScavengingTest
|
||||||
extends AbstractClusteredSessionScavengingTest
|
extends AbstractClusteredSessionScavengingTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String MAP_NAME = Long.toString( System.currentTimeMillis() );
|
private static final String MAP_NAME = Long.toString( TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) );
|
||||||
|
|
||||||
private HazelcastInstance hazelcastInstance;
|
private HazelcastInstance hazelcastInstance;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
@ -145,7 +146,7 @@ public class AttributeNameTest
|
||||||
if ("init".equals(action))
|
if ("init".equals(action))
|
||||||
{
|
{
|
||||||
Session session = (Session)request.getSession(true);
|
Session session = (Session)request.getSession(true);
|
||||||
session.setAttribute("a.b.c",System.currentTimeMillis());
|
session.setAttribute("a.b.c",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
|
||||||
sendResult(session,httpServletResponse.getWriter());
|
sendResult(session,httpServletResponse.getWriter());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
@ -532,7 +533,7 @@ public class SaveOptimizeTest
|
||||||
{
|
{
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
assertNotNull(session);
|
assertNotNull(session);
|
||||||
session.setAttribute("ttt", new Long(System.currentTimeMillis()));
|
session.setAttribute("ttt", new Long(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())));
|
||||||
}
|
}
|
||||||
else if ("max".equalsIgnoreCase(action))
|
else if ("max".equalsIgnoreCase(action))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue