Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2012-08-29 09:31:24 +0000
committerSimone Bordet2012-08-29 09:49:41 +0000
commitdd8958ffe8e4ee53d4fc10976cff724046eb4d6d (patch)
treecb10d791e440c232e5751a1d2cba0914a4ef97c1 /jetty-deploy/src
parentc3abbe5ecb68e36c3d8bca239ce1edc0b6daa5e9 (diff)
downloadorg.eclipse.jetty.project-dd8958ffe8e4ee53d4fc10976cff724046eb4d6d.tar.gz
org.eclipse.jetty.project-dd8958ffe8e4ee53d4fc10976cff724046eb4d6d.tar.xz
org.eclipse.jetty.project-dd8958ffe8e4ee53d4fc10976cff724046eb4d6d.zip
Jetty9 - Fixed parsing in case of a <Configure> element without <Arg> elements,
which may happen if the configuration is not the one that creates the Server instance, but just adds additional configuration to it. Also took the chance to JDK7-ify the code and remove old cruft and unused code.
Diffstat (limited to 'jetty-deploy/src')
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java6
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java17
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java75
3 files changed, 48 insertions, 50 deletions
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
index 70962fc961..982907a7c7 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java
@@ -104,7 +104,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
}
while(_scans.get()<scan);
}
-
+
/**
* Simple webapp deployment after startup of server.
*/
@@ -153,7 +153,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
Assume.assumeTrue(!OS.IS_WINDOWS);
Assume.assumeTrue(!OS.IS_OSX); // build server has issues with finding itself apparently
-
+
jetty.copyWebapp("foo-webapp-1.war","foo.war");
jetty.copyContext("foo.xml","foo.xml");
@@ -166,7 +166,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
jetty.assertResponseContains("/foo/info","FooServlet-1");
waitForDirectoryScan();
- System.out.println("Updating war files");
+ System.err.println("Updating war files");
jetty.copyContext("foo.xml","foo.xml"); // essentially "touch" the context xml
jetty.copyWebapp("foo-webapp-2.war","foo.war");
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
index 51c83d61a6..65fbf73187 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java
@@ -69,7 +69,7 @@ public class WebAppProviderTest
File workDir = jetty.getJettyDir("workish");
System.err.println("workDir="+workDir);
-
+
// Test for regressions
assertDirNotExists("root of work directory",workDir,"webinf");
assertDirNotExists("root of work directory",workDir,"jsp");
@@ -80,16 +80,19 @@ public class WebAppProviderTest
private static boolean hasJettyGeneratedPath(File basedir, String expectedWarFilename)
{
- for (File path : basedir.listFiles())
+ File[] paths = basedir.listFiles();
+ if (paths != null)
{
- if (path.exists() && path.isDirectory() && path.getName().startsWith("jetty-") && path.getName().contains(expectedWarFilename))
+ for (File path : paths)
{
- System.out.println("Found expected generated directory: " + path);
- return true;
+ if (path.exists() && path.isDirectory() && path.getName().startsWith("jetty-") && path.getName().contains(expectedWarFilename))
+ {
+ System.err.println("Found expected generated directory: " + path);
+ return true;
+ }
}
+ System.err.println("did not find "+expectedWarFilename+" in "+Arrays.asList(paths));
}
-
- System.err.println("did not find "+expectedWarFilename+" in "+Arrays.asList(basedir.listFiles()));
return false;
}
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java
index 12a5626974..2afd52841f 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java
@@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
@@ -56,7 +55,7 @@ import org.junit.Assert;
public class XmlConfiguredJetty
{
private List<URL> _xmlConfigurations;
- private Map<String,String> _properties = new HashMap<String,String>();
+ private Map<String,String> _properties = new HashMap<>();
private Server _server;
private int _serverPort;
private String _scheme = HttpScheme.HTTP.asString();
@@ -64,7 +63,7 @@ public class XmlConfiguredJetty
public XmlConfiguredJetty(TestingDir testdir) throws IOException
{
- _xmlConfigurations = new ArrayList<URL>();
+ _xmlConfigurations = new ArrayList<>();
Properties properties = new Properties();
String jettyHomeBase = testdir.getDir().getAbsolutePath();
@@ -131,12 +130,12 @@ public class XmlConfiguredJetty
FileOutputStream out = new FileOutputStream(testConfig);
properties.store(out,"Generated by " + XmlConfiguredJetty.class.getName());
for (Object key:properties.keySet())
- _properties.put(String.valueOf(key),String.valueOf(properties.get(key)));
+ setProperty(String.valueOf(key),String.valueOf(properties.get(key)));
}
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
{
- _xmlConfigurations.add(Resource.toURL(xmlConfigFile));
+ addConfiguration(Resource.toURL(xmlConfigFile));
}
public void addConfiguration(String testConfigName) throws MalformedURLException
@@ -156,7 +155,7 @@ public class XmlConfiguredJetty
{
for (WebAppContext context : contexts)
{
- System.out.println("WebAppContext should not exist:\n" + context);
+ System.err.println("WebAppContext should not exist:\n" + context);
}
Assert.assertEquals("Contexts.size",0,contexts.size());
}
@@ -183,7 +182,7 @@ public class XmlConfiguredJetty
public void assertResponseContains(String path, String needle) throws IOException
{
- System.out.println("Issuing request to " + path);
+ System.err.println("Issuing request to " + path);
String content = getResponse(path);
Assert.assertTrue("Content should contain <" + needle + ">, instead got <" + content + ">",content.contains(needle));
}
@@ -193,15 +192,15 @@ public class XmlConfiguredJetty
List<WebAppContext> contexts = getWebAppContexts();
if (expectedContextPaths.length != contexts.size())
{
- System.out.println("## Expected Contexts");
+ System.err.println("## Expected Contexts");
for (String expected : expectedContextPaths)
{
- System.out.println(expected);
+ System.err.println(expected);
}
- System.out.println("## Actual Contexts");
+ System.err.println("## Actual Contexts");
for (WebAppContext context : contexts)
{
- System.out.printf("%s ## %s%n",context.getContextPath(),context);
+ System.err.printf("%s ## %s%n",context.getContextPath(),context);
}
Assert.assertEquals("Contexts.size",expectedContextPaths.length,contexts.size());
}
@@ -223,7 +222,7 @@ public class XmlConfiguredJetty
public void copyContext(String srcName, String destName) throws IOException
{
- System.out.printf("Copying Context: %s -> %s%n",srcName,destName);
+ System.err.printf("Copying Context: %s -> %s%n",srcName,destName);
File srcDir = MavenTestingUtils.getTestResourceDir("contexts");
File destDir = new File(_jettyHome,"contexts");
@@ -238,13 +237,13 @@ public class XmlConfiguredJetty
PathAssert.assertFileExists(type + " File",srcFile);
IO.copyFile(srcFile,destFile);
PathAssert.assertFileExists(type + " File",destFile);
- System.out.printf("Copy %s: %s%n To %s: %s%n",type,srcFile,type,destFile);
- System.out.printf("Destination Exists: %s - %s%n",destFile.exists(),destFile);
+ System.err.printf("Copy %s: %s%n To %s: %s%n",type,srcFile,type,destFile);
+ System.err.printf("Destination Exists: %s - %s%n",destFile.exists(),destFile);
}
public void copyWebapp(String srcName, String destName) throws IOException
{
- System.out.printf("Copying Webapp: %s -> %s%n",srcName,destName);
+ System.err.printf("Copying Webapp: %s -> %s%n",srcName,destName);
File srcDir = MavenTestingUtils.getTestResourceDir("webapps");
File destDir = new File(_jettyHome,"webapps");
@@ -256,33 +255,32 @@ public class XmlConfiguredJetty
private void deleteContents(File dir)
{
- System.out.printf("Delete (dir) %s/%n",dir);
+ System.err.printf("Delete (dir) %s/%n",dir);
if (!dir.exists())
{
return;
}
- for (File file : dir.listFiles())
+ File[] files = dir.listFiles();
+ if (files != null)
{
- // Safety measure. only recursively delete within target directory.
- if (file.isDirectory() && file.getAbsolutePath().contains("target" + File.separator))
+ for (File file : files)
{
- deleteContents(file);
- Assert.assertTrue("Delete failed: " + file.getAbsolutePath(),file.delete());
- }
- else
- {
- System.out.printf("Delete (file) %s%n",file);
- Assert.assertTrue("Delete failed: " + file.getAbsolutePath(),file.delete());
+ // Safety measure. only recursively delete within target directory.
+ if (file.isDirectory() && file.getAbsolutePath().contains("target" + File.separator))
+ {
+ deleteContents(file);
+ Assert.assertTrue("Delete failed: " + file.getAbsolutePath(),file.delete());
+ }
+ else
+ {
+ System.err.printf("Delete (file) %s%n",file);
+ Assert.assertTrue("Delete failed: " + file.getAbsolutePath(),file.delete());
+ }
}
}
}
- public DeploymentManager getActiveDeploymentManager()
- {
- return _server.getBean(DeploymentManager.class);
- }
-
public File getJettyDir(String name)
{
return new File(_jettyHome,name);
@@ -310,18 +308,18 @@ public class XmlConfiguredJetty
public URI getServerURI() throws UnknownHostException
{
- StringBuffer uri = new StringBuffer();
- uri.append(this._scheme).append("://");
+ StringBuilder uri = new StringBuilder();
+ uri.append(getScheme()).append("://");
uri.append(InetAddress.getLocalHost().getHostAddress());
- uri.append(":").append(this._serverPort);
+ uri.append(":").append(getServerPort());
return URI.create(uri.toString());
}
public List<WebAppContext> getWebAppContexts()
{
- List<WebAppContext> contexts = new ArrayList<WebAppContext>();
+ List<WebAppContext> contexts = new ArrayList<>();
HandlerCollection handlers = (HandlerCollection)_server.getHandler();
- System.out.println(_server.dump());
+ System.err.println(_server.dump());
Handler children[] = handlers.getChildHandlers();
for (Handler handler : children)
@@ -347,9 +345,7 @@ public class XmlConfiguredJetty
URL configURL = this._xmlConfigurations.get(i);
XmlConfiguration configuration = new XmlConfiguration(configURL);
if (last != null)
- {
configuration.getIdMap().putAll(last.getIdMap());
- }
configuration.getProperties().putAll(_properties);
obj[i] = configuration.configure();
last = configuration;
@@ -425,7 +421,7 @@ public class XmlConfiguredJetty
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + _serverPort + ">",(1 <= this._serverPort) && (this._serverPort <= 65535));
// Uncomment to have server start and continue to run (without exiting)
- // System.out.printf("Listening to port %d%n",this.serverPort);
+ // System.err.printf("Listening to port %d%n",this.serverPort);
// server.join();
}
@@ -433,5 +429,4 @@ public class XmlConfiguredJetty
{
_server.stop();
}
-
}

Back to the top