Merge branch `jetty-9.4.x` into `jetty-10.0.x`
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
commit
68a9498092
|
@ -36,9 +36,8 @@ public class FileServerXml
|
|||
{
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
Resource fileserverXml = Resource.newSystemResource("fileserver.xml");
|
||||
XmlConfiguration configuration = new XmlConfiguration(
|
||||
fileserverXml.getInputStream());
|
||||
Resource fileServerXml = Resource.newSystemResource("fileserver.xml");
|
||||
XmlConfiguration configuration = new XmlConfiguration(fileServerXml);
|
||||
Server server = (Server) configuration.configure();
|
||||
server.start();
|
||||
server.join();
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.eclipse.jetty.servlet.ServletMapping;
|
|||
import org.eclipse.jetty.servlet.Source;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
|
@ -608,7 +609,7 @@ public class AntWebAppContext extends WebAppContext
|
|||
//apply a context xml file if one was supplied
|
||||
if (contextXml != null)
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(contextXml));
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(new PathResource(contextXml));
|
||||
TaskLog.log("Applying context xml file "+contextXml);
|
||||
xmlConfiguration.configure(this);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -451,7 +452,7 @@ public class ServerProxyImpl implements ServerProxy
|
|||
XmlConfiguration configuration;
|
||||
try
|
||||
{
|
||||
configuration = new XmlConfiguration(Resource.toURL(jettyXml));
|
||||
configuration = new XmlConfiguration(new PathResource(jettyXml));
|
||||
configuration.configure(server);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
|
|
|
@ -92,7 +92,7 @@ public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
|||
|
||||
if (globalContextSettings.exists())
|
||||
{
|
||||
XmlConfiguration jettyXmlConfig = new XmlConfiguration(globalContextSettings.getInputStream());
|
||||
XmlConfiguration jettyXmlConfig = new XmlConfiguration(globalContextSettings);
|
||||
Resource resource = Resource.newResource(app.getOriginId());
|
||||
app.getDeploymentManager().scope(jettyXmlConfig,resource);
|
||||
WebAppClassLoader.runWithServerClassAccess(()->{jettyXmlConfig.configure(context);return null;});
|
||||
|
|
|
@ -265,7 +265,7 @@ public class WebAppProvider extends ScanningAppProvider
|
|||
|
||||
if (resource.exists() && FileID.isXmlFile(file))
|
||||
{
|
||||
XmlConfiguration xmlc = new XmlConfiguration(resource.getURI().toURL())
|
||||
XmlConfiguration xmlc = new XmlConfiguration(resource)
|
||||
{
|
||||
@Override
|
||||
public void initializeDefaults(Object context)
|
||||
|
|
|
@ -18,13 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.deploy.test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -53,17 +46,25 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|||
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
* Allows for setting up a Jetty server for testing based on XML configuration files.
|
||||
*/
|
||||
public class XmlConfiguredJetty
|
||||
{
|
||||
private List<URL> _xmlConfigurations;
|
||||
private List<Resource> _xmlConfigurations;
|
||||
private Map<String,String> _properties = new HashMap<>();
|
||||
private Server _server;
|
||||
private int _serverPort;
|
||||
|
@ -137,9 +138,9 @@ public class XmlConfiguredJetty
|
|||
setProperty(String.valueOf(key),String.valueOf(properties.get(key)));
|
||||
}
|
||||
|
||||
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
|
||||
public void addConfiguration(File xmlConfigFile)
|
||||
{
|
||||
addConfiguration(Resource.toURL(xmlConfigFile));
|
||||
addConfiguration(new PathResource(xmlConfigFile));
|
||||
}
|
||||
|
||||
public void addConfiguration(String testConfigName) throws MalformedURLException
|
||||
|
@ -147,7 +148,7 @@ public class XmlConfiguredJetty
|
|||
addConfiguration(MavenTestingUtils.getTestResourceFile(testConfigName));
|
||||
}
|
||||
|
||||
public void addConfiguration(URL xmlConfig)
|
||||
public void addConfiguration(Resource xmlConfig)
|
||||
{
|
||||
_xmlConfigurations.add(xmlConfig);
|
||||
}
|
||||
|
@ -330,8 +331,8 @@ public class XmlConfiguredJetty
|
|||
// Configure everything
|
||||
for (int i = 0; i < this._xmlConfigurations.size(); i++)
|
||||
{
|
||||
URL configURL = this._xmlConfigurations.get(i);
|
||||
XmlConfiguration configuration = new XmlConfiguration(configURL);
|
||||
Resource configResource = this._xmlConfigurations.get(i);
|
||||
XmlConfiguration configuration = new XmlConfiguration(configResource);
|
||||
if (last != null)
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
configuration.getProperties().putAll(_properties);
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.util.PathWatcher;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
|
@ -556,7 +557,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
contextXml = path.toFile().getAbsolutePath();
|
||||
}
|
||||
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(path.toFile()));
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(new PathResource(path));
|
||||
getLog().info("Applying context xml file "+contextXml);
|
||||
xmlConfiguration.configure(webApp);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.webapp.Configurations;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
@ -194,7 +193,7 @@ public class ServerSupport
|
|||
PluginLog.getLog().info( "Configuring Jetty from xml configuration file = " + xmlFile.getCanonicalPath() );
|
||||
|
||||
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.toURL(xmlFile));
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(new PathResource(xmlFile));
|
||||
|
||||
//add in any properties
|
||||
if (properties != null)
|
||||
|
|
|
@ -19,13 +19,9 @@
|
|||
|
||||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -253,7 +249,7 @@ public class WebAppPropertyConverter
|
|||
str = props.getProperty("context.xml");
|
||||
if (!StringUtil.isBlank(str))
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(str).getURI().toURL());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(str));
|
||||
xmlConfiguration.getIdMap().put("Server",server);
|
||||
//add in any properties
|
||||
if (jettyProperties != null)
|
||||
|
|
|
@ -158,7 +158,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
|||
{
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(res.getInputStream());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(res);
|
||||
HashMap properties = new HashMap();
|
||||
//put the server instance in
|
||||
properties.put("Server", getServerInstanceWrapper().getServer());
|
||||
|
|
|
@ -414,7 +414,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
// Apply it just as the standard jetty ContextProvider would do
|
||||
LOG.info("Applying " + contextXmlUri + " to " + _webApp);
|
||||
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXmlUri);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(contextXmlUri));
|
||||
WebAppClassLoader.runWithServerClassAccess(()->
|
||||
{
|
||||
HashMap<String,String> properties = new HashMap<>();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.osgi.boot.internal.serverfactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -54,6 +53,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -142,10 +142,10 @@ public class ServerInstanceWrapper
|
|||
|
||||
for (URL jettyConfiguration : jettyConfigurations)
|
||||
{
|
||||
try(InputStream in = jettyConfiguration.openStream())
|
||||
try
|
||||
{
|
||||
// Execute a Jetty configuration file
|
||||
XmlConfiguration config = new XmlConfiguration(in);
|
||||
XmlConfiguration config = new XmlConfiguration(Resource.newResource(jettyConfiguration));
|
||||
|
||||
config.getIdMap().putAll(id_map);
|
||||
config.getProperties().putAll(properties);
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
@ -39,6 +38,7 @@ import org.eclipse.jetty.plus.jndi.EnvEntry;
|
|||
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.FragmentConfiguration;
|
||||
import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
|
||||
|
@ -57,7 +57,7 @@ public class EnvConfiguration extends AbstractConfiguration
|
|||
private static final Logger LOG = Log.getLogger(EnvConfiguration.class);
|
||||
|
||||
private static final String JETTY_ENV_BINDINGS = "org.eclipse.jetty.jndi.EnvConfiguration";
|
||||
private URL jettyEnvXmlUrl;
|
||||
private Resource jettyEnvXmlResource;
|
||||
|
||||
public EnvConfiguration()
|
||||
{
|
||||
|
@ -66,9 +66,14 @@ public class EnvConfiguration extends AbstractConfiguration
|
|||
protectAndExpose("org.eclipse.jetty.jndi.");
|
||||
}
|
||||
|
||||
public void setJettyEnvResource(Resource resource)
|
||||
{
|
||||
this.jettyEnvXmlResource = resource;
|
||||
}
|
||||
|
||||
public void setJettyEnvXml (URL url)
|
||||
{
|
||||
this.jettyEnvXmlUrl = url;
|
||||
this.jettyEnvXmlResource = Resource.newResource(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +91,7 @@ public class EnvConfiguration extends AbstractConfiguration
|
|||
|
||||
//check to see if an explicit file has been set, if not,
|
||||
//look in WEB-INF/jetty-env.xml
|
||||
if (jettyEnvXmlUrl == null)
|
||||
if (jettyEnvXmlResource == null)
|
||||
{
|
||||
//look for a file called WEB-INF/jetty-env.xml
|
||||
//and process it if it exists
|
||||
|
@ -96,12 +101,12 @@ public class EnvConfiguration extends AbstractConfiguration
|
|||
org.eclipse.jetty.util.resource.Resource jettyEnv = web_inf.addPath("jetty-env.xml");
|
||||
if(jettyEnv.exists())
|
||||
{
|
||||
jettyEnvXmlUrl = jettyEnv.getURI().toURL();
|
||||
jettyEnvXmlResource = jettyEnv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jettyEnvXmlUrl != null)
|
||||
if (jettyEnvXmlResource != null)
|
||||
{
|
||||
synchronized (localContextRoot.getRoot())
|
||||
{
|
||||
|
@ -125,7 +130,7 @@ public class EnvConfiguration extends AbstractConfiguration
|
|||
try
|
||||
{
|
||||
localContextRoot.getRoot().addListener(listener);
|
||||
XmlConfiguration configuration = new XmlConfiguration(jettyEnvXmlUrl);
|
||||
XmlConfiguration configuration = new XmlConfiguration(jettyEnvXmlResource);
|
||||
configuration.setJettyStandardIdsAndProperties(context.getServer(), null);
|
||||
WebAppClassLoader.runWithServerClassAccess(()->{configuration.configure(context);return null;});
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class PreconfigureQuickStartWar
|
|||
{
|
||||
if (xml.isDirectory() || !xml.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml"))
|
||||
error("Bad context.xml: "+xml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(xml.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(xml);
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
webapp.setResourceBase(dir.getFile().getAbsolutePath());
|
||||
|
|
|
@ -327,7 +327,7 @@ public class Runner
|
|||
for (String cfg : _configFiles)
|
||||
{
|
||||
try (Resource resource = Resource.newResource(cfg)) {
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(resource.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(resource);
|
||||
xmlConfiguration.configure(_server);
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ public class Runner
|
|||
if (!ctx.isDirectory() && ctx.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml"))
|
||||
{
|
||||
// It is a context config file
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(ctx.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(ctx);
|
||||
xmlConfiguration.getIdMap().put("Server", _server);
|
||||
ContextHandler handler = (ContextHandler) xmlConfiguration.configure();
|
||||
if (contextPathSet)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.eclipse.jetty.spring;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
@ -69,18 +68,25 @@ public class SpringConfigurationProcessor implements ConfigurationProcessor
|
|||
private String _main;
|
||||
|
||||
@Override
|
||||
public void init(URL url, XmlParser.Node config, XmlConfiguration configuration)
|
||||
public void init(org.eclipse.jetty.util.resource.Resource jettyResource, XmlParser.Node config, XmlConfiguration configuration)
|
||||
{
|
||||
try
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
Resource resource = url != null
|
||||
? new UrlResource(url)
|
||||
: new ByteArrayResource(("" +
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" +
|
||||
config).getBytes(StandardCharsets.UTF_8));
|
||||
Resource springResource;
|
||||
|
||||
if (jettyResource != null)
|
||||
{
|
||||
springResource = new UrlResource(jettyResource.getURI());
|
||||
}
|
||||
else
|
||||
{
|
||||
springResource = new ByteArrayResource(("" +
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" +
|
||||
config).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
_beanFactory = new DefaultListableBeanFactory()
|
||||
{
|
||||
|
@ -92,7 +98,7 @@ public class SpringConfigurationProcessor implements ConfigurationProcessor
|
|||
}
|
||||
};
|
||||
|
||||
new XmlBeanDefinitionReader(_beanFactory).loadBeanDefinitions(resource);
|
||||
new XmlBeanDefinitionReader(_beanFactory).loadBeanDefinitions(springResource);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.spring;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -29,16 +26,20 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class SpringXmlConfigurationTest
|
||||
{
|
||||
protected String _configure="org/eclipse/jetty/spring/configure.xml";
|
||||
|
||||
@BeforeEach
|
||||
public void init() throws Exception
|
||||
public void init()
|
||||
{
|
||||
// Jetty's XML configuration will make use of java.util.ServiceLoader
|
||||
// to load the proper ConfigurationProcessorFactory, so these tests
|
||||
|
@ -60,7 +61,7 @@ public class SpringXmlConfigurationTest
|
|||
TestConfiguration.VALUE=77;
|
||||
|
||||
URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url));
|
||||
|
||||
Map<String,String> properties = new HashMap<>();
|
||||
properties.put("test", "xxx");
|
||||
|
@ -100,7 +101,7 @@ public class SpringXmlConfigurationTest
|
|||
|
||||
URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url)
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url))
|
||||
{
|
||||
@Override
|
||||
public void initializeDefaults(Object object)
|
||||
|
@ -147,7 +148,7 @@ public class SpringXmlConfigurationTest
|
|||
public void testJettyXml() throws Exception
|
||||
{
|
||||
URL url = SpringXmlConfigurationTest.class.getClassLoader().getResource("org/eclipse/jetty/spring/jetty.xml");
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url));
|
||||
|
||||
Server server = (Server)configuration.configure();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
|||
|
||||
Object xml_attr=context.getAttribute(XML_CONFIGURATION);
|
||||
context.removeAttribute(XML_CONFIGURATION);
|
||||
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration?(XmlConfiguration)xml_attr:new XmlConfiguration(jetty.getURI().toURL());
|
||||
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration?(XmlConfiguration)xml_attr:new XmlConfiguration(jetty);
|
||||
|
||||
setupXmlConfiguration(context, jetty_config, web_inf);
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.core.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
class XmlHttpClientProvider implements HttpClientProvider
|
||||
|
@ -35,11 +35,11 @@ class XmlHttpClientProvider implements HttpClientProvider
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try (InputStream in = resource.openStream())
|
||||
|
||||
try
|
||||
{
|
||||
XmlConfiguration configuration = new XmlConfiguration(in);
|
||||
return (HttpClient)configuration.configure();
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(resource));
|
||||
return (HttpClient) configuration.configure();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
|
|
@ -18,21 +18,28 @@
|
|||
|
||||
package org.eclipse.jetty.xml;
|
||||
|
||||
import java.net.URL;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
* A ConfigurationProcessor for non XmlConfiguration format files.
|
||||
* <p>
|
||||
* A file in non-XmlConfiguration file format may be processed by a {@link ConfigurationProcessor}
|
||||
* instance that is returned from a {@link ConfigurationProcessorFactory} instance discovered by the
|
||||
* <code>ServiceLoader</code> mechanism. This is used to allow spring configuration files to be used instead of
|
||||
* jetty.xml
|
||||
*
|
||||
* {@code ServiceLoader} mechanism. This is used to allow spring configuration files to be used instead of
|
||||
* {@code jetty.xml}
|
||||
*/
|
||||
public interface ConfigurationProcessor
|
||||
{
|
||||
public void init(URL url, XmlParser.Node root, XmlConfiguration configuration);
|
||||
|
||||
public Object configure( Object obj) throws Exception;
|
||||
public Object configure() throws Exception;
|
||||
/**
|
||||
* Initialize a ConfigurationProcessor from provided Resource and XML
|
||||
*
|
||||
* @param resource the resource being read
|
||||
* @param root the parsed XML root node for the resource
|
||||
* @param configuration the configuration being used (typically for ref IDs)
|
||||
*/
|
||||
void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration);
|
||||
|
||||
Object configure(Object obj) throws Exception;
|
||||
|
||||
Object configure() throws Exception;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.xml;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -30,7 +29,6 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -63,7 +61,6 @@ import org.eclipse.jetty.util.component.LifeCycle;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
|
@ -101,13 +98,13 @@ public class XmlConfiguration
|
|||
|
||||
private static XmlParser initParser()
|
||||
{
|
||||
ClassLoader loader = XmlConfiguration.class.getClassLoader();
|
||||
XmlParser parser = new XmlParser();
|
||||
|
||||
Class<?> klass = XmlConfiguration.class;
|
||||
URL config60 = klass.getResource("configure_6_0.dtd");
|
||||
URL config76 = klass.getResource("configure_7_6.dtd");
|
||||
URL config90 = klass.getResource("configure_9_0.dtd");
|
||||
URL config93 = klass.getResource("configure_9_3.dtd");
|
||||
URL config60 = loader.getResource("configure_6_0.dtd");
|
||||
URL config76 = loader.getResource("configure_7_6.dtd");
|
||||
URL config90 = loader.getResource("configure_9_0.dtd");
|
||||
URL config93 = loader.getResource("configure_9_3.dtd");
|
||||
parser.redirectEntity("configure.dtd",config93);
|
||||
parser.redirectEntity("configure_1_0.dtd",config60);
|
||||
parser.redirectEntity("configure_1_1.dtd",config60);
|
||||
|
@ -185,81 +182,38 @@ public class XmlConfiguration
|
|||
|
||||
private final Map<String, Object> _idMap = new HashMap<>();
|
||||
private final Map<String, String> _propertyMap = new HashMap<>();
|
||||
private final URL _url;
|
||||
private final Resource _location;
|
||||
private final String _dtd;
|
||||
private ConfigurationProcessor _processor;
|
||||
|
||||
/**
|
||||
* Reads and parses the XML configuration file.
|
||||
*
|
||||
* @param configuration the URL of the XML configuration
|
||||
* @param resource the Resource to the XML configuration
|
||||
* @throws IOException if the configuration could not be read
|
||||
* @throws SAXException if the configuration could not be parsed
|
||||
*/
|
||||
public XmlConfiguration(URL configuration) throws SAXException, IOException
|
||||
public XmlConfiguration(Resource resource) throws SAXException, IOException
|
||||
{
|
||||
synchronized (__parser)
|
||||
{
|
||||
_url = configuration;
|
||||
setConfig(__parser.parse(configuration.toString()));
|
||||
_location = resource;
|
||||
try(InputStream inputStream = resource.getInputStream())
|
||||
{
|
||||
setConfig(__parser.parse(inputStream));
|
||||
}
|
||||
_dtd = __parser.getDTD();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and parses the XML configuration file.
|
||||
*
|
||||
* @param configuration the URI of the XML configuration
|
||||
* @throws IOException if the configuration could not be read
|
||||
* @throws SAXException if the configuration could not be parsed
|
||||
*/
|
||||
public XmlConfiguration(URI configuration) throws SAXException, IOException
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
synchronized (__parser)
|
||||
if (_location == null)
|
||||
{
|
||||
_url=configuration.toURL();
|
||||
setConfig(__parser.parse(configuration.toString()));
|
||||
_dtd=__parser.getDTD();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and parses the XML configuration string.
|
||||
*
|
||||
* @param configuration String of XML configuration commands excluding the normal XML preamble.
|
||||
* The String should start with a "<Configure ....>" element.
|
||||
* @throws IOException if the configuration could not be read
|
||||
* @throws SAXException if the configuration could not be parsed
|
||||
*/
|
||||
public XmlConfiguration(String configuration) throws SAXException, IOException
|
||||
{
|
||||
configuration = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE Configure PUBLIC \"-//Jetty//Configure//EN\" \"https://www.eclipse.org/jetty/configure.dtd\">"
|
||||
+ configuration;
|
||||
InputSource source = new InputSource(new StringReader(configuration));
|
||||
synchronized (__parser)
|
||||
{
|
||||
_url = null;
|
||||
setConfig(__parser.parse(source));
|
||||
_dtd = __parser.getDTD();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and parses the XML configuration stream.
|
||||
*
|
||||
* @param configuration An input stream containing a complete configuration file
|
||||
* @throws IOException if the configuration could not be read
|
||||
* @throws SAXException if the configuration could not be parsed
|
||||
*/
|
||||
public XmlConfiguration(InputStream configuration) throws SAXException, IOException
|
||||
{
|
||||
InputSource source = new InputSource(configuration);
|
||||
synchronized (__parser)
|
||||
{
|
||||
_url = null;
|
||||
setConfig(__parser.parse(source));
|
||||
_dtd = __parser.getDTD();
|
||||
return "UNKNOWN-LOCATION";
|
||||
}
|
||||
return _location.toString();
|
||||
}
|
||||
|
||||
private void setConfig(XmlParser.Node config)
|
||||
|
@ -283,7 +237,7 @@ public class XmlConfiguration
|
|||
{
|
||||
throw new IllegalArgumentException("Unknown XML tag:" + config.getTag());
|
||||
}
|
||||
_processor.init(_url, config, this);
|
||||
_processor.init(_location, config, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,14 +312,12 @@ public class XmlConfiguration
|
|||
|
||||
private static class JettyXmlConfiguration implements ConfigurationProcessor
|
||||
{
|
||||
private String _url;
|
||||
XmlParser.Node _root;
|
||||
XmlConfiguration _configuration;
|
||||
|
||||
@Override
|
||||
public void init(URL url, XmlParser.Node root, XmlConfiguration configuration)
|
||||
public void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration)
|
||||
{
|
||||
_url = url == null ? null : url.toString();
|
||||
_root = root;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
@ -378,7 +330,7 @@ public class XmlConfiguration
|
|||
if (oClass != null && !oClass.isInstance(obj))
|
||||
{
|
||||
String loaders = (oClass.getClassLoader() == obj.getClass().getClassLoader()) ? "" : "Object Class and type Class are from different loaders.";
|
||||
throw new IllegalArgumentException("Object of class '" + obj.getClass().getCanonicalName() + "' is not of type '" + oClass.getCanonicalName() + "'. " + loaders + " in " + _url);
|
||||
throw new IllegalArgumentException("Object of class '" + obj.getClass().getCanonicalName() + "' is not of type '" + oClass.getCanonicalName() + "'. " + loaders + " in " + _configuration);
|
||||
}
|
||||
String id = _root.getAttribute("id");
|
||||
if (id != null)
|
||||
|
@ -430,7 +382,7 @@ public class XmlConfiguration
|
|||
}
|
||||
catch (NoSuchMethodException x)
|
||||
{
|
||||
throw new IllegalStateException(String.format("No constructor %s(%s,%s) in %s", oClass, arguments, namedArgMap, _url));
|
||||
throw new IllegalStateException(String.format("No constructor %s(%s,%s) in %s", oClass, arguments, namedArgMap, _configuration));
|
||||
}
|
||||
}
|
||||
if (id != null)
|
||||
|
@ -522,12 +474,12 @@ public class XmlConfiguration
|
|||
envObj(node);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown tag: " + tag + " in " + _url);
|
||||
throw new IllegalStateException("Unknown tag: " + tag + " in " + _configuration);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Config error at " + node, e.toString() + " in " + _url);
|
||||
LOG.warn("Config error at " + node, e.toString() + " in " + _configuration);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -703,7 +655,7 @@ public class XmlConfiguration
|
|||
{
|
||||
Object result = constructor.newInstance(args);
|
||||
if (constructor.getAnnotation(Deprecated.class) != null)
|
||||
LOG.warn("Deprecated constructor {} in {}", constructor, _url);
|
||||
LOG.warn("Deprecated constructor {} in {}", constructor, _configuration);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -711,7 +663,7 @@ public class XmlConfiguration
|
|||
{
|
||||
Object result = method.invoke(obj, args);
|
||||
if (method.getAnnotation(Deprecated.class) != null)
|
||||
LOG.warn("Deprecated method {} in {}", method, _url);
|
||||
LOG.warn("Deprecated method {} in {}", method, _configuration);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -719,7 +671,7 @@ public class XmlConfiguration
|
|||
{
|
||||
Object result = field.get(object);
|
||||
if (field.getAnnotation(Deprecated.class) != null)
|
||||
LOG.warn("Deprecated field {} in {}", field, _url);
|
||||
LOG.warn("Deprecated field {} in {}", field, _configuration);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -727,7 +679,7 @@ public class XmlConfiguration
|
|||
{
|
||||
field.set(obj, arg);
|
||||
if (field.getAnnotation(Deprecated.class) != null)
|
||||
LOG.warn("Deprecated field {} in {}", field, _url);
|
||||
LOG.warn("Deprecated field {} in {}", field, _configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1545,7 +1497,7 @@ public class XmlConfiguration
|
|||
if ("Env".equals(tag))
|
||||
return envObj(node);
|
||||
|
||||
LOG.warn("Unknown value tag: " + node, new Throwable());
|
||||
LOG.warn("Unknown value tag: " + node + " in " + _configuration, new Throwable());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1754,7 +1706,7 @@ public class XmlConfiguration
|
|||
{
|
||||
if (!arg.toLowerCase(Locale.ENGLISH).endsWith(".properties") && (arg.indexOf('=') < 0))
|
||||
{
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(arg).getURI().toURL());
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(arg));
|
||||
if (last != null)
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
if (properties.size() > 0)
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
|
||||
package org.eclipse.jetty.xml;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,13 +34,19 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -53,8 +60,11 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class XmlConfigurationTest
|
||||
{
|
||||
public WorkDir workDir;
|
||||
|
||||
protected String[] _configure=new String [] {"org/eclipse/jetty/xml/configureWithAttr.xml","org/eclipse/jetty/xml/configureWithElements.xml"};
|
||||
|
||||
private static final String STRING_ARRAY_XML = "<Array type=\"String\"><Item type=\"String\">String1</Item><Item type=\"String\">String2</Item></Array>";
|
||||
|
@ -64,7 +74,8 @@ public class XmlConfigurationTest
|
|||
public void testMortBay() throws Exception
|
||||
{
|
||||
URL url = XmlConfigurationTest.class.getResource("mortbay.xml");
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
Resource resource = Resource.newResource(url);
|
||||
XmlConfiguration configuration = new XmlConfiguration(resource);
|
||||
configuration.configure();
|
||||
}
|
||||
|
||||
|
@ -77,7 +88,7 @@ public class XmlConfigurationTest
|
|||
properties.put("whatever", "xxx");
|
||||
TestConfiguration.VALUE=77;
|
||||
URL url = XmlConfigurationTest.class.getClassLoader().getResource(configure);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url));
|
||||
TestConfiguration tc = new TestConfiguration("tc");
|
||||
configuration.getProperties().putAll(properties);
|
||||
configuration.configure(tc);
|
||||
|
@ -156,7 +167,7 @@ public class XmlConfigurationTest
|
|||
|
||||
URL url = XmlConfigurationTest.class.getClassLoader().getResource(configure);
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
XmlConfiguration configuration = new XmlConfiguration(url)
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(url))
|
||||
{
|
||||
@Override
|
||||
public void initializeDefaults(Object object)
|
||||
|
@ -236,18 +247,26 @@ public class XmlConfigurationTest
|
|||
}
|
||||
}
|
||||
|
||||
public XmlConfiguration asXmlConfiguration(String rawXml) throws IOException, SAXException
|
||||
{
|
||||
Path testFile = workDir.getEmptyPathDir().resolve("raw.xml");
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(testFile, UTF_8))
|
||||
{
|
||||
writer.write(rawXml);
|
||||
}
|
||||
return new XmlConfiguration(new PathResource(testFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetClass() throws Exception
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get name=\"class\"/></Set></Configure>");
|
||||
XmlConfiguration configuration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get name=\"class\"/></Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
configuration.configure(tc);
|
||||
assertEquals(TestConfiguration.class,tc.testObject);
|
||||
|
||||
configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get class=\"java.lang.String\" name=\"class\"><Get id=\"simple\" name=\"simpleName\"/></Get></Set></Configure>");
|
||||
asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\"><Get class=\"java.lang.String\" name=\"class\"><Get id=\"simple\" name=\"simpleName\"/></Get></Set></Configure>");
|
||||
configuration.configure(tc);
|
||||
assertEquals(String.class,tc.testObject);
|
||||
assertEquals("String",configuration.getIdMap().get("simple"));
|
||||
|
@ -256,8 +275,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testStringConfiguration() throws Exception
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\">SetValue</Set><Set name=\"Test\" type=\"int\">2</Set></Configure>");
|
||||
XmlConfiguration configuration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Test\">SetValue</Set><Set name=\"Test\" type=\"int\">2</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
configuration.configure(tc);
|
||||
assertEquals("SetValue", tc.testObject, "Set String 3");
|
||||
|
@ -267,8 +285,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testMeaningfullSetException() throws Exception
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"PropertyTest\"><Property name=\"null\"/></Set></Configure>");
|
||||
XmlConfiguration configuration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"PropertyTest\"><Property name=\"null\"/></Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
|
||||
NoSuchMethodException e = assertThrows(NoSuchMethodException.class, () -> {
|
||||
|
@ -281,7 +298,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testListConstructorArg() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
+ "<Set name=\"constructorArgTestClass\"><New class=\"org.eclipse.jetty.xml.ConstructorArgTestClass\"><Arg type=\"List\">"
|
||||
+ STRING_ARRAY_XML + "</Arg></New></Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
|
@ -294,7 +311,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testTwoArgumentListConstructorArg() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
+ "<Set name=\"constructorArgTestClass\"><New class=\"org.eclipse.jetty.xml.ConstructorArgTestClass\">"
|
||||
+ "<Arg type=\"List\">" + STRING_ARRAY_XML + "</Arg>"
|
||||
+ "<Arg type=\"List\">" + STRING_ARRAY_XML + "</Arg>"
|
||||
|
@ -309,7 +326,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testListNotContainingArray() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
+ "<New class=\"org.eclipse.jetty.xml.ConstructorArgTestClass\"><Arg type=\"List\">Some String</Arg></New></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
|
||||
|
@ -321,7 +338,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetConstructorArg() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
+ "<Set name=\"constructorArgTestClass\"><New class=\"org.eclipse.jetty.xml.ConstructorArgTestClass\"><Arg type=\"Set\">"
|
||||
+ STRING_ARRAY_XML + "</Arg></New></Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
|
@ -334,7 +351,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetNotContainingArray() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">"
|
||||
+ "<New class=\"org.eclipse.jetty.xml.ConstructorArgTestClass\"><Arg type=\"Set\">Some String</Arg></New></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThrows(IllegalArgumentException.class, ()->{
|
||||
|
@ -345,7 +362,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testListSetterWithStringArray() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"List\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"List\">"
|
||||
+ STRING_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getList() returns null as it's not configured yet",tc.getList(),is(nullValue()));
|
||||
|
@ -356,7 +373,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testListSetterWithPrimitiveArray() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"List\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"List\">"
|
||||
+ INT_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getList() returns null as it's not configured yet",tc.getList(),is(nullValue()));
|
||||
|
@ -367,7 +384,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNotSupportedLinkedListSetter() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"LinkedList\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"LinkedList\">"
|
||||
+ INT_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getSet() returns null as it's not configured yet", tc.getList(), is(nullValue()));
|
||||
|
@ -379,7 +396,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testArrayListSetter() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"ArrayList\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"ArrayList\">"
|
||||
+ INT_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getSet() returns null as it's not configured yet", tc.getList(), is(nullValue()));
|
||||
|
@ -390,7 +407,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetSetter() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Set\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Set\">"
|
||||
+ STRING_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getSet() returns null as it's not configured yet", tc.getSet(), is(nullValue()));
|
||||
|
@ -401,7 +418,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetSetterWithPrimitiveArray() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Set\">"
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\"><Set name=\"Set\">"
|
||||
+ INT_ARRAY_XML + "</Set></Configure>");
|
||||
TestConfiguration tc = new TestConfiguration();
|
||||
assertThat("tc.getSet() returns null as it's not configured yet", tc.getSet(), is(nullValue()));
|
||||
|
@ -412,7 +429,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testMap() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">" +
|
||||
" <Set name=\"map\">" +
|
||||
" <Map>" +
|
||||
|
@ -436,7 +453,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testConstructorNamedInjection() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg>arg1</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -453,7 +470,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testConstructorNamedInjectionOrdered() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg name=\"second\">arg2</Arg> " +
|
||||
|
@ -470,7 +487,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testConstructorNamedInjectionUnOrdered() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg name=\"third\">arg3</Arg> " +
|
||||
|
@ -487,7 +504,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testConstructorNamedInjectionOrderedMixed() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -504,7 +521,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testConstructorNamedInjectionUnorderedMixed() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"third\">arg3</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -521,7 +538,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNestedConstructorNamedInjection() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg>arg1</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -549,7 +566,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNestedConstructorNamedInjectionOrdered() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg name=\"second\">arg2</Arg> " +
|
||||
|
@ -576,7 +593,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNestedConstructorNamedInjectionUnOrdered() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg name=\"third\">arg3</Arg> " +
|
||||
|
@ -603,7 +620,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNestedConstructorNamedInjectionOrderedMixed() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"first\">arg1</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -630,7 +647,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testArgumentsGetIgnoredMissingDTD() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg>arg1</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -642,8 +659,7 @@ public class XmlConfigurationTest
|
|||
" <Arg>arg3</Arg>\n" +
|
||||
" </New>" +
|
||||
" </Set>" +
|
||||
"</Configure>").getBytes(StandardCharsets.ISO_8859_1)));
|
||||
// XmlConfiguration xmlConfiguration = new XmlConfiguration(url);
|
||||
"</Configure>");
|
||||
|
||||
AnnotatedTestConfiguration atc = (AnnotatedTestConfiguration)xmlConfiguration.configure();
|
||||
|
||||
|
@ -658,7 +674,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetGetIgnoredMissingDTD() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\">arg1</Set> " +
|
||||
" <Set name=\"second\">arg2</Set> " +
|
||||
|
@ -670,8 +686,7 @@ public class XmlConfigurationTest
|
|||
" <Set name=\"third\">arg3</Set> " +
|
||||
" </New>" +
|
||||
" </Set>" +
|
||||
"</Configure>").getBytes(StandardCharsets.UTF_8)));
|
||||
// XmlConfiguration xmlConfiguration = new XmlConfiguration(url);
|
||||
"</Configure>");
|
||||
|
||||
DefaultTestConfiguration atc = (DefaultTestConfiguration)xmlConfiguration.configure();
|
||||
|
||||
|
@ -686,7 +701,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testNestedConstructorNamedInjectionUnorderedMixed() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
|
||||
" <Arg name=\"third\">arg3</Arg> " +
|
||||
" <Arg>arg2</Arg> " +
|
||||
|
@ -751,7 +766,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetBooleanTrue() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"boolean\">true</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -763,7 +778,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetBooleanFalse() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"boolean\">false</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -776,7 +791,7 @@ public class XmlConfigurationTest
|
|||
@Disabled
|
||||
public void testSetBadBoolean() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"boolean\">tru</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -788,7 +803,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetBadInteger() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"integer\">bad</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -801,7 +816,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetBadExtraInteger() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"integer\">100 bas</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -814,7 +829,7 @@ public class XmlConfigurationTest
|
|||
@Test
|
||||
public void testSetBadFloatInteger() throws Exception
|
||||
{
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.XmlConfigurationTest$NativeHolder\">" +
|
||||
" <Set name=\"integer\">1.5</Set>" +
|
||||
"</Configure>");
|
||||
|
@ -829,7 +844,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
// No properties
|
||||
String defolt = "baz";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\"><Property name=\"wibble\" deprecated=\"foo,bar\" default=\"" + defolt + "\"/></Set> " +
|
||||
"</Configure>");
|
||||
|
@ -842,7 +857,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
String name = "foo";
|
||||
String value = "foo";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\"><Property name=\"" + name + "\" deprecated=\"other,bar\" default=\"baz\"/></Set> " +
|
||||
"</Configure>");
|
||||
|
@ -856,7 +871,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
String name = "bar";
|
||||
String value = "bar";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\"><Property name=\"foo\" deprecated=\"" + name + "\" default=\"baz\"/></Set> " +
|
||||
"</Configure>");
|
||||
|
@ -870,7 +885,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
String name = "bar";
|
||||
String value = "bar";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\"><Property name=\"foo\" deprecated=\"other," + name + "\" default=\"baz\"/></Set> " +
|
||||
"</Configure>");
|
||||
|
@ -884,7 +899,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
String name = "bar";
|
||||
String value = "bar";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\">" +
|
||||
" <Property> " +
|
||||
|
@ -907,7 +922,7 @@ public class XmlConfigurationTest
|
|||
String value = "bar";
|
||||
String defaultValue = "_<Property name=\"bar\"/>_<Property name=\"bar\"/>_";
|
||||
String expectedValue = "_" + value + "_" + value + "_";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\">" +
|
||||
" <Property>" +
|
||||
|
@ -925,7 +940,7 @@ public class XmlConfigurationTest
|
|||
public void testPropertyNotFoundWithPropertyInDefaultValueNotFoundWithDefault() throws Exception
|
||||
{
|
||||
String value = "bar";
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.DefaultTestConfiguration\">" +
|
||||
" <Set name=\"first\">" +
|
||||
" <Property name=\"not_found\">" +
|
||||
|
@ -948,7 +963,7 @@ public class XmlConfigurationTest
|
|||
for(String propName: propNames)
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("" +
|
||||
asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">" +
|
||||
" <Set name=\"TestString\">" +
|
||||
" <Property name=\"" + propName + "\"/>" +
|
||||
|
@ -976,7 +991,7 @@ public class XmlConfigurationTest
|
|||
for(String propName: propNames)
|
||||
{
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("" +
|
||||
asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">" +
|
||||
" <Set name=\"TestString\">" +
|
||||
" <Property name=\"" + propName + "\"/>" +
|
||||
|
@ -998,7 +1013,7 @@ public class XmlConfigurationTest
|
|||
{
|
||||
Path war = MavenTestingUtils.getTargetPath("no.war");
|
||||
XmlConfiguration configuration =
|
||||
new XmlConfiguration("" +
|
||||
asXmlConfiguration("" +
|
||||
"<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">" +
|
||||
" <Set name=\"TestString\">" +
|
||||
" <Property name=\"" + "jetty.webapps.uri" + "\"/>" +
|
||||
|
@ -1012,12 +1027,12 @@ public class XmlConfigurationTest
|
|||
|
||||
assertThat("jetty.webapps.uri", tc.getTestString(), is(XmlConfiguration.normalizeURI(war.getParent().toUri().toString())));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeprecated() throws Exception
|
||||
{
|
||||
Class<?> testClass = AnnotatedTestConfiguration.class;
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
|
||||
XmlConfiguration xmlConfiguration = asXmlConfiguration("" +
|
||||
"<Configure class=\"" + testClass.getName() + "\">" +
|
||||
" <Set name=\"deprecated\">foo</Set>" +
|
||||
" <Set name=\"obsolete\">" +
|
||||
|
|
|
@ -69,8 +69,6 @@ VER_CURRENT=`sed -e "s/xmlns/ignore/" pom.xml | xmllint --xpath "/project/versio
|
|||
echo "Current pom.xml Version: ${VER_CURRENT}"
|
||||
read -e -p "Release Version ? " VER_RELEASE
|
||||
read -e -p "Next Dev Version ? " VER_NEXT
|
||||
# VER_RELEASE=9.3.5.v20151012
|
||||
# VER_NEXT=9.3.6-SNAPSHOT
|
||||
TAG_NAME="jetty-$VER_RELEASE"
|
||||
|
||||
# Ensure tag doesn't exist (yet)
|
||||
|
@ -89,9 +87,12 @@ if [ ! -d "$ALT_DEPLOY_DIR" ] ; then
|
|||
fi
|
||||
|
||||
# DEPLOY_OPTS="-Dmaven.test.failure.ignore=true"
|
||||
DEPLOY_OPTS="-Dtest=None"
|
||||
DEPLOY_OPTS="-DskipTests -Dtest=None"
|
||||
# DEPLOY_OPTS="$DEPLOY_OPTS -DaltDeploymentRepository=intarget::default::file://$ALT_DEPLOY_DIR/"
|
||||
|
||||
# Uncomment for Java 1.7
|
||||
export MAVEN_OPTS="-Xmx1g -XX:MaxPermSize=128m"
|
||||
|
||||
echo ""
|
||||
echo "-----------------------------------------------"
|
||||
echo " Release Plan Review"
|
||||
|
@ -103,6 +104,7 @@ echo "Current Version : $VER_CURRENT"
|
|||
echo "Release Version : $VER_RELEASE"
|
||||
echo "Next Dev Version : $VER_NEXT"
|
||||
echo "Tag name : $TAG_NAME"
|
||||
echo "MAVEN_OPTS : $MAVEN_OPTS"
|
||||
echo "Maven Deploy Opts: $DEPLOY_OPTS"
|
||||
|
||||
reportMavenTestFailures() {
|
||||
|
@ -130,13 +132,20 @@ echo ""
|
|||
if proceedyn "Are you sure you want to release using above? (y/N)" n; then
|
||||
echo ""
|
||||
if proceedyn "Update VERSION.txt for $VER_RELEASE? (Y/n)" y; then
|
||||
# Uncomment alternate JVM for jetty 9.2 builds
|
||||
# JAVA_HOME_ORIG=$JAVA_HOME
|
||||
# PATH_ORIG=$PATH
|
||||
# JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
|
||||
# PATH=$JAVA_HOME/bin:$PATH
|
||||
mvn -N -Pupdate-version generate-resources
|
||||
cp VERSION.txt VERSION.txt.backup
|
||||
cat VERSION.txt.backup | sed -e "s/$VER_CURRENT/$VER_RELEASE/" > VERSION.txt
|
||||
rm VERSION.txt.backup
|
||||
# JAVA_HOME=$JAVA_HOME_ORIG
|
||||
# PATH=$PATH_ORIG
|
||||
echo "VERIFY the following files (in a different console window) before continuing."
|
||||
echo " VERSION.txt - top section"
|
||||
echo " target/vers-tag.txt - for the tag commit message"
|
||||
echo " target/version-tag.txt - for the tag commit message"
|
||||
fi
|
||||
|
||||
# This is equivalent to 'mvn release:prepare'
|
||||
|
@ -151,8 +160,8 @@ if proceedyn "Are you sure you want to release using above? (y/N)" n; then
|
|||
fi
|
||||
if proceedyn "Create Tag $TAG_NAME? (Y/n)" y; then
|
||||
echo "TODO: Sign tags with GIT_USER_EMAIL=$GIT_USER_EMAIL"
|
||||
echo "Using target/vers-tag.txt as tag text"
|
||||
git tag --file=target/vers-tag.txt $TAG_NAME
|
||||
echo "Using target/version-tag.txt as tag text"
|
||||
git tag --file=target/version-tag.txt $TAG_NAME
|
||||
fi
|
||||
|
||||
# This is equivalent to 'mvn release:perform'
|
||||
|
@ -170,9 +179,10 @@ if proceedyn "Are you sure you want to release using above? (y/N)" n; then
|
|||
echo "" >> VERSION.txt
|
||||
cat VERSION.txt.backup >> VERSION.txt
|
||||
echo "Update project.versions for $VER_NEXT"
|
||||
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set \
|
||||
mvn org.codehaus.mojo:versions-maven-plugin:2.7:set \
|
||||
-DoldVersion="$VER_RELEASE" \
|
||||
-DnewVersion="$VER_NEXT"
|
||||
-DnewVersion="$VER_NEXT" \
|
||||
-DprocessAllModules=true
|
||||
echo "Commit $VER_NEXT"
|
||||
if proceedyn "Commit updates in working directory for $VER_NEXT? (Y/n)" y; then
|
||||
git commit -a -m "Updating to version $VER_NEXT"
|
||||
|
|
|
@ -18,17 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.test.support;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -41,15 +36,21 @@ import org.eclipse.jetty.server.NetworkConnector;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Allows for setting up a Jetty server for testing based on XML configuration files.
|
||||
*/
|
||||
public class XmlBasedJettyServer
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(XmlBasedJettyServer.class);
|
||||
private List<URL> _xmlConfigurations;
|
||||
private List<Resource> _xmlConfigurations;
|
||||
private final Map<String,String> _properties = new HashMap<>();
|
||||
private Server _server;
|
||||
private int _serverPort;
|
||||
|
@ -94,14 +95,14 @@ public class XmlBasedJettyServer
|
|||
_properties.put(String.valueOf(key),String.valueOf(properties.get(key)));
|
||||
}
|
||||
|
||||
public void addXmlConfiguration(URL xmlConfig)
|
||||
public void addXmlConfiguration(Resource xmlConfig)
|
||||
{
|
||||
_xmlConfigurations.add(xmlConfig);
|
||||
}
|
||||
|
||||
public void addXmlConfiguration(File xmlConfigFile) throws MalformedURLException
|
||||
public void addXmlConfiguration(File xmlConfigFile)
|
||||
{
|
||||
_xmlConfigurations.add(xmlConfigFile.toURI().toURL());
|
||||
_xmlConfigurations.add(new PathResource(xmlConfigFile));
|
||||
}
|
||||
|
||||
public void addXmlConfiguration(String testConfigName) throws MalformedURLException
|
||||
|
@ -122,9 +123,9 @@ public class XmlBasedJettyServer
|
|||
// Configure everything
|
||||
for (int i = 0; i < this._xmlConfigurations.size(); i++)
|
||||
{
|
||||
URL configURL = this._xmlConfigurations.get(i);
|
||||
LOG.debug("configuring: "+configURL);
|
||||
XmlConfiguration configuration = new XmlConfiguration(configURL);
|
||||
Resource configResource = this._xmlConfigurations.get(i);
|
||||
LOG.debug("configuring: "+configResource);
|
||||
XmlConfiguration configuration = new XmlConfiguration(configResource);
|
||||
if (last != null)
|
||||
{
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
|
|
|
@ -74,7 +74,7 @@ public class QuickStartTest
|
|||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml);
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class QuickStartTest
|
|||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml);
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class QuickStartTest
|
|||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI().toURL());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml);
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ public class Quickstart
|
|||
//apply context xml file
|
||||
if (contextXml != null)
|
||||
{
|
||||
// System.err.println("Applying "+contextXml);
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI());
|
||||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml);
|
||||
xmlConfiguration.configure(webapp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue