367635: Add test for parsing start.d files, small changes
This commit is contained in:
parent
90e9358ea5
commit
48438dc914
|
@ -123,30 +123,35 @@ 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));
|
||||
|
||||
File start_d = new File(_jettyHome,"start.d");
|
||||
if (start_d.isDirectory())
|
||||
{
|
||||
File[] inis = start_d.listFiles(new FilenameFilter()
|
||||
{
|
||||
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);
|
||||
arguments.addAll(0,parseStartIniFiles());
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
return name.toLowerCase().endsWith(".ini");
|
||||
}
|
||||
});
|
||||
Arrays.sort(inis);
|
||||
for (File i : inis)
|
||||
ini_args.addAll(loadStartIni(i));
|
||||
}
|
||||
return ini_args;
|
||||
}
|
||||
|
||||
public List<String> processCommandLine(List<String> arguments) throws Exception
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue