summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorThomas Becker2012-01-02 11:50:57 (EST)
committer Greg Wilkins2012-01-08 19:23:24 (EST)
commit48438dc914631dbcbdead46ae3076e4d627ef0c0 (patch)
tree16da2088f00a9ba067c48e7b59019e3564acf3a2
parent90e9358ea5f62b78f1b11fe607b333b500373cb3 (diff)
downloadorg.eclipse.jetty.project-48438dc914631dbcbdead46ae3076e4d627ef0c0.zip
org.eclipse.jetty.project-48438dc914631dbcbdead46ae3076e4d627ef0c0.tar.gz
org.eclipse.jetty.project-48438dc914631dbcbdead46ae3076e4d627ef0c0.tar.bz2
367635: Add test for parsing start.d files, small changes
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java43
-rw-r--r--jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt16
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java15
3 files changed, 42 insertions, 32 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index c42b93d..6275baa 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -123,29 +123,34 @@ public class Main
// if no non-option inis, add the start.ini and start.d
if (!ini)
{
- List<String> ini_args=new ArrayList<String>();
- File start_ini = new File(_jettyHome,"start.ini");
- if (start_ini.exists())
- ini_args.addAll(loadStartIni(start_ini));
+ arguments.addAll(0,parseStartIniFiles());
+ }
+
+ return arguments;
+ }
- File start_d = new File(_jettyHome,"start.d");
- if (start_d.isDirectory())
+ List<String> parseStartIniFiles()
+ {
+ List<String> ini_args=new ArrayList<String>();
+ File start_ini = new File(_jettyHome,"start.ini");
+ if (start_ini.exists())
+ ini_args.addAll(loadStartIni(start_ini));
+
+ File start_d = new File(_jettyHome,"start.d");
+ if (start_d.isDirectory())
+ {
+ File[] inis = start_d.listFiles(new FilenameFilter()
{
- File[] inis = start_d.listFiles(new FilenameFilter()
+ public boolean accept(File dir, String name)
{
- public boolean accept(File dir, String name)
- {
- return name.toLowerCase().endsWith(".ini");
- }
- });
- Arrays.sort(inis);
- for (File i : inis)
- ini_args.addAll(loadStartIni(i));
- }
- arguments.addAll(0,ini_args);
+ return name.toLowerCase().endsWith(".ini");
+ }
+ });
+ Arrays.sort(inis);
+ for (File i : inis)
+ ini_args.addAll(loadStartIni(i));
}
-
- return arguments;
+ return ini_args;
}
public List<String> processCommandLine(List<String> arguments) throws Exception
diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
index c4c85c4..41b0107 100644
--- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
+++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
@@ -20,7 +20,7 @@ Command Line Options:
when the start.ini includes -X or -D arguments.
--exec Run the generated command line (see --dry-run) in
- a sub processes. This can be used when start.ini
+ a sub process. This can be used when start.ini
contains -X or -D arguments, but creates an extra
JVM instance.
@@ -36,8 +36,10 @@ Command Line Options:
--ini=<file> Load command line arguments from a file. If
no --ini options are specified, then the
- start.ini file will be read if it exists.
- A --ini option with no file indicates that
+ start.ini file will be read if it exists in
+ jetty.home. If specified jetty.home/start.ini
+ and additional .ini files in jetty.home/start.d/
+ will NOT be read. A --ini option with no file indicates that
start.ini should not be read.
--pre=<file> Specify a configuration file that is to be processed
@@ -116,10 +118,10 @@ Available Configurations:
Defaults:
A start.ini file may be used to specify default arguments to start.jar,
which are used if no command line arguments are provided and override
- the defaults in the start.config file. If the directory start.d exists,
- then multiple *.ini files will be read from that directory in alphabetical
- order. If --ini options are provided on the command line, then start.ini
- and start.d will not be read.
+ the defaults in the start.config file. If the directory jetty.home/start.d
+ exists, then multiple *.ini files will be read from that directory in
+ alphabetical order. If --ini options are provided on the command line,
+ then start.ini and start.d will NOT be read.
The current start.ini arguments are:
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
index 246771b..8e2f1f0 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
@@ -15,7 +15,7 @@ package org.eclipse.jetty.start;
import static org.junit.Assert.assertEquals;
-import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.util.List;
@@ -39,15 +39,18 @@ public class MainTest
/**
* Test method for {@link org.eclipse.jetty.start.StartIniParser#loadStartIni(java.lang.String)}.
+ * @throws IOException
*/
@Test
- public void testLoadStartIni()
+ public void testLoadStartIni() throws IOException
{
- URL startIni = this.getClass().getResource("/jetty.home/start.ini");
- String startIniFileName = startIni.getFile();
- List<String> args = Main.loadStartIni(new File(startIniFileName));
- assertEquals("Expected 5 uncommented lines in start.ini",5,args.size());
+ URL startIni = this.getClass().getResource("/jetty.home/");
+ System.setProperty("jetty.home",startIni.getFile());
+ Main main = new Main();
+ List<String> args = main.parseStartIniFiles();
+ assertEquals("Expected 5 uncommented lines in start.ini",9,args.size());
assertEquals("First uncommented line in start.ini doesn't match expected result","OPTIONS=Server,jsp,resources,websocket,ext",args.get(0));
+ assertEquals("Last uncommented line in start.ini doesn't match expected result","etc/jetty-testrealm.xml",args.get(8));
}
@Test