mirror of
https://github.com/ethauvin/rife2.git
synced 2025-04-30 02:28:13 -07:00
Removed the site config support for now, there might be a better way
This commit is contained in:
parent
257b24f930
commit
60fd4f74a8
2 changed files with 0 additions and 139 deletions
|
@ -4,14 +4,11 @@
|
|||
*/
|
||||
package rife.engine;
|
||||
|
||||
import rife.config.Config;
|
||||
import rife.config.exceptions.ConfigErrorException;
|
||||
import rife.continuations.ContinuationManager;
|
||||
import rife.engine.exceptions.EngineException;
|
||||
import rife.tools.StringUtils;
|
||||
import rife.workflow.Workflow;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
|
@ -237,39 +234,4 @@ public class Site extends Router {
|
|||
public Workflow createWorkflow(ExecutorService executor) {
|
||||
return new Workflow(executor, properties_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a named resource in the classpath and parses it as an
|
||||
* XML {@link Config} file.
|
||||
*
|
||||
* @param name the name of the resource to parse
|
||||
* @return the parsed configuration file
|
||||
* @throws EngineException when an error occurred during the parsing, or
|
||||
* if the resource couldn't be found
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public Config config(String name) {
|
||||
try {
|
||||
return Config.fromXmlResource(name, properties());
|
||||
} catch (ConfigErrorException e) {
|
||||
throw new EngineException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the provided file as an XML {@link Config} file.
|
||||
*
|
||||
* @param file the file to parse
|
||||
* @return the parsed configuration file
|
||||
* @throws EngineException when an error occurred during the parsing, or
|
||||
* if the resource couldn't be found
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public Config config(File file) {
|
||||
try {
|
||||
return Config.fromXmlFile(file, properties());
|
||||
} catch (ConfigErrorException e) {
|
||||
throw new EngineException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -675,105 +675,4 @@ public class TestEngine {
|
|||
RifeConfig.engine().setPrettyEngineExceptions(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigResource()
|
||||
throws IOException {
|
||||
try (final var server = new TestServerRunner(new Site() {
|
||||
public void setup() {
|
||||
properties().put("config.property.test", "property-engine-value");
|
||||
|
||||
var xml = config("xml/test_xml2config.xml").toXml();
|
||||
|
||||
get("/config", c -> {
|
||||
c.print(xml);
|
||||
});
|
||||
}
|
||||
})) {
|
||||
try (final var webClient = new WebClient()) {
|
||||
final HtmlPage page = webClient.getPage("http://localhost:8181/config");
|
||||
assertEquals("""
|
||||
<config>
|
||||
<list name="list1">
|
||||
<item>item1</item>
|
||||
<item>item2</item>
|
||||
<item>item3</item>
|
||||
</list>
|
||||
<list name="list2">
|
||||
<item>item4</item>
|
||||
<item>item5</item>
|
||||
<item>start:property-engine-value:finish</item>
|
||||
</list>
|
||||
<list name="listfinal" final="true">
|
||||
<item>item6</item>
|
||||
<item>item7</item>
|
||||
</list>
|
||||
<param name="parambool">1</param>
|
||||
<param name="paramchar">C</param>
|
||||
<param name="paramdouble">7863.3434353</param>
|
||||
<param name="paramfinal" final="true">initial value</param>
|
||||
<param name="paramfloat">545.2546</param>
|
||||
<param name="paramint">5133</param>
|
||||
<param name="paramlong">8736478</param>
|
||||
<param name="paramproperty">begin:property-engine-value:end</param>
|
||||
<param name="paramstring">astring</param>
|
||||
</config>
|
||||
""", page.getWebResponse().getContentAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigFile()
|
||||
throws IOException {
|
||||
try (final var server = new TestServerRunner(new Site() {
|
||||
public void setup() {
|
||||
properties().put("config.property.test", "property-engine-value");
|
||||
|
||||
try {
|
||||
var file = File.createTempFile("config", ".xml");
|
||||
FileUtils.writeString("""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE config SYSTEM "/dtd/config.dtd">
|
||||
<config>
|
||||
<list name="alist">
|
||||
<item>start:<property name="config.property.test"/>:finish</item>
|
||||
</list>
|
||||
<param name="paramstring">astring</param>
|
||||
<param name="paramproperty">begin:<property name="config.property.test"/>:end</param>
|
||||
</config>
|
||||
""", file);
|
||||
|
||||
config(file)
|
||||
.parameter("newparam", "newval")
|
||||
.storeToXml();
|
||||
|
||||
var xml = config(file).toXml();
|
||||
|
||||
file.delete();
|
||||
|
||||
get("/config", c -> {
|
||||
|
||||
c.print(xml);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
})) {
|
||||
try (final var webClient = new WebClient()) {
|
||||
final HtmlPage page = webClient.getPage("http://localhost:8181/config");
|
||||
assertEquals("""
|
||||
<config>
|
||||
<list name="alist">
|
||||
<item>start:property-engine-value:finish</item>
|
||||
</list>
|
||||
<param name="newparam">newval</param>
|
||||
<param name="paramproperty">begin:property-engine-value:end</param>
|
||||
<param name="paramstring">astring</param>
|
||||
</config>
|
||||
""", page.getWebResponse().getContentAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue