jetty-9 - Removed references to JUnit 3.x.
This commit is contained in:
parent
80e1e7b47b
commit
40382bad3a
|
@ -23,20 +23,22 @@ import java.net.URL;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.FragmentDescriptor;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* TestAnnotationConfiguration
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TestAnnotationConfiguration extends TestCase
|
||||
public class TestAnnotationConfiguration
|
||||
{
|
||||
public void testGetFragmentFromJar ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testGetFragmentFromJar() throws Exception
|
||||
{
|
||||
String dir = System.getProperty("basedir", ".");
|
||||
File file = new File(dir);
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
|||
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
|
@ -35,8 +34,15 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestSecurityAnnotationConversions extends TestCase
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class TestSecurityAnnotationConversions
|
||||
{
|
||||
@ServletSecurity(value=@HttpConstraint(value=EmptyRoleSemantic.DENY))
|
||||
public static class DenyServlet extends HttpServlet
|
||||
|
@ -65,8 +71,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
|||
{
|
||||
}
|
||||
|
||||
public void testDenyAllOnClass ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testDenyAllOnClass() throws Exception
|
||||
{
|
||||
|
||||
WebAppContext wac = makeWebAppContext(DenyServlet.class.getCanonicalName(), "denyServlet", new String[]{"/foo/*", "*.foo"});
|
||||
|
@ -97,9 +103,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
|||
compareResults(expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||
}
|
||||
|
||||
|
||||
public void testPermitAll()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testPermitAll() throws Exception
|
||||
{
|
||||
//Assume we found 1 servlet with a @ServletSecurity security annotation
|
||||
WebAppContext wac = makeWebAppContext(PermitServlet.class.getCanonicalName(), "permitServlet", new String[]{"/foo/*", "*.foo"});
|
||||
|
@ -129,8 +134,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
|||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||
}
|
||||
|
||||
public void testRolesAllowedWithTransportGuarantee ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testRolesAllowedWithTransportGuarantee() throws Exception
|
||||
{
|
||||
//Assume we found 1 servlet with annotation with roles defined and
|
||||
//and a TransportGuarantee
|
||||
|
@ -161,9 +166,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
|||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||
}
|
||||
|
||||
|
||||
public void testMethodAnnotation ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testMethodAnnotation() throws Exception
|
||||
{
|
||||
//ServletSecurity annotation with HttpConstraint of TransportGuarantee.CONFIDENTIAL, and a list of rolesAllowed, and
|
||||
//a HttpMethodConstraint for GET method that permits all and has TransportGuarantee.NONE (ie is default)
|
||||
|
@ -209,8 +213,8 @@ public class TestSecurityAnnotationConversions extends TestCase
|
|||
compareResults (expectedMappings, ((ConstraintAware)wac.getSecurityHandler()).getConstraintMappings());
|
||||
}
|
||||
|
||||
public void testMethodAnnotation2 ()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testMethodAnnotation2() throws Exception
|
||||
{
|
||||
//A ServletSecurity annotation that has HttpConstraint of CONFIDENTIAL with defined roles, but a
|
||||
//HttpMethodConstraint for GET that permits all, but also requires CONFIDENTIAL
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
package org.eclipse.jetty.ant;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class JettyRunTaskTest extends TestCase
|
||||
{
|
||||
public void testInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -20,8 +20,8 @@ package org.eclipse.jetty.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpCookieParserTest
|
||||
|
|
|
@ -18,10 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.deploy.graph;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class GraphTest
|
||||
{
|
||||
final Node nodeA = new Node("A");
|
||||
|
@ -37,7 +36,7 @@ public class GraphTest
|
|||
|
||||
Path path = new Path();
|
||||
|
||||
Assert.assertEquals(0,path.nodes());
|
||||
Assert.assertEquals(0, path.nodes());
|
||||
Assert.assertEquals(null,path.firstNode());
|
||||
Assert.assertEquals(null,path.lastNode());
|
||||
|
||||
|
|
|
@ -18,18 +18,21 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PathMapTest extends TestCase
|
||||
public class PathMapTest
|
||||
{
|
||||
@Test
|
||||
public void testPathMap() throws Exception
|
||||
{
|
||||
PathMap p = new PathMap();
|
||||
PathMap<String> p = new PathMap<>();
|
||||
|
||||
p.put("/abs/path", "1");
|
||||
p.put("/abs/path/longer", "2");
|
||||
|
|
|
@ -34,10 +34,10 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.nio.channels.SocketChannel;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -43,6 +42,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
|||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -232,7 +232,7 @@ public class SslConnectionTest
|
|||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||
byte[] buffer = new byte[1024];
|
||||
int len=client.getInputStream().read(buffer);
|
||||
Assert.assertEquals(10,len);
|
||||
Assert.assertEquals(10, len);
|
||||
Assert.assertEquals("HelloWorld",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||
|
||||
client.close();
|
||||
|
|
|
@ -45,12 +45,12 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -351,7 +351,7 @@ public class WriteFlusherTest
|
|||
public void testConcurrentAccessToWriteAndOnFail() throws Exception
|
||||
{
|
||||
// TODO review this test - It was changed for the boolean flush return, but not really well inspected
|
||||
|
||||
|
||||
final CountDownLatch failedCalledLatch = new CountDownLatch(1);
|
||||
final CountDownLatch writeCalledLatch = new CountDownLatch(1);
|
||||
final CountDownLatch writeCompleteLatch = new CountDownLatch(1);
|
||||
|
@ -377,13 +377,13 @@ public class WriteFlusherTest
|
|||
executor.submit(new Writer(writeFlusher, callback));
|
||||
assertThat("Write has been called.", writeCalledLatch.await(5, TimeUnit.SECONDS), is(true));
|
||||
executor.submit(new FailedCaller(writeFlusher, failedCalledLatch)).get();
|
||||
|
||||
|
||||
|
||||
|
||||
// callback failed is NOT called because in WRITING state failed() doesn't know about the callback. However
|
||||
// either the write succeeds or we get an IOException which will call callback.failed()
|
||||
assertThat("write complete", writeCompleteLatch.await(5, TimeUnit.SECONDS), is(true));
|
||||
|
||||
|
||||
|
||||
|
||||
// in this testcase we more or less emulate that the write has successfully finished and we return from
|
||||
// EndPoint.flush() back to WriteFlusher.write(). Then someone calls failed. So the callback should have been
|
||||
// completed.
|
||||
|
@ -570,7 +570,7 @@ public class WriteFlusherTest
|
|||
{
|
||||
byteBuffer.position(byteBuffer.limit());
|
||||
}
|
||||
|
||||
|
||||
for (ByteBuffer b: buffers)
|
||||
if (BufferUtil.hasContent(b))
|
||||
return false;
|
||||
|
|
|
@ -25,11 +25,11 @@ import javax.management.MBeanOperationInfo;
|
|||
import javax.management.MBeanParameterInfo;
|
||||
|
||||
import com.acme.Derived;
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.nio.channels.FileChannel;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.plugins.model.Plugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
|
@ -25,9 +25,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.util.security.Credential;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -18,23 +18,22 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class HttpURITest
|
||||
{
|
||||
private final String[][] partial_tests=
|
||||
|
|
|
@ -20,15 +20,13 @@ package org.eclipse.jetty.server.handler;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -37,14 +35,13 @@ import org.junit.Test;
|
|||
*
|
||||
* TODO: increase the testing going on here
|
||||
*/
|
||||
public class ResourceHandlerTest extends TestCase
|
||||
public class ResourceHandlerTest
|
||||
{
|
||||
private static Server _server;
|
||||
private static ServerConnector _connector;
|
||||
private static ContextHandler _contextHandler;
|
||||
private static ResourceHandler _resourceHandler;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
|
@ -60,7 +57,6 @@ public class ResourceHandlerTest extends TestCase
|
|||
_server.start();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@AfterClass
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
|
@ -78,5 +74,4 @@ public class ResourceHandlerTest extends TestCase
|
|||
|
||||
Assert.assertNotNull("missing jetty.css" , sr.getString("/resource/jetty-dir.css"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -38,9 +37,11 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
|||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SSLCloseTest extends TestCase
|
||||
public class SSLCloseTest
|
||||
{
|
||||
@Test
|
||||
public void testClose() throws Exception
|
||||
{
|
||||
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||
|
@ -54,7 +55,7 @@ public class SSLCloseTest extends TestCase
|
|||
connector.setPort(0);
|
||||
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
{connector});
|
||||
server.setHandler(new WriteHandler());
|
||||
|
||||
server.start();
|
||||
|
@ -85,7 +86,7 @@ public class SSLCloseTest extends TestCase
|
|||
|
||||
Thread.sleep(2000);
|
||||
|
||||
while ((line=in.readLine())!=null)
|
||||
while (in.readLine()!=null)
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
|
@ -38,6 +37,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class AsyncContextTest
|
|||
|
||||
BufferedReader br = parseHeader(responseString);
|
||||
|
||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath",br.readLine());
|
||||
Assert.assertEquals("servlet gets right path", "doGet:getServletPath:/servletPath", br.readLine());
|
||||
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath",br.readLine());
|
||||
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ public class AsyncContextTest
|
|||
@Override
|
||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
if (((Request)request).getDispatcherType() == DispatcherType.ASYNC)
|
||||
if (request.getDispatcherType() == DispatcherType.ASYNC)
|
||||
{
|
||||
response.getOutputStream().print("Dispatched back to ForwardingServlet");
|
||||
}
|
||||
|
@ -310,8 +310,6 @@ public class AsyncContextTest
|
|||
asyncContext.start(new AsyncRunnable(asyncContext));
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,7 +324,6 @@ public class AsyncContextTest
|
|||
AsyncContext asyncContext = request.startAsync(request, response);
|
||||
response.getOutputStream().print("doGet:async:getServletPath:" + ((HttpServletRequest)asyncContext.getRequest()).getServletPath() + "\n");
|
||||
asyncContext.start(new AsyncRunnable(asyncContext));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import javax.servlet.http.HttpServletRequestWrapper;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -51,6 +50,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
|
@ -35,6 +34,7 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -185,7 +185,7 @@ public class ServletContextHandlerTest
|
|||
err.append("\n").append(response);
|
||||
|
||||
System.err.println(err);
|
||||
throw new AssertionFailedError(err.toString());
|
||||
Assert.fail(err.toString());
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
|
@ -51,6 +50,7 @@ import org.eclipse.jetty.spdy.api.Stream;
|
|||
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ package org.eclipse.jetty.spdy.server;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
||||
import org.eclipse.jetty.spdy.api.Session;
|
||||
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SPDYClientFactoryTest extends AbstractTest
|
||||
|
|
|
@ -22,10 +22,10 @@ package org.eclipse.jetty.spdy.server;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
||||
import org.eclipse.jetty.spdy.api.Session;
|
||||
import org.eclipse.jetty.spdy.api.SessionFrameListener;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SPDYServerConnectorTest extends AbstractTest
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Assume;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SpringXmlConfigurationTest
|
||||
{
|
||||
|
|
|
@ -55,10 +55,6 @@ public class JSONTest
|
|||
"\"undefined\": undefined," +
|
||||
"}";
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception
|
||||
{
|
||||
|
|
|
@ -23,9 +23,9 @@ import java.util.Locale;
|
|||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -69,7 +69,6 @@ public class DateCacheTest
|
|||
TimeUnit.MILLISECONDS.sleep(50);
|
||||
now=System.currentTimeMillis();
|
||||
}
|
||||
Assert.assertTrue(hits/10 > misses);
|
||||
Assert.assertTrue(hits / 10 > misses);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,28 +28,34 @@ import javax.servlet.MultipartConfigElement;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Part;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.jetty.util.MultiPartInputStream.MultiPart;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* MultiPartInputStreamTest
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MultiPartInputStreamTest extends TestCase
|
||||
public class MultiPartInputStreamTest
|
||||
{
|
||||
private static final String FILENAME = "stuff.txt";
|
||||
protected String _contentType = "multipart/form-data, boundary=AaB03x";
|
||||
protected String _multi = createMultipartRequestString(FILENAME);
|
||||
protected String _dirname = System.getProperty("java.io.tmpdir")+File.separator+"myfiles-"+System.currentTimeMillis();
|
||||
|
||||
|
||||
@Test
|
||||
public void testNonMultiPartRequest()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -61,6 +67,7 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
assertTrue(mpis.getParts().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoLimits()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -73,6 +80,7 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
assertFalse(parts.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestTooBig ()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -93,6 +101,7 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileTooBig()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -113,13 +122,14 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMulti ()
|
||||
throws Exception
|
||||
{
|
||||
testMulti(FILENAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiWithSpaceInFilename() throws Exception
|
||||
{
|
||||
testMulti("stuff with spaces.txt");
|
||||
|
@ -164,9 +174,9 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
assertThat(stuff.getHeader("content-disposition"),is("form-data; name=\"stuff\"; filename=\"" + filename + "\""));
|
||||
assertThat(stuff.getHeaderNames().size(),is(2));
|
||||
assertThat(stuff.getSize(),is(51L));
|
||||
f = ((MultiPartInputStream.MultiPart)stuff).getFile();
|
||||
f = stuff.getFile();
|
||||
assertThat(f,notNullValue()); // longer than 100 bytes, should already be a file
|
||||
assertThat(((MultiPartInputStream.MultiPart)stuff).getBytes(),nullValue()); //not in internal buffer any more
|
||||
assertThat(stuff.getBytes(),nullValue()); //not in internal buffer any more
|
||||
assertThat(f.exists(),is(true));
|
||||
assertThat(f.getName(),is(not("stuff with space.txt")));
|
||||
stuff.write(filename);
|
||||
|
@ -174,6 +184,7 @@ public class MultiPartInputStreamTest extends TestCase
|
|||
assertThat(f.exists(),is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSameNames ()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -18,18 +18,13 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StringUtilTest
|
||||
{
|
||||
@Test
|
||||
|
|
|
@ -23,8 +23,8 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class AggregateLifeCycleTest
|
|||
a0.addBean(a1);
|
||||
|
||||
a0.start();
|
||||
Assert.assertEquals(1,started.get());
|
||||
Assert.assertEquals(1, started.get());
|
||||
Assert.assertEquals(0,stopped.get());
|
||||
Assert.assertEquals(0,destroyed.get());
|
||||
|
||||
|
@ -250,7 +250,7 @@ public class AggregateLifeCycleTest
|
|||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump,"");
|
||||
|
||||
|
||||
AggregateLifeCycle aa2 = new AggregateLifeCycle();
|
||||
a0.addBean(aa2,false);
|
||||
dump=trim(a0.dump());
|
||||
|
@ -259,7 +259,7 @@ public class AggregateLifeCycleTest
|
|||
dump=check(dump," += org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump,"");
|
||||
|
||||
|
||||
aa1.start();
|
||||
a0.start();
|
||||
dump=trim(a0.dump());
|
||||
|
@ -268,14 +268,14 @@ public class AggregateLifeCycleTest
|
|||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump," +~ org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump,"");
|
||||
|
||||
|
||||
a0.manage(aa1);
|
||||
a0.removeBean(aa2);
|
||||
dump=trim(a0.dump());
|
||||
dump=check(dump,"org.eclipse.jetty.util.component.AggregateLifeCycl");
|
||||
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump," +- org.eclipse.jetty.util.component.AggregateLife");
|
||||
dump=check(dump,"");
|
||||
dump=check(dump,"");
|
||||
|
||||
AggregateLifeCycle aaa0 = new AggregateLifeCycle();
|
||||
aa0.addBean(aaa0);
|
||||
|
|
|
@ -30,10 +30,10 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class SslContextFactoryTest
|
||||
|
|
|
@ -22,9 +22,9 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -77,9 +77,9 @@ public class QueuedThreadPoolTest
|
|||
tp.setMaxThreads(10);
|
||||
tp.setMaxIdleTimeMs(1000);
|
||||
tp.setThreadsPriority(Thread.NORM_PRIORITY-1);
|
||||
|
||||
|
||||
tp.start();
|
||||
|
||||
|
||||
waitForThreads(tp,5);
|
||||
waitForIdle(tp,5);
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class QueuedThreadPoolTest
|
|||
jobs[i]=new RunningJob();
|
||||
tp.dispatch(jobs[i]);
|
||||
}
|
||||
|
||||
|
||||
waitForIdle(tp,1);
|
||||
waitForThreads(tp,6);
|
||||
|
||||
|
@ -238,7 +238,7 @@ public class QueuedThreadPoolTest
|
|||
{}
|
||||
now=System.currentTimeMillis();
|
||||
}
|
||||
Assert.assertEquals(idle,tp.getIdleThreads());
|
||||
Assert.assertEquals(idle, tp.getIdleThreads());
|
||||
}
|
||||
|
||||
private void waitForThreads(QueuedThreadPool tp, int threads)
|
||||
|
|
|
@ -29,16 +29,12 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class TimeoutTest
|
||||
{
|
||||
private boolean _stress=Boolean.getBoolean("STRESS");
|
||||
private boolean _stress=Boolean.getBoolean("STRESS");
|
||||
|
||||
Object lock = new Object();
|
||||
Timeout timeout = new Timeout(null);
|
||||
Timeout.Task[] tasks;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
|
|
|
@ -27,11 +27,11 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
|
|
@ -31,10 +31,9 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.websocket.core.api.WebSocketBehavior;
|
||||
|
@ -46,6 +45,7 @@ import org.eclipse.jetty.websocket.core.protocol.Parser;
|
|||
import org.eclipse.jetty.websocket.core.protocol.WebSocketFrame;
|
||||
import org.eclipse.jetty.websocket.server.examples.MyEchoSocket;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -142,7 +142,7 @@ public class WebSocketLoadRFC6455Test
|
|||
// TODO: Send it
|
||||
// TODO: Receive response
|
||||
|
||||
Assert.assertEquals(message,_response.toString());
|
||||
Assert.assertEquals(message, _response.toString());
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@ import java.util.Map;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
package org.eclipse.jetty;
|
||||
|
||||
import com.acme.DispatchServlet;
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletTester;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Simple tests against DispatchServlet.
|
||||
*/
|
||||
public class DispatchServletTest extends TestCase
|
||||
public class DispatchServletTest
|
||||
{
|
||||
/**
|
||||
* As filed in JETTY-978.
|
||||
|
@ -65,6 +68,7 @@ public class DispatchServletTest extends TestCase
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSelfRefForwardDenialOfService() throws Exception
|
||||
{
|
||||
ServletTester tester = new ServletTester();
|
||||
|
@ -74,8 +78,8 @@ public class DispatchServletTest extends TestCase
|
|||
tester.addServlet(DefaultServlet.class,"/");
|
||||
tester.start();
|
||||
|
||||
StringBuffer req1 = new StringBuffer();
|
||||
req1.append("GET /tests/dispatch/includeN/"+dispatch.getName()+" HTTP/1.1\n");
|
||||
StringBuilder req1 = new StringBuilder();
|
||||
req1.append("GET /tests/dispatch/includeN/").append(dispatch.getName()).append(" HTTP/1.1\n");
|
||||
req1.append("Host: tester\n");
|
||||
req1.append("Connection: close\n");
|
||||
req1.append("\n");
|
||||
|
@ -88,6 +92,7 @@ public class DispatchServletTest extends TestCase
|
|||
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelfRefDeep() throws Exception
|
||||
{
|
||||
ServletTester tester = new ServletTester();
|
||||
|
@ -106,11 +111,9 @@ public class DispatchServletTest extends TestCase
|
|||
*/
|
||||
int nestedDepth = 220;
|
||||
|
||||
for (int sri = 0; sri < selfRefs.length; sri++)
|
||||
for (String selfRef : selfRefs)
|
||||
{
|
||||
String selfRef = selfRefs[sri];
|
||||
|
||||
StringBuffer req1 = new StringBuffer();
|
||||
StringBuilder req1 = new StringBuilder();
|
||||
req1.append("GET /tests");
|
||||
for (int i = 0; i < nestedDepth; i++)
|
||||
{
|
||||
|
@ -124,7 +127,7 @@ public class DispatchServletTest extends TestCase
|
|||
|
||||
String response = tester.getResponses(req1.toString());
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Response code on nested \"").append(selfRef).append("\"");
|
||||
msg.append(" (depth:").append(nestedDepth).append(")");
|
||||
|
||||
|
@ -132,7 +135,7 @@ public class DispatchServletTest extends TestCase
|
|||
"the nestedDepth in the TestCase is too large (reduce it)",
|
||||
response.startsWith("HTTP/1.1 413 "));
|
||||
|
||||
assertFalse(msg + " should not be code 500.",response.startsWith("HTTP/1.1 500 "));
|
||||
assertFalse(msg + " should not be code 500.", response.startsWith("HTTP/1.1 500 "));
|
||||
|
||||
assertTrue(msg + " should return error code 403 (Forbidden)", response.startsWith("HTTP/1.1 403 "));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue