Merging back /branches/jetty-bug-296978 revs 2674:HEAD
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2709 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
dd7511a721
commit
acc4f230fc
|
@ -72,7 +72,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -86,10 +86,14 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -31,6 +32,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
public class SecuredContentExchangeTest
|
||||
extends ContentExchangeTest
|
||||
|
@ -60,7 +62,8 @@ public class SecuredContentExchangeTest
|
|||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
server.addConnector(connector);
|
||||
|
||||
LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
server.addBean(loginService);
|
||||
|
||||
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -32,6 +33,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
public class SecuredErrorStatusTest
|
||||
extends ErrorStatusTest
|
||||
|
@ -128,7 +130,8 @@ public class SecuredErrorStatusTest
|
|||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
server.addConnector(connector);
|
||||
|
||||
LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
server.addBean(loginService);
|
||||
|
||||
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -43,6 +44,7 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
/**
|
||||
* Functional testing for HttpExchange.
|
||||
|
@ -285,7 +287,8 @@ public class SecurityListenerTest extends TestCase
|
|||
cm.setConstraint(constraint);
|
||||
cm.setPathSpec("/*");
|
||||
|
||||
LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
|
||||
sh.setLoginService(loginService);
|
||||
sh.setAuthenticator(new BasicAuthenticator());
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
public class SslContentExchangeTest
|
||||
extends ContentExchangeTest
|
||||
|
@ -33,8 +34,8 @@ public class SslContentExchangeTest
|
|||
setProtocol("https");
|
||||
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
String keystore = new File("src/test/resources/keystore").getAbsolutePath();
|
||||
connector.setKeystore(keystore);
|
||||
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||
connector.setKeystore(keystore.getAbsolutePath());
|
||||
connector.setPassword("storepwd");
|
||||
connector.setKeyPassword("keypwd");
|
||||
server.addConnector(connector);
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
public class SslSecuredContentExchangeTest
|
||||
extends ContentExchangeTest
|
||||
|
@ -59,13 +60,14 @@ extends ContentExchangeTest
|
|||
});
|
||||
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
String keystore = new File("src/test/resources/keystore").getAbsolutePath();
|
||||
connector.setKeystore(keystore);
|
||||
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||
connector.setKeystore(keystore.getAbsolutePath());
|
||||
connector.setPassword("storepwd");
|
||||
connector.setKeyPassword("keypwd");
|
||||
server.addConnector(connector);
|
||||
|
||||
LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
server.addBean(loginService);
|
||||
|
||||
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -33,6 +34,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
public class SslSecuredErrorStatusTest
|
||||
extends ErrorStatusTest
|
||||
|
@ -126,7 +128,8 @@ public class SslSecuredErrorStatusTest
|
|||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
server.addConnector(connector);
|
||||
|
||||
LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
server.addBean(loginService);
|
||||
|
||||
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.jetty.io.EofException;
|
|||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.security.LoginService;
|
||||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
|
@ -45,6 +46,7 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.ssl.SslSocketConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
/**
|
||||
|
@ -162,7 +164,8 @@ public class SslSecurityListenerTest extends TestCase
|
|||
cm.setConstraint(constraint);
|
||||
cm.setPathSpec("/*");
|
||||
|
||||
HashLoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
|
||||
File realmPropFile = MavenTestingUtils.getTestResourceFile("realm.properties");
|
||||
LoginService loginService = new HashLoginService("MyRealm",realmPropFile.getAbsolutePath());
|
||||
_server.addBean(loginService);
|
||||
|
||||
BasicAuthenticator authenticator = new BasicAuthenticator();
|
||||
|
|
|
@ -15,20 +15,23 @@ package org.eclipse.jetty.client;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.client.security.Realm;
|
||||
import org.eclipse.jetty.client.security.SimpleRealmResolver;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Functional testing for HttpExchange.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
||||
public class WebdavListenerTest
|
||||
{
|
||||
protected String _scheme = "http://";
|
||||
protected Server _server;
|
||||
|
@ -43,11 +46,8 @@ public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
|||
private String _dirFileURL;
|
||||
private String _dirURL;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_singleFileURL = "https://dav.codehaus.org/user/" + _username + "/foo.txt";
|
||||
_dirURL = "https://dav.codehaus.org/user/" + _username + "/ttt/";
|
||||
|
@ -82,25 +82,20 @@ public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown () throws Exception
|
||||
{
|
||||
_httpClient.stop();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore("Only works with real WebDAV server")
|
||||
public void testPUTandDELETEwithSSL() throws Exception
|
||||
{
|
||||
File file = new File("src/test/resources/foo.txt");
|
||||
assertTrue(file.exists());
|
||||
|
||||
|
||||
/*
|
||||
* UNCOMMENT TO TEST WITH REAL DAV SERVER
|
||||
* Remember to set _username and _password to a real user's account.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
{
|
||||
File file = MavenTestingUtils.getTestResourceFile("foo.txt");
|
||||
PathAssert.assertFileExists("WebDAV test file", file);
|
||||
|
||||
//PUT a FILE
|
||||
ContentExchange singleFileExchange = new ContentExchange();
|
||||
singleFileExchange.setURL(_singleFileURL);
|
||||
|
@ -112,8 +107,7 @@ public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
|||
singleFileExchange.waitForDone();
|
||||
|
||||
String result = singleFileExchange.getResponseContent();
|
||||
assertEquals(201, singleFileExchange.getResponseStatus());
|
||||
|
||||
Assert.assertEquals(201, singleFileExchange.getResponseStatus());
|
||||
|
||||
//PUT a FILE in a directory hierarchy
|
||||
ContentExchange dirFileExchange = new ContentExchange();
|
||||
|
@ -125,9 +119,7 @@ public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
|||
_httpClient.send(dirFileExchange);
|
||||
dirFileExchange.waitForDone();
|
||||
result = dirFileExchange.getResponseContent();
|
||||
assertEquals(201, singleFileExchange.getResponseStatus());
|
||||
|
||||
|
||||
Assert.assertEquals(201, singleFileExchange.getResponseStatus());
|
||||
|
||||
|
||||
//DELETE the single file
|
||||
|
@ -135,15 +127,13 @@ public class WebdavListenerTest extends TestCase//extends HttpExchangeTest
|
|||
del.setURL(_singleFileURL);
|
||||
del.setMethod(HttpMethods.DELETE);
|
||||
_httpClient.send(del);
|
||||
del.waitForCompletion();
|
||||
del.waitForDone();
|
||||
|
||||
//DELETE the whole dir
|
||||
del.setURL(_dirURL);
|
||||
del.setMethod(HttpMethods.DELETE);
|
||||
del.setRequestHeader("Depth", "infinity");
|
||||
_httpClient.send(del);
|
||||
del.waitForCompletion();
|
||||
*/
|
||||
del.waitForDone();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,10 +92,14 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -23,8 +23,9 @@ import java.util.List;
|
|||
import org.eclipse.jetty.deploy.graph.GraphOutputDot;
|
||||
import org.eclipse.jetty.deploy.graph.Node;
|
||||
import org.eclipse.jetty.deploy.graph.Path;
|
||||
import org.eclipse.jetty.deploy.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +33,10 @@ import org.junit.Test;
|
|||
*/
|
||||
public class AppLifeCycleTest
|
||||
{
|
||||
private void assertNoPath(String from, String to)
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private void assertNoPath(String from, String to)
|
||||
{
|
||||
assertPath(from,to,new ArrayList<String>());
|
||||
}
|
||||
|
@ -169,8 +173,7 @@ public class AppLifeCycleTest
|
|||
AppLifeCycle lifecycle = new AppLifeCycle();
|
||||
List<String> expected = new ArrayList<String>();
|
||||
|
||||
File outputDir = MavenTestingUtils.getTargetTestingDir(this.getClass().getName() + ".testFindPathMultiple");
|
||||
outputDir.mkdirs();
|
||||
File outputDir = testdir.getEmptyDir();
|
||||
|
||||
// Modify graph to add new 'staging' -> 'staged' between 'deployed' and 'started'
|
||||
GraphOutputDot.write(lifecycle,new File(outputDir,"multiple-1.dot")); // before change
|
||||
|
|
|
@ -4,12 +4,17 @@ import java.util.Collection;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DeploymentManagerTest
|
||||
{
|
||||
@Test
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
@Test
|
||||
public void testReceiveApp() throws Exception
|
||||
{
|
||||
DeploymentManager depman = new DeploymentManager();
|
||||
|
@ -59,7 +64,7 @@ public class DeploymentManagerTest
|
|||
XmlConfiguredJetty jetty = null;
|
||||
try
|
||||
{
|
||||
jetty = new XmlConfiguredJetty();
|
||||
jetty = new XmlConfiguredJetty(testdir);
|
||||
jetty.addConfiguration("jetty.xml");
|
||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ package org.eclipse.jetty.deploy;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jetty.deploy.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.deploy.util.FileID;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
@ -52,7 +52,7 @@ public class MockAppProvider extends AbstractLifeCycle implements AppProvider
|
|||
WebAppContext context = new WebAppContext();
|
||||
|
||||
File war = new File(webappsDir,app.getOriginId().substring(5));
|
||||
context.setWar(Resource.newResource(war.toURL()).toString());
|
||||
context.setWar(Resource.newResource(war.toURI().toURL()).toString());
|
||||
|
||||
String path = war.getName();
|
||||
|
||||
|
|
|
@ -18,22 +18,26 @@ package org.eclipse.jetty.deploy.providers;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Similar in scope to {@link MonitoredDirAppProviderStartupTest}, except is concerned with the modification of existing
|
||||
* Similar in scope to {@link ScanningAppProviderStartupTest}, except is concerned with the modification of existing
|
||||
* deployed webapps due to incoming changes identified by the {@link ScanningAppProvider}.
|
||||
*/
|
||||
public class MonitoredDirAppProviderRuntimeUpdatesTest
|
||||
public class ScanningAppProviderRuntimeUpdatesTest
|
||||
{
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
private static XmlConfiguredJetty jetty;
|
||||
|
||||
@Before
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
jetty = new XmlConfiguredJetty();
|
||||
jetty = new XmlConfiguredJetty(testdir);
|
||||
jetty.addConfiguration("jetty.xml");
|
||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||
|
|
@ -16,21 +16,25 @@
|
|||
package org.eclipse.jetty.deploy.providers;
|
||||
|
||||
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link ScanningAppProvider} as it starts up for the first time.
|
||||
*/
|
||||
public class MonitoredDirAppProviderStartupTest
|
||||
public class ScanningAppProviderStartupTest
|
||||
{
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
private static XmlConfiguredJetty jetty;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupEnvironment() throws Exception
|
||||
@Before
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
jetty = new XmlConfiguredJetty();
|
||||
jetty = new XmlConfiguredJetty(testdir);
|
||||
jetty.addConfiguration("jetty.xml");
|
||||
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
|
||||
|
||||
|
@ -45,8 +49,8 @@ public class MonitoredDirAppProviderStartupTest
|
|||
jetty.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void teardownEnvironment() throws Exception
|
||||
@After
|
||||
public void teardownEnvironment() throws Exception
|
||||
{
|
||||
// Stop jetty.
|
||||
jetty.stop();
|
|
@ -4,19 +4,23 @@ import java.io.File;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
|
||||
import org.junit.AfterClass;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WebAppProviderTest
|
||||
{
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
private static XmlConfiguredJetty jetty;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupEnvironment() throws Exception
|
||||
@Before
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
jetty = new XmlConfiguredJetty();
|
||||
jetty = new XmlConfiguredJetty(testdir);
|
||||
jetty.addConfiguration("jetty.xml");
|
||||
jetty.addConfiguration("jetty-deploy-wars.xml");
|
||||
|
||||
|
@ -31,8 +35,8 @@ public class WebAppProviderTest
|
|||
jetty.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void teardownEnvironment() throws Exception
|
||||
@After
|
||||
public void teardownEnvironment() throws Exception
|
||||
{
|
||||
// Stop jetty.
|
||||
jetty.stop();
|
||||
|
|
|
@ -1,221 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.deploy.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
/**
|
||||
* Common utility methods for working with JUnit tests cases in a maven friendly way.
|
||||
*/
|
||||
public class MavenTestingUtils
|
||||
{
|
||||
private static File basedir;
|
||||
private static File testResourcesDir;
|
||||
private static File targetDir;
|
||||
|
||||
// private static Boolean surefireRunning;
|
||||
|
||||
public static File getBasedir()
|
||||
{
|
||||
if (basedir == null)
|
||||
{
|
||||
String cwd = System.getProperty("basedir");
|
||||
|
||||
if (cwd == null)
|
||||
{
|
||||
cwd = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
basedir = new File(cwd);
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the /target directory for this project.
|
||||
*
|
||||
* @return the directory path to the target directory.
|
||||
*/
|
||||
public static File getTargetDir()
|
||||
{
|
||||
if (targetDir == null)
|
||||
{
|
||||
targetDir = new File(getBasedir(),"target");
|
||||
PathAssert.assertDirExists("Target Dir",targetDir);
|
||||
}
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link File} object for a path in the /target directory.
|
||||
*
|
||||
* @param path
|
||||
* the path desired, no validation of existence is performed.
|
||||
* @return the File to the path.
|
||||
*/
|
||||
public static File getTargetFile(String path)
|
||||
{
|
||||
return new File(getTargetDir(),path.replace("/",File.separator));
|
||||
}
|
||||
|
||||
public static File getTargetTestingDir()
|
||||
{
|
||||
File dir = new File(getTargetDir(),"testing");
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the JUnit 3.x {@link TestCase#getName()} to make itself unique.
|
||||
*
|
||||
* @param test
|
||||
* the junit 3.x testcase to base this new directory on.
|
||||
* @return the File path to the testcase specific testing directory underneath the
|
||||
* <code>${basedir}/target</code> sub directory
|
||||
*/
|
||||
public static File getTargetTestingDir(TestCase test)
|
||||
{
|
||||
return getTargetTestingDir(test.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the an arbitrary name.
|
||||
*
|
||||
* @param testname
|
||||
* the testname to create directory against.
|
||||
* @return the File path to the testname sepecific testing directory underneath the
|
||||
* <code>${basedir}/target</code> sub directory
|
||||
*/
|
||||
public static File getTargetTestingDir(String testname)
|
||||
{
|
||||
File dir = new File(getTargetDir(),"test-" + testname);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a dir)
|
||||
* @return the dir in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceDir(String name)
|
||||
{
|
||||
File dir = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertDirExists("Test Resource Dir",dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a file)
|
||||
* @return the file in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceFile(String name)
|
||||
{
|
||||
File file = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertFileExists("Test Resource File",file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path resource (File or Dir) from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist)
|
||||
* @return the path in src/test/resource
|
||||
*/
|
||||
public static File getTestResourcePath(String name)
|
||||
{
|
||||
File path = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertExists("Test Resource Path",path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the src/test/resource directory
|
||||
*
|
||||
* @return the directory {@link File} to the src/test/resources directory
|
||||
*/
|
||||
public static File getTestResourcesDir()
|
||||
{
|
||||
if (testResourcesDir == null)
|
||||
{
|
||||
testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator));
|
||||
PathAssert.assertDirExists("Test Resources Dir",testResourcesDir);
|
||||
}
|
||||
return testResourcesDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the contents of a file into a String and return it.
|
||||
*
|
||||
* @param file
|
||||
* the file to read.
|
||||
* @return the contents of the file.
|
||||
* @throws IOException
|
||||
* if unable to read the file.
|
||||
*/
|
||||
public static String readToString(File file) throws IOException
|
||||
{
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
return IO.toString(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTestID()
|
||||
{
|
||||
StackTraceElement stacked[] = new Throwable().getStackTrace();
|
||||
|
||||
String name = null;
|
||||
|
||||
for(StackTraceElement stack: stacked) {
|
||||
if(stack.getClassName().endsWith("Test"))
|
||||
{
|
||||
name = stack.getClassName();
|
||||
if (stack.getMethodName().startsWith("test"))
|
||||
{
|
||||
return stack.getClassName() + "#" + stack.getMethodName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(name == null)
|
||||
{
|
||||
return "Unidentified_Test";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.deploy.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
public class PathAssert
|
||||
{
|
||||
public static void assertDirExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory());
|
||||
}
|
||||
|
||||
public static void assertFileExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile());
|
||||
}
|
||||
|
||||
public static void assertExists(String msg, File path)
|
||||
{
|
||||
Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists());
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
|
@ -38,8 +37,10 @@ import org.eclipse.jetty.http.HttpSchemes;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
@ -57,17 +58,12 @@ public class XmlConfiguredJetty
|
|||
private String _scheme = HttpSchemes.HTTP;
|
||||
private File _jettyHome;
|
||||
|
||||
public XmlConfiguredJetty() throws IOException
|
||||
{
|
||||
this(MavenTestingUtils.getTestID());
|
||||
}
|
||||
|
||||
public XmlConfiguredJetty(String testname) throws IOException
|
||||
public XmlConfiguredJetty(TestingDir testdir) throws IOException
|
||||
{
|
||||
_xmlConfigurations = new ArrayList<URL>();
|
||||
Properties properties = new Properties();
|
||||
|
||||
String jettyHomeBase = MavenTestingUtils.getTargetTestingDir(testname).getAbsolutePath();
|
||||
String jettyHomeBase = testdir.getDir().getAbsolutePath();
|
||||
// Ensure we have a new (pristene) directory to work with.
|
||||
int idx = 0;
|
||||
_jettyHome = new File(jettyHomeBase + "#" + idx);
|
||||
|
@ -336,7 +332,6 @@ public class XmlConfiguredJetty
|
|||
return contexts;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() throws Exception
|
||||
{
|
||||
XmlConfiguration last = null;
|
||||
|
@ -351,7 +346,7 @@ public class XmlConfiguredJetty
|
|||
{
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
}
|
||||
configuration.setProperties(_properties);
|
||||
configuration.getProperties().putAll(_properties);
|
||||
obj[i] = configuration.configure();
|
||||
last = configuration;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -162,11 +162,8 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -126,10 +126,20 @@
|
|||
<artifactId>jetty-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-policy</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -24,9 +24,13 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -35,7 +39,6 @@ import static org.junit.Assert.fail;
|
|||
public class JettyPolicyRuntimeTest
|
||||
{
|
||||
private HashMap<String, String> evaluator = new HashMap<String, String>();
|
||||
private boolean _runningOnWindows;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
|
@ -43,8 +46,6 @@ public class JettyPolicyRuntimeTest
|
|||
System.setSecurityManager(null);
|
||||
Policy.setPolicy(null);
|
||||
|
||||
_runningOnWindows = System.getProperty( "os.name" ).startsWith( "Windows" );
|
||||
|
||||
evaluator.put("jetty.home",MavenTestingUtils.getBaseURI().toASCIIString());
|
||||
evaluator.put("basedir",MavenTestingUtils.getBaseURI().toASCIIString());
|
||||
}
|
||||
|
@ -115,11 +116,7 @@ public class JettyPolicyRuntimeTest
|
|||
public void testPolicyRestrictive() throws Exception
|
||||
{
|
||||
// TODO - temporary, create alternate file to load for windows
|
||||
if (_runningOnWindows)
|
||||
{
|
||||
// skip run
|
||||
return;
|
||||
}
|
||||
Assume.assumeTrue(!OS.IS_WINDOWS); // Ignore test if running under windows.
|
||||
|
||||
JettyPolicy ap = new JettyPolicy(getSinglePolicy("global-file-read-only-tmp-permission.policy"),evaluator);
|
||||
ap.refresh();
|
||||
|
@ -148,14 +145,11 @@ public class JettyPolicyRuntimeTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Jesse will work on this")
|
||||
public void testCertificateLoader() throws Exception
|
||||
{
|
||||
// TODO - temporary, create alternate file to load for windows
|
||||
if (_runningOnWindows)
|
||||
{
|
||||
// skip run
|
||||
return;
|
||||
}
|
||||
Assume.assumeTrue(!OS.IS_WINDOWS); // Ignore test if running under windows.
|
||||
|
||||
JettyPolicy ap = new JettyPolicy(getSinglePolicy("jetty-certificate.policy"),evaluator);
|
||||
ap.refresh();
|
||||
|
@ -163,7 +157,7 @@ public class JettyPolicyRuntimeTest
|
|||
Policy.setPolicy( ap );
|
||||
System.setSecurityManager( new SecurityManager() );
|
||||
|
||||
URL url = MavenTestingUtils.toTargetURL("test-policy/jetty-test-policy.jar");
|
||||
URL url = MavenTestingUtils.getTargetURL("test-policy/jetty-test-policy.jar");
|
||||
|
||||
URLClassLoader loader ;
|
||||
if (Thread.currentThread().getContextClassLoader() != null )
|
||||
|
@ -203,11 +197,7 @@ public class JettyPolicyRuntimeTest
|
|||
throws Exception
|
||||
{
|
||||
// TODO - temporary, create alternate file to load for windows
|
||||
if (_runningOnWindows)
|
||||
{
|
||||
// skip run
|
||||
return;
|
||||
}
|
||||
Assume.assumeTrue(!OS.IS_WINDOWS); // Ignore test if running under windows.
|
||||
|
||||
JettyPolicy ap = new JettyPolicy(getSinglePolicy("jetty-bad-certificate.policy"),evaluator);
|
||||
ap.refresh();
|
||||
|
@ -215,7 +205,7 @@ public class JettyPolicyRuntimeTest
|
|||
Policy.setPolicy( ap );
|
||||
System.setSecurityManager( new SecurityManager() );
|
||||
|
||||
URL url = MavenTestingUtils.toTargetURL("test-policy/jetty-test-policy.jar");
|
||||
URL url = MavenTestingUtils.getTargetURL("test-policy/jetty-test-policy.jar");
|
||||
|
||||
URLClassLoader loader ;
|
||||
if (Thread.currentThread().getContextClassLoader() != null )
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.eclipse.jetty.policy;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilePermission;
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
|
@ -24,7 +25,6 @@ import java.security.PermissionCollection;
|
|||
import java.security.ProtectionDomain;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.PropertyPermission;
|
||||
|
@ -32,6 +32,7 @@ import java.util.Set;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -58,8 +59,8 @@ public class JettyPolicyTest
|
|||
@Test
|
||||
public void testGlobalAllPermissionLoader() throws Exception
|
||||
{
|
||||
|
||||
JettyPolicy ap = new JettyPolicy( Collections.singleton( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/global-all-permission.policy" ), evaluator );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("global-all-permission.policy");
|
||||
JettyPolicy ap = new JettyPolicy( Collections.singleton( policyFile.getAbsolutePath() ), evaluator );
|
||||
ap.refresh();
|
||||
|
||||
PermissionCollection pc = ap.getPermissions( new ProtectionDomain( null, null ) );
|
||||
|
@ -83,9 +84,8 @@ public class JettyPolicyTest
|
|||
@Test
|
||||
public void testSingleCodebaseFilePermissionLoader() throws Exception
|
||||
{
|
||||
JettyPolicy ap =
|
||||
new JettyPolicy( Collections.singleton( MavenTestingUtils.getBasedir().getAbsolutePath()
|
||||
+ "/src/test/resources/single-codebase-file-permission.policy" ), evaluator );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("single-codebase-file-permission.policy");
|
||||
JettyPolicy ap = new JettyPolicy( Collections.singleton( policyFile.getAbsolutePath() ), evaluator );
|
||||
ap.refresh();
|
||||
|
||||
URL url = new URL( "file:///foo.jar" );
|
||||
|
@ -113,9 +113,8 @@ public class JettyPolicyTest
|
|||
@Test
|
||||
public void testMultipleCodebaseFilePermissionLoader() throws Exception
|
||||
{
|
||||
JettyPolicy ap =
|
||||
new JettyPolicy( Collections.singleton( MavenTestingUtils.getBasedir().getAbsolutePath()
|
||||
+ "/src/test/resources/multiple-codebase-file-permission.policy" ), evaluator );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("multiple-codebase-file-permission.policy");
|
||||
JettyPolicy ap = new JettyPolicy( Collections.singleton( policyFile.getAbsolutePath() ), evaluator );
|
||||
|
||||
ap.refresh();
|
||||
|
||||
|
@ -168,9 +167,8 @@ public class JettyPolicyTest
|
|||
@Test
|
||||
public void testMultipleCodebaseMixedPermissionLoader() throws Exception
|
||||
{
|
||||
JettyPolicy ap =
|
||||
new JettyPolicy( Collections.singleton( MavenTestingUtils.getBasedir().getAbsolutePath()
|
||||
+ "/src/test/resources/multiple-codebase-mixed-permission.policy" ), evaluator );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("multiple-codebase-mixed-permission.policy");
|
||||
JettyPolicy ap = new JettyPolicy( Collections.singleton( policyFile.getAbsolutePath() ), evaluator );
|
||||
|
||||
ap.refresh();
|
||||
|
||||
|
@ -228,7 +226,8 @@ public class JettyPolicyTest
|
|||
@Test
|
||||
public void testSCLoader() throws Exception
|
||||
{
|
||||
JettyPolicy ap = new JettyPolicy(Collections.singleton(MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/main/config/lib/policy/jetty.policy"),evaluator);
|
||||
File policyFile = MavenTestingUtils.getProjectFile("src/main/config/lib/policy/jetty.policy");
|
||||
JettyPolicy ap = new JettyPolicy(Collections.singleton(policyFile.getAbsolutePath()),evaluator);
|
||||
|
||||
ap.refresh();
|
||||
}
|
||||
|
@ -242,8 +241,8 @@ public class JettyPolicyTest
|
|||
{
|
||||
Set<String> files = new HashSet<String>();
|
||||
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission.policy" );
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission-2.policy" );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission.policy").getAbsolutePath() );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission-2.policy").getAbsolutePath() );
|
||||
|
||||
JettyPolicy ap = new JettyPolicy( files, evaluator );
|
||||
|
||||
|
@ -274,9 +273,9 @@ public class JettyPolicyTest
|
|||
{
|
||||
Set<String> files = new HashSet<String>();
|
||||
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission.policy" );
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission-2.policy" );
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission-3.policy" );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission.policy").getAbsolutePath() );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission-2.policy").getAbsolutePath() );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission-3.policy").getAbsolutePath() );
|
||||
|
||||
JettyPolicy ap = new JettyPolicy( files, evaluator );
|
||||
|
||||
|
@ -310,8 +309,8 @@ public class JettyPolicyTest
|
|||
{
|
||||
Set<String> files = new HashSet<String>();
|
||||
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/single-codebase-file-permission.policy" );
|
||||
files.add( MavenTestingUtils.getBasedir().getAbsolutePath() + "/src/test/resources/context" );
|
||||
files.add( MavenTestingUtils.getTestResourceFile("single-codebase-file-permission.policy").getAbsolutePath() );
|
||||
files.add( MavenTestingUtils.getTestResourceDir("context").getAbsolutePath() );
|
||||
|
||||
JettyPolicy ap = new JettyPolicy( files, evaluator );
|
||||
|
||||
|
|
|
@ -1,209 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.policy;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Common utility methods for working with JUnit tests cases in a maven friendly way.
|
||||
*/
|
||||
public class MavenTestingUtils
|
||||
{
|
||||
private static File basedir;
|
||||
private static File testResourcesDir;
|
||||
private static File targetDir;
|
||||
private static URI baseURI;
|
||||
|
||||
public static File getBasedir()
|
||||
{
|
||||
if (basedir == null)
|
||||
{
|
||||
String cwd = System.getProperty("basedir");
|
||||
|
||||
if (cwd == null)
|
||||
{
|
||||
// System property not set.
|
||||
|
||||
// Use CWD.
|
||||
cwd = System.getProperty("user.dir");
|
||||
basedir = new File(cwd);
|
||||
|
||||
// Set the System property.
|
||||
System.setProperty("basedir",basedir.getAbsolutePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Has system property, use it.
|
||||
basedir = new File(cwd);
|
||||
}
|
||||
|
||||
baseURI = basedir.toURI();
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the /target directory for this project.
|
||||
*
|
||||
* @return the directory path to the target directory.
|
||||
*/
|
||||
public static File getTargetDir()
|
||||
{
|
||||
if (targetDir == null)
|
||||
{
|
||||
targetDir = new File(basedir,"target");
|
||||
// PathAssert.assertDirExists("Target Dir",targetDir);
|
||||
}
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a file)
|
||||
* @return the file in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceFile(String name)
|
||||
{
|
||||
File file = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertFileExists("Test Resource File",file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a dir)
|
||||
* @return the dir in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceDir(String name)
|
||||
{
|
||||
File dir = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertDirExists("Test Resource Dir",dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path resource (File or Dir) from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist)
|
||||
* @return the path in src/test/resource
|
||||
*/
|
||||
public static File getTestResourcePath(String name)
|
||||
{
|
||||
File path = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertExists("Test Resource Path",path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the src/test/resource directory
|
||||
*
|
||||
* @return the directory {@link File} to the src/test/resources directory
|
||||
*/
|
||||
public static File getTestResourcesDir()
|
||||
{
|
||||
if (testResourcesDir == null)
|
||||
{
|
||||
testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator));
|
||||
PathAssert.assertDirExists("Test Resources Dir",testResourcesDir);
|
||||
}
|
||||
return testResourcesDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link File} object for a path in the /target directory.
|
||||
*
|
||||
* @param path
|
||||
* the path desired, no validation of existence is performed.
|
||||
* @return the File to the path.
|
||||
*/
|
||||
public static File toTargetFile(String path)
|
||||
{
|
||||
return new File(getTargetDir(),path.replace("/",File.separator));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the contents of a file into a String and return it.
|
||||
*
|
||||
* @param file
|
||||
* the file to read.
|
||||
* @return the contents of the file.
|
||||
* @throws IOException
|
||||
* if unable to read the file.
|
||||
*/
|
||||
public static String readToString(File file) throws IOException
|
||||
{
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
int bufSize = 8096;
|
||||
char buf[] = new char[bufSize];
|
||||
int len = bufSize;
|
||||
|
||||
while (true)
|
||||
{
|
||||
len = reader.read(buf,0,bufSize);
|
||||
if (len == -1)
|
||||
break;
|
||||
writer.write(buf,0,len);
|
||||
}
|
||||
|
||||
return writer.toString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
catch (IOException ignore)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static URI getBaseURI()
|
||||
{
|
||||
if (baseURI == null)
|
||||
{
|
||||
getBasedir();
|
||||
}
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
public static URL toTargetURL(String path) throws MalformedURLException
|
||||
{
|
||||
return getBaseURI().resolve("target/" + path).toURL();
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.policy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class PathAssert
|
||||
{
|
||||
public static void assertDirExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory());
|
||||
}
|
||||
|
||||
public static void assertFileExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile());
|
||||
}
|
||||
|
||||
public static void assertExists(String msg, File path)
|
||||
{
|
||||
Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists());
|
||||
}
|
||||
}
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
|||
import org.eclipse.jetty.policy.entry.GrantEntry;
|
||||
import org.eclipse.jetty.policy.entry.KeystoreEntry;
|
||||
import org.eclipse.jetty.policy.loader.PolicyFileScanner;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -34,12 +36,10 @@ import static org.junit.Assert.assertEquals;
|
|||
public class PolicyContextTest
|
||||
{
|
||||
public static final String __PRINCIPAL = "javax.security.auth.x500.X500Principal \"CN=Jetty Policy,OU=Artifact,O=Jetty Project,L=Earth,ST=Internet,C=US\"";
|
||||
private boolean _runningOnWindows;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_runningOnWindows = System.getProperty( "os.name" ).startsWith( "Windows" );
|
||||
System.setProperty( "basedir", MavenTestingUtils.getBaseURI().toASCIIString() );
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,11 @@ public class PolicyContextTest
|
|||
List<GrantEntry> grantEntries = new ArrayList<GrantEntry>();
|
||||
List<KeystoreEntry> keystoreEntries = new ArrayList<KeystoreEntry>();
|
||||
|
||||
File policyFile = new File( getWorkingDirectory() + "/src/test/resources/context/jetty-certificate.policy" );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("context/jetty-certificate.policy");
|
||||
|
||||
loader.scanStream( new InputStreamReader( new FileInputStream( policyFile ) ), grantEntries, keystoreEntries );
|
||||
|
||||
if ( !_runningOnWindows ) //temporary, create alternate file to load for windows
|
||||
if ( !OS.IS_WINDOWS ) //temporary, create alternate file to load for windows
|
||||
{
|
||||
for (KeystoreEntry node : keystoreEntries)
|
||||
{
|
||||
|
@ -81,11 +81,11 @@ public class PolicyContextTest
|
|||
List<GrantEntry> grantEntries = new ArrayList<GrantEntry>();
|
||||
List<KeystoreEntry> keystoreEntries = new ArrayList<KeystoreEntry>();
|
||||
|
||||
File policyFile = new File( getWorkingDirectory() + "/src/test/resources/context/jetty-certificate-alias.policy" );
|
||||
File policyFile = MavenTestingUtils.getTestResourceFile("context/jetty-certificate-alias.policy");
|
||||
|
||||
loader.scanStream( new InputStreamReader( new FileInputStream( policyFile ) ), grantEntries, keystoreEntries );
|
||||
|
||||
if ( !_runningOnWindows ) //temporary, create alternate file to load for windows
|
||||
if ( !OS.IS_WINDOWS ) //temporary, create alternate file to load for windows
|
||||
{
|
||||
for (KeystoreEntry node : keystoreEntries)
|
||||
{
|
||||
|
@ -115,9 +115,4 @@ public class PolicyContextTest
|
|||
|
||||
assertEquals(File.separator + File.separator, context.evaluate( "${/}${/}" ) );
|
||||
}
|
||||
|
||||
private String getWorkingDirectory()
|
||||
{
|
||||
return MavenTestingUtils.getBasedir().getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -87,7 +87,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -62,12 +62,6 @@
|
|||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-security</artifactId>
|
||||
|
@ -79,5 +73,15 @@
|
|||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -12,19 +14,26 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.ServletResponse;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DefaultServletTest
|
||||
{
|
||||
private boolean _runningOnWindows;
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private Server server;
|
||||
private LocalConnector connector;
|
||||
private ServletContextHandler context;
|
||||
|
@ -32,8 +41,6 @@ public class DefaultServletTest
|
|||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_runningOnWindows = System.getProperty( "os.name" ).startsWith( "Windows" );
|
||||
|
||||
server = new Server();
|
||||
server.setSendServerVersion(false);
|
||||
|
||||
|
@ -63,12 +70,11 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("dirAllowed","true");
|
||||
defholder.setInitParameter("redirectWelcome","false");
|
||||
defholder.setInitParameter("gzip","false");
|
||||
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
|
||||
testdir.ensureEmpty();
|
||||
|
||||
/* create some content in the docroot */
|
||||
File resBase = new File(testDir, "docroot");
|
||||
File resBase = testdir.getFile("docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
assertTrue(new File(resBase, "one").mkdir());
|
||||
assertTrue(new File(resBase, "two").mkdir());
|
||||
|
@ -99,17 +105,17 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("redirectWelcome","false");
|
||||
defholder.setInitParameter("gzip","false");
|
||||
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
testdir.ensureEmpty();
|
||||
|
||||
/* create some content in the docroot */
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
assertTrue(new File(resBase, "one").mkdir());
|
||||
assertTrue(new File(resBase, "two").mkdir());
|
||||
assertTrue(new File(resBase, "three").mkdir());
|
||||
if ( !_runningOnWindows )
|
||||
if ( !OS.IS_WINDOWS ) {
|
||||
assertTrue("Creating dir 'f??r' (Might not work in Windows)", new File(resBase, "f??r").mkdir());
|
||||
}
|
||||
|
||||
String resBasePath = resBase.getAbsolutePath();
|
||||
defholder.setInitParameter( "resourceBase", resBasePath );
|
||||
|
@ -128,8 +134,9 @@ public class DefaultServletTest
|
|||
assertResponseContains( "/one/", response );
|
||||
assertResponseContains( "/two/", response );
|
||||
assertResponseContains( "/three/", response );
|
||||
if ( !_runningOnWindows )
|
||||
if ( !OS.IS_WINDOWS ) {
|
||||
assertResponseContains( "/f%3F%3Fr", response );
|
||||
}
|
||||
|
||||
assertResponseNotContains( "<script>", response );
|
||||
}
|
||||
|
@ -142,11 +149,10 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("redirectWelcome","false");
|
||||
defholder.setInitParameter("gzip","false");
|
||||
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
testdir.ensureEmpty();
|
||||
|
||||
/* create some content in the docroot */
|
||||
File resBase = new File(testDir, "docroot");
|
||||
File resBase = testdir.getFile("docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
File wackyDir = new File(resBase, "dir;"); // this should not be double-encoded.
|
||||
assertTrue(wackyDir.mkdirs());
|
||||
|
@ -195,27 +201,25 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("gzip","false");
|
||||
defholder.setInitParameter("aliases","true");
|
||||
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
testdir.ensureEmpty();
|
||||
|
||||
/* create some content in the docroot */
|
||||
File resBase = new File(testDir, "docroot");
|
||||
File resBase = testdir.getFile("docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
|
||||
File index = new File(resBase, "index.html");
|
||||
createFile(index, "<h1>Hello Index</h1>");
|
||||
|
||||
File wackyDir = new File(resBase, "dir?");
|
||||
if ( !_runningOnWindows )
|
||||
{
|
||||
assertTrue(wackyDir.mkdirs());
|
||||
if ( !OS.IS_WINDOWS ) {
|
||||
FS.ensureDirExists(wackyDir);
|
||||
}
|
||||
|
||||
wackyDir = new File(resBase, "dir;");
|
||||
assertTrue(wackyDir.mkdirs());
|
||||
|
||||
/* create some content outside of the docroot */
|
||||
File sekret = new File(testDir, "sekret");
|
||||
File sekret = testdir.getFile("sekret");
|
||||
assertTrue(sekret.mkdirs());
|
||||
File pass = new File(sekret, "pass");
|
||||
createFile(pass, "Sssh, you shouldn't be seeing this");
|
||||
|
@ -241,7 +245,7 @@ public class DefaultServletTest
|
|||
response= connector.getResponses("GET /context/dir?/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("404",response);
|
||||
|
||||
if ( !_runningOnWindows )
|
||||
if ( !OS.IS_WINDOWS )
|
||||
{
|
||||
response= connector.getResponses("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("Directory: /context/dir?/<",response);
|
||||
|
@ -298,10 +302,9 @@ public class DefaultServletTest
|
|||
@Test
|
||||
public void testWelcome() throws Exception
|
||||
{
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
File inde = new File(resBase, "index.htm");
|
||||
File index = new File(resBase, "index.html");
|
||||
|
||||
|
@ -317,6 +320,7 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("maxCachedFileSize","512000");
|
||||
defholder.setInitParameter("maxCachedFiles","100");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ServletHolder jspholder = context.addServlet(NoJspServlet.class,"*.jsp");
|
||||
|
||||
String response = connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
|
||||
|
@ -342,14 +346,12 @@ public class DefaultServletTest
|
|||
@Test
|
||||
public void testWelcomeServlet() throws Exception
|
||||
{
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
File inde = new File(resBase, "index.htm");
|
||||
File index = new File(resBase, "index.html");
|
||||
|
||||
|
||||
|
||||
String resBasePath = resBase.getAbsolutePath();
|
||||
|
||||
ServletHolder defholder = context.addServlet(DefaultServlet.class,"/");
|
||||
|
@ -359,7 +361,8 @@ public class DefaultServletTest
|
|||
defholder.setInitParameter("gzip","false");
|
||||
defholder.setInitParameter("resourceBase",resBasePath);
|
||||
|
||||
ServletHolder jspholder = context.addServlet(NoJspServlet.class,"*.jsp");
|
||||
@SuppressWarnings("unused")
|
||||
ServletHolder jspholder = context.addServlet(NoJspServlet.class,"*.jsp");
|
||||
|
||||
String response;
|
||||
|
||||
|
@ -374,11 +377,11 @@ public class DefaultServletTest
|
|||
response= connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("<h1>Hello Index</h1>",response);
|
||||
|
||||
assertTrue(index.delete());
|
||||
deleteFile(index);
|
||||
response= connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("<h1>Hello Inde</h1>",response);
|
||||
|
||||
assertTrue(inde.delete());
|
||||
deleteFile(inde);
|
||||
response= connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("JSP support not configured",response);
|
||||
}
|
||||
|
@ -386,10 +389,9 @@ public class DefaultServletTest
|
|||
@Test
|
||||
public void testWelcomeExactServlet() throws Exception
|
||||
{
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
File inde = new File(resBase, "index.htm");
|
||||
File index = new File(resBase, "index.html");
|
||||
|
||||
|
@ -430,10 +432,9 @@ public class DefaultServletTest
|
|||
@Test
|
||||
public void testRangeRequests() throws Exception
|
||||
{
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
File data = new File(resBase, "data.txt");
|
||||
createFile(data,"01234567890123456789012345678901234567890123456789012345678901234567890123456789");
|
||||
String resBasePath = resBase.getAbsolutePath();
|
||||
|
@ -511,10 +512,9 @@ public class DefaultServletTest
|
|||
@Test
|
||||
public void testFiltered() throws Exception
|
||||
{
|
||||
File testDir = new File("target/tests/" + DefaultServletTest.class.getSimpleName());
|
||||
prepareEmptyTestDir(testDir);
|
||||
File resBase = new File(testDir, "docroot");
|
||||
assertTrue(resBase.mkdirs());
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
FS.ensureDirExists(resBase);
|
||||
File file0 = new File(resBase, "data0.txt");
|
||||
createFile(file0, "Hello Text 0");
|
||||
|
||||
|
@ -593,49 +593,6 @@ public class DefaultServletTest
|
|||
}
|
||||
}
|
||||
|
||||
private void prepareEmptyTestDir(File testdir)
|
||||
{
|
||||
if (testdir.exists())
|
||||
{
|
||||
emptyDir(testdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
assertTrue(testdir.mkdirs());
|
||||
}
|
||||
|
||||
assertTrue("test dir should exists",testdir.exists());
|
||||
assertTrue("test dir should be a dir",testdir.isDirectory());
|
||||
assertTrue("test dir should be empty",isEmpty(testdir));
|
||||
}
|
||||
|
||||
private boolean isEmpty(File dir)
|
||||
{
|
||||
if (!dir.isDirectory())
|
||||
return true;
|
||||
|
||||
return dir.list().length == 0;
|
||||
}
|
||||
|
||||
private void emptyDir(File dir)
|
||||
{
|
||||
File entries[] = dir.listFiles();
|
||||
for (File entry : entries)
|
||||
deletePath(entry);
|
||||
}
|
||||
|
||||
private void deletePath(File path)
|
||||
{
|
||||
if (path.isDirectory())
|
||||
{
|
||||
File entries[] = path.listFiles();
|
||||
for (File entry : entries)
|
||||
deletePath(entry);
|
||||
}
|
||||
|
||||
assertTrue("Deleting: " + path.getAbsolutePath(),path.delete());
|
||||
}
|
||||
|
||||
private void assertResponseNotContains(String forbidden, String response)
|
||||
{
|
||||
int idx = response.indexOf(forbidden);
|
||||
|
@ -666,4 +623,16 @@ public class DefaultServletTest
|
|||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
private void deleteFile(File file) throws IOException {
|
||||
if(OS.IS_WINDOWS) {
|
||||
// Since Windows doesn't seem to like to delete content that was recently created.
|
||||
File deleted = MavenTestingUtils.getTargetFile(".deleted");
|
||||
FS.ensureDirExists(deleted);
|
||||
File dest = File.createTempFile(file.getName(), "deleted", deleted);
|
||||
Assert.assertTrue("Unable to move file out of the way: " + file.getName(), file.renameTo(dest));
|
||||
} else {
|
||||
Assert.assertTrue("Deleting: " + file.getName(), file.delete());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
17
pom.xml
17
pom.xml
|
@ -18,7 +18,6 @@
|
|||
<javax-servlet-jsp-version>2.1.v20100127</javax-servlet-jsp-version>
|
||||
<javax-transaction-version>1.1.1</javax-transaction-version>
|
||||
<jetty.url>http://www.eclipse.org/jetty</jetty.url>
|
||||
<junit-version>3.8.2</junit-version>
|
||||
<junit4-version>4.8.1</junit4-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<slf4j-version>1.5.11</slf4j-version>
|
||||
|
@ -245,6 +244,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<targetJdk>1.5</targetJdk>
|
||||
<rulesets>
|
||||
|
@ -255,10 +255,10 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<!--
|
||||
<repositories>
|
||||
<repository>
|
||||
<snapshots>
|
||||
|
@ -269,7 +269,6 @@
|
|||
<url>http://oss.sonatype.org/content/groups/jetty</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
-->
|
||||
<modules>
|
||||
<module>jetty-util</module>
|
||||
<module>jetty-jmx</module>
|
||||
|
@ -317,9 +316,9 @@
|
|||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -351,6 +350,12 @@
|
|||
<artifactId>activation</artifactId>
|
||||
<version>${javax-activation-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<!--
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.eclipse.jetty.continuation;
|
||||
|
||||
import org.eclipse.jetty.servlets.ProxyServlet;
|
||||
import org.junit.Ignore;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.nio.SelectChannelConnector;
|
||||
|
@ -9,6 +10,7 @@ import org.mortbay.jetty.servlet.FilterHolder;
|
|||
import org.mortbay.jetty.servlet.ServletHandler;
|
||||
import org.mortbay.jetty.servlet.ServletHolder;
|
||||
|
||||
@Ignore("Not a test case")
|
||||
public class TestProxyServer
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/WebAppTest.java</exclude>
|
||||
<exclude>**/Test*.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -40,9 +41,9 @@
|
|||
<descriptor>config.xml</descriptor>
|
||||
<descriptor>src/main/assembly/web-bundle.xml</descriptor>
|
||||
</descriptors>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.lang.management.ManagementFactory;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.swing.text.WrappedPlainView;
|
||||
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
|
@ -42,7 +41,9 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@Ignore("Not a test case")
|
||||
public class TestServer
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
|
|
|
@ -72,10 +72,14 @@
|
|||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -1,220 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
/**
|
||||
* Common utility methods for working with JUnit tests cases in a maven friendly way.
|
||||
*/
|
||||
public class MavenTestingUtils
|
||||
{
|
||||
private static File basedir;
|
||||
private static File testResourcesDir;
|
||||
private static File targetDir;
|
||||
|
||||
// private static Boolean surefireRunning;
|
||||
|
||||
public static File getBasedir()
|
||||
{
|
||||
if (basedir == null)
|
||||
{
|
||||
String cwd = System.getProperty("basedir");
|
||||
|
||||
if (cwd == null)
|
||||
{
|
||||
cwd = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
basedir = new File(cwd);
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the /target directory for this project.
|
||||
*
|
||||
* @return the directory path to the target directory.
|
||||
*/
|
||||
public static File getTargetDir()
|
||||
{
|
||||
if (targetDir == null)
|
||||
{
|
||||
targetDir = new File(getBasedir(),"target");
|
||||
PathAssert.assertDirExists("Target Dir",targetDir);
|
||||
}
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link File} object for a path in the /target directory.
|
||||
*
|
||||
* @param path
|
||||
* the path desired, no validation of existence is performed.
|
||||
* @return the File to the path.
|
||||
*/
|
||||
public static File getTargetFile(String path)
|
||||
{
|
||||
return new File(getTargetDir(),path.replace("/",File.separator));
|
||||
}
|
||||
|
||||
public static File getTargetTestingDir()
|
||||
{
|
||||
File dir = new File(getTargetDir(),"testing");
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the JUnit 3.x {@link TestCase#getName()} to make itself unique.
|
||||
*
|
||||
* @param test
|
||||
* the junit 3.x testcase to base this new directory on.
|
||||
* @return the dir in /target/ that uses the JUnit 3.x {@link TestCase#getName()} to make itself unique.
|
||||
*/
|
||||
public static File getTargetTestingDir(TestCase test)
|
||||
{
|
||||
return getTargetTestingDir(test.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the an arbitrary name.
|
||||
*
|
||||
* @param testname
|
||||
* the testname to create directory against.
|
||||
* @return the dir in /target/ that uses the an arbitrary name.
|
||||
*/
|
||||
public static File getTargetTestingDir(String testname)
|
||||
{
|
||||
File dir = new File(getTargetDir(),"test-" + testname);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a dir)
|
||||
* @return the dir in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceDir(String name)
|
||||
{
|
||||
File dir = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertDirExists("Test Resource Dir",dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a file)
|
||||
* @return the file in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceFile(String name)
|
||||
{
|
||||
File file = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertFileExists("Test Resource File",file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path resource (File or Dir) from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist)
|
||||
* @return the path in src/test/resource
|
||||
*/
|
||||
public static File getTestResourcePath(String name)
|
||||
{
|
||||
File path = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertExists("Test Resource Path",path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the src/test/resource directory
|
||||
*
|
||||
* @return the directory {@link File} to the src/test/resources directory
|
||||
*/
|
||||
public static File getTestResourcesDir()
|
||||
{
|
||||
if (testResourcesDir == null)
|
||||
{
|
||||
testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator));
|
||||
PathAssert.assertDirExists("Test Resources Dir",testResourcesDir);
|
||||
}
|
||||
return testResourcesDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the contents of a file into a String and return it.
|
||||
*
|
||||
* @param file
|
||||
* the file to read.
|
||||
* @return the contents of the file.
|
||||
* @throws IOException
|
||||
* if unable to read the file.
|
||||
*/
|
||||
public static String readToString(File file) throws IOException
|
||||
{
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
return IO.toString(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTestID()
|
||||
{
|
||||
StackTraceElement stacked[] = new Throwable().getStackTrace();
|
||||
|
||||
String name = null;
|
||||
|
||||
for (StackTraceElement stack : stacked)
|
||||
{
|
||||
if (stack.getClassName().endsWith("Test"))
|
||||
{
|
||||
name = stack.getClassName();
|
||||
if (stack.getMethodName().startsWith("test"))
|
||||
{
|
||||
return stack.getClassName() + "#" + stack.getMethodName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
return "Unidentified_Test";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
public class PathAssert
|
||||
{
|
||||
public static void assertDirExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory());
|
||||
}
|
||||
|
||||
public static void assertFileExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile());
|
||||
}
|
||||
|
||||
public static void assertExists(String msg, File path)
|
||||
{
|
||||
Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists());
|
||||
}
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
public class StringAssert
|
||||
{
|
||||
/**
|
||||
* Asserts that the string (<code>haystack</code>) starts with the string (
|
||||
* <code>expected</code>)
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param haystack
|
||||
* the text to search in
|
||||
* @param expected
|
||||
* the expected starts with text
|
||||
*/
|
||||
public static void assertStartsWith(String msg, String haystack, String expected)
|
||||
{
|
||||
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
|
||||
Assert.assertNotNull(msg + ": expected should not be null",expected);
|
||||
|
||||
if (!haystack.startsWith(expected))
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(msg).append(": String \"");
|
||||
int len = Math.min(expected.length() + 4,haystack.length());
|
||||
buf.append(haystack.substring(0,len));
|
||||
buf.append("\" does not start with expected \"").append(expected).append("\"");
|
||||
System.err.println(buf);
|
||||
throw new AssertionFailedError(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that string (<code>haystack</code>) contains specified text (
|
||||
* <code>needle</code>).
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param haystack
|
||||
* the text to search in
|
||||
* @param needle
|
||||
* the text to search for
|
||||
*/
|
||||
public static void assertContains(String msg, String haystack, String needle)
|
||||
{
|
||||
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
|
||||
Assert.assertNotNull(msg + ": needle should not be null",needle);
|
||||
|
||||
int idx = haystack.indexOf(needle);
|
||||
if (idx == (-1))
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(msg).append(": ");
|
||||
buf.append("Unable to find \"").append(needle).append("\" in \"");
|
||||
buf.append(haystack).append("\"");
|
||||
System.err.println(buf);
|
||||
throw new AssertionFailedError(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that string (<code>haystack</code>) contains specified text (
|
||||
* <code>needle</code>), starting at offset (in <code>haystack</code>).
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param haystack
|
||||
* the text to search in
|
||||
* @param needle
|
||||
* the text to search for
|
||||
* @param offset
|
||||
* the offset in (haystack) to perform search from
|
||||
*/
|
||||
public static void assertContains(String msg, String haystack, String needle, int offset)
|
||||
{
|
||||
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
|
||||
Assert.assertNotNull(msg + ": needle should not be null",needle);
|
||||
|
||||
int idx = haystack.indexOf(needle,offset);
|
||||
if (idx == (-1))
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(msg).append(": ");
|
||||
buf.append("Unable to find \"").append(needle).append("\" in \"");
|
||||
buf.append(haystack.substring(offset)).append("\"");
|
||||
System.err.println(buf);
|
||||
throw new AssertionFailedError(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that string (<code>haystack</code>) does <u>not</u> contain
|
||||
* specified text (<code>needle</code>).
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param haystack
|
||||
* the text to search in
|
||||
* @param needle
|
||||
* the text to search for
|
||||
*/
|
||||
public static void assertNotContains(String msg, String haystack, String needle)
|
||||
{
|
||||
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
|
||||
Assert.assertNotNull(msg + ": needle should not be null",needle);
|
||||
|
||||
int idx = haystack.indexOf(needle);
|
||||
if (idx != (-1))
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(msg).append(": ");
|
||||
buf.append("Should not have found \"").append(needle).append("\" at offset ");
|
||||
buf.append(idx).append(" in \"").append(haystack).append("\"");
|
||||
System.err.println(buf);
|
||||
throw new AssertionFailedError(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that string (<code>haystack</code>) does <u>not</u> contain
|
||||
* specified text (<code>needle</code>), starting at offset (in
|
||||
* <code>haystack</code>).
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param haystack
|
||||
* the text to search in
|
||||
* @param needle
|
||||
* the text to search for
|
||||
* @param offset
|
||||
* the offset in (haystack) to perform search from
|
||||
*/
|
||||
public static void assertNotContains(String msg, String haystack, String needle, int offset)
|
||||
{
|
||||
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
|
||||
Assert.assertNotNull(msg + ": needle should not be null",needle);
|
||||
|
||||
int idx = haystack.indexOf(needle,offset);
|
||||
if (idx != (-1))
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(msg).append(": ");
|
||||
buf.append("Should not have found \"").append(needle).append("\" at offset ");
|
||||
buf.append(idx).append(" in \"").append(haystack.substring(offset)).append("\"");
|
||||
System.err.println(buf);
|
||||
throw new AssertionFailedError(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the list of String lines contains the same lines (without a regard for the order of those lines)
|
||||
*
|
||||
* @param msg
|
||||
* the assertion message
|
||||
* @param linesExpected
|
||||
* the list of expected lines
|
||||
* @param linesActual
|
||||
* the list of actual lines
|
||||
*/
|
||||
public static void assertContainsSame(String msg, List<String> linesExpected, List<String> linesActual)
|
||||
{
|
||||
Assert.assertEquals(msg + " line count",linesExpected.size(),linesActual.size());
|
||||
|
||||
for (String expected : linesExpected)
|
||||
{
|
||||
Assert.assertTrue(msg + ": expecting to see line <" + expected + ">",linesActual.contains(expected));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public class RFC2616BIOHttpTest extends RFC2616BaseTest
|
|||
server.addConfiguration("RFC2616_Redirects.xml");
|
||||
server.addConfiguration("RFC2616_Filters.xml");
|
||||
server.addConfiguration("BIOHttp.xml");
|
||||
setUpServer(server);
|
||||
setUpServer(server, RFC2616BIOHttpTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RFC2616BIOHttpsTest extends RFC2616BaseTest
|
|||
server.addConfiguration("RFC2616_Redirects.xml");
|
||||
server.addConfiguration("RFC2616_Filters.xml");
|
||||
server.addConfiguration("BIOHttps.xml");
|
||||
setUpServer(server);
|
||||
setUpServer(server, RFC2616BIOHttpsTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,13 +31,14 @@ import java.util.TimeZone;
|
|||
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.test.StringAssert;
|
||||
import org.eclipse.jetty.test.support.StringUtil;
|
||||
import org.eclipse.jetty.test.support.TestableJettyServer;
|
||||
import org.eclipse.jetty.test.support.rawhttp.HttpResponseTester;
|
||||
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
|
||||
import org.eclipse.jetty.test.support.rawhttp.HttpTesting;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.StringAssert;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -79,16 +80,10 @@ public abstract class RFC2616BaseTest
|
|||
}
|
||||
}
|
||||
|
||||
public static void setUpServer(TestableJettyServer testableserver) throws Exception
|
||||
public static void setUpServer(TestableJettyServer testableserver, Class<?> testclazz) throws Exception
|
||||
{
|
||||
File targetDir = MavenTestingUtils.getTargetDir();
|
||||
String testId = MavenTestingUtils.getTestID();
|
||||
|
||||
File testWorkDir = new File(targetDir,"work" + File.separator + testId);
|
||||
if (!testWorkDir.exists())
|
||||
{
|
||||
testWorkDir.mkdirs();
|
||||
}
|
||||
File testWorkDir = MavenTestingUtils.getTargetTestingDir(testclazz.getName());
|
||||
FS.ensureDirExists(testWorkDir);
|
||||
|
||||
System.setProperty("java.io.tmpdir",testWorkDir.getAbsolutePath());
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RFC2616NIOHttpTest extends RFC2616BaseTest
|
|||
server.addConfiguration("RFC2616_Redirects.xml");
|
||||
server.addConfiguration("RFC2616_Filters.xml");
|
||||
server.addConfiguration("NIOHttp.xml");
|
||||
setUpServer(server);
|
||||
setUpServer(server, RFC2616NIOHttpTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RFC2616NIOHttpsTest extends RFC2616BaseTest
|
|||
server.addConfiguration("RFC2616_Redirects.xml");
|
||||
server.addConfiguration("RFC2616_Filters.xml");
|
||||
server.addConfiguration("NIOHttps.xml");
|
||||
setUpServer(server);
|
||||
setUpServer(server, RFC2616NIOHttpsTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -108,7 +108,6 @@ public class TestableJettyServer
|
|||
_properties.put(key,value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() throws Exception
|
||||
{
|
||||
XmlConfiguration last = null;
|
||||
|
@ -123,7 +122,7 @@ public class TestableJettyServer
|
|||
{
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
}
|
||||
configuration.setProperties(_properties);
|
||||
configuration.getProperties().putAll(_properties);
|
||||
obj[i] = configuration.configure();
|
||||
last = configuration;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.eclipse.jetty.http.MimeTypes;
|
|||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.eclipse.jetty.test.StringAssert;
|
||||
import org.eclipse.jetty.test.support.StringUtil;
|
||||
import org.eclipse.jetty.toolchain.test.StringAssert;
|
||||
import org.eclipse.jetty.util.ByteArrayOutputStream2;
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.jetty.server.session;
|
|||
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
import org.eclipse.jetty.server.SessionManager;
|
||||
import org.eclipse.jetty.server.session.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
/**
|
||||
* JdbcTestServer
|
||||
|
@ -25,10 +25,9 @@ public class JdbcTestServer extends AbstractTestServer
|
|||
public static final String CONNECTION_URL = "jdbc:derby:sessions;create=true";
|
||||
public static final int SAVE_INTERVAL = 1;
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
System.setProperty("derby.system.home", MavenTestingUtils.getTargetTestingDir().getAbsolutePath());
|
||||
System.setProperty("derby.system.home", MavenTestingUtils.getTargetFile("test-derby").getAbsolutePath());
|
||||
}
|
||||
|
||||
public JdbcTestServer(int port)
|
||||
|
|
|
@ -33,21 +33,25 @@
|
|||
<artifactId>jetty-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,221 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.server.session.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
/**
|
||||
* Common utility methods for working with JUnit tests cases in a maven friendly way.
|
||||
*/
|
||||
public class MavenTestingUtils
|
||||
{
|
||||
private static File basedir;
|
||||
private static File testResourcesDir;
|
||||
private static File targetDir;
|
||||
|
||||
// private static Boolean surefireRunning;
|
||||
|
||||
public static File getBasedir()
|
||||
{
|
||||
if (basedir == null)
|
||||
{
|
||||
String cwd = System.getProperty("basedir");
|
||||
|
||||
if (cwd == null)
|
||||
{
|
||||
cwd = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
basedir = new File(cwd);
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the /target directory for this project.
|
||||
*
|
||||
* @return the directory path to the target directory.
|
||||
*/
|
||||
public static File getTargetDir()
|
||||
{
|
||||
if (targetDir == null)
|
||||
{
|
||||
targetDir = new File(getBasedir(),"target");
|
||||
PathAssert.assertDirExists("Target Dir",targetDir);
|
||||
}
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link File} object for a path in the /target directory.
|
||||
*
|
||||
* @param path
|
||||
* the path desired, no validation of existence is performed.
|
||||
* @return the File to the path.
|
||||
*/
|
||||
public static File getTargetFile(String path)
|
||||
{
|
||||
return new File(getTargetDir(),path.replace("/",File.separator));
|
||||
}
|
||||
|
||||
public static File getTargetTestingDir()
|
||||
{
|
||||
File dir = new File(getTargetDir(),"testing");
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the JUnit 3.x {@link TestCase#getName()} to make itself unique.
|
||||
*
|
||||
* @param test
|
||||
* the junit 3.x testcase to base this new directory on.
|
||||
* @return the File path to the testcase specific testing directory underneath the
|
||||
* <code>${basedir}/target</code> sub directory
|
||||
*/
|
||||
public static File getTargetTestingDir(TestCase test)
|
||||
{
|
||||
return getTargetTestingDir(test.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir in /target/ that uses the an arbitrary name.
|
||||
*
|
||||
* @param testname
|
||||
* the testname to create directory against.
|
||||
* @return the File path to the testname sepecific testing directory underneath the
|
||||
* <code>${basedir}/target</code> sub directory
|
||||
*/
|
||||
public static File getTargetTestingDir(String testname)
|
||||
{
|
||||
File dir = new File(getTargetDir(),"test-" + testname);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a dir)
|
||||
* @return the dir in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceDir(String name)
|
||||
{
|
||||
File dir = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertDirExists("Test Resource Dir",dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a file)
|
||||
* @return the file in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceFile(String name)
|
||||
{
|
||||
File file = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertFileExists("Test Resource File",file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path resource (File or Dir) from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist)
|
||||
* @return the path in src/test/resource
|
||||
*/
|
||||
public static File getTestResourcePath(String name)
|
||||
{
|
||||
File path = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertExists("Test Resource Path",path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the src/test/resource directory
|
||||
*
|
||||
* @return the directory {@link File} to the src/test/resources directory
|
||||
*/
|
||||
public static File getTestResourcesDir()
|
||||
{
|
||||
if (testResourcesDir == null)
|
||||
{
|
||||
testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator));
|
||||
PathAssert.assertDirExists("Test Resources Dir",testResourcesDir);
|
||||
}
|
||||
return testResourcesDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the contents of a file into a String and return it.
|
||||
*
|
||||
* @param file
|
||||
* the file to read.
|
||||
* @return the contents of the file.
|
||||
* @throws IOException
|
||||
* if unable to read the file.
|
||||
*/
|
||||
public static String readToString(File file) throws IOException
|
||||
{
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
return IO.toString(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTestID()
|
||||
{
|
||||
StackTraceElement stacked[] = new Throwable().getStackTrace();
|
||||
|
||||
String name = null;
|
||||
|
||||
for(StackTraceElement stack: stacked) {
|
||||
if(stack.getClassName().endsWith("Test"))
|
||||
{
|
||||
name = stack.getClassName();
|
||||
if (stack.getMethodName().startsWith("test"))
|
||||
{
|
||||
return stack.getClassName() + "#" + stack.getMethodName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(name == null)
|
||||
{
|
||||
return "Unidentified_Test";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.server.session.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
public class PathAssert
|
||||
{
|
||||
public static void assertDirExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory());
|
||||
}
|
||||
|
||||
public static void assertFileExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile());
|
||||
}
|
||||
|
||||
public static void assertExists(String msg, File path)
|
||||
{
|
||||
Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue