Skip to content
Snippets Groups Projects
Commit 96df1d5a authored by gmantele's avatar gmantele
Browse files

Fix UDF parsing from the configuration file.

The end of the description of a UDF was not detected when this UDF was followed
by another UDF definition. This was due to an incorrect double quote escape in
the regular expression of a UDF's definition.
parent a959db1f
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE project> <!DOCTYPE project>
<project name="tap" basedir="." default="buildLib"> <project name="tap" basedir="." default="buildLib">
<property name="version" value="2.2" /> <property name="version" value="2.3" />
<property name="srcDir" value="src" /> <property name="srcDir" value="src" />
<property name="testDir" value="test" /> <property name="testDir" value="test" />
......
...@@ -129,7 +129,7 @@ import uws.service.log.UWSLog.LogLevel; ...@@ -129,7 +129,7 @@ import uws.service.log.UWSLog.LogLevel;
* </p> * </p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI)
* @version 2.1 (02/2018) * @version 2.3 (03/2018)
* @since 2.0 * @since 2.0
*/ */
public final class ConfigurableServiceConnection implements ServiceConnection { public final class ConfigurableServiceConnection implements ServiceConnection {
...@@ -1124,7 +1124,7 @@ public final class ConfigurableServiceConnection implements ServiceConnection { ...@@ -1124,7 +1124,7 @@ public final class ConfigurableServiceConnection implements ServiceConnection {
private final String REGEXP_CLASSPATH = "\\{[^{}]*\\}"; private final String REGEXP_CLASSPATH = "\\{[^{}]*\\}";
private final String REGEXP_DESCRIPTION = "\"((\\\"|[^\"])*)\""; private final String REGEXP_DESCRIPTION = "\"((\\\\\"|[^\"])*)\"";
private final String REGEXP_UDF = "\\[\\s*(" + REGEXP_SIGNATURE + ")\\s*(,\\s*(" + REGEXP_CLASSPATH + ")?\\s*(,\\s*(" + REGEXP_DESCRIPTION + ")?\\s*)?)?\\]"; private final String REGEXP_UDF = "\\[\\s*(" + REGEXP_SIGNATURE + ")\\s*(,\\s*(" + REGEXP_CLASSPATH + ")?\\s*(,\\s*(" + REGEXP_DESCRIPTION + ")?\\s*)?)?\\]";
......
...@@ -308,7 +308,7 @@ public class TestConfigurableServiceConnection { ...@@ -308,7 +308,7 @@ public class TestConfigurableServiceConnection {
udfsWithClassNameProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}]"); udfsWithClassNameProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}]");
udfsWithClassNameAndDescriptionProp = (Properties)validProp.clone(); udfsWithClassNameAndDescriptionProp = (Properties)validProp.clone();
udfsWithClassNameAndDescriptionProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}, \"Bla \"bla\".\"]"); udfsWithClassNameAndDescriptionProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR, {adql.db.TestDBChecker$UDFToto}, \"Bla \\\"bla\\\".\"], [ titi(b REAL) -> double, {adql.db.TestDBChecker$UDFToto}, \"Function titi.\"]");
udfsWithEmptyOptParamsProp = (Properties)validProp.clone(); udfsWithEmptyOptParamsProp = (Properties)validProp.clone();
udfsWithEmptyOptParamsProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR,, ]"); udfsWithEmptyOptParamsProp.setProperty(KEY_UDFS, "[toto(a string)->VARCHAR,, ]");
...@@ -1060,12 +1060,18 @@ public class TestConfigurableServiceConnection { ...@@ -1060,12 +1060,18 @@ public class TestConfigurableServiceConnection {
try{ try{
ServiceConnection connection = new ConfigurableServiceConnection(udfsWithClassNameAndDescriptionProp); ServiceConnection connection = new ConfigurableServiceConnection(udfsWithClassNameAndDescriptionProp);
assertNotNull(connection.getUDFs()); assertNotNull(connection.getUDFs());
assertEquals(1, connection.getUDFs().size()); assertEquals(2, connection.getUDFs().size());
FunctionDef def = connection.getUDFs().iterator().next(); Iterator<FunctionDef> itUdfs = connection.getUDFs().iterator();
FunctionDef def = itUdfs.next();
assertEquals("toto(a VARCHAR) -> VARCHAR", def.toString()); assertEquals("toto(a VARCHAR) -> VARCHAR", def.toString());
assertEquals(UDFToto.class, def.getUDFClass()); assertEquals(UDFToto.class, def.getUDFClass());
assertEquals("Bla \"bla\".", def.description); assertEquals("Bla \\\"bla\\\".", def.description);
def = itUdfs.next();
assertEquals("titi(b REAL) -> DOUBLE", def.toString());
assertEquals(UDFToto.class, def.getUDFClass());
assertEquals("Function titi.", def.description);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace();
fail("This MUST have succeeded because the given list of UDFs contains valid items! \nCaught exception: " + getPertinentMessage(e)); fail("This MUST have succeeded because the given list of UDFs contains valid items! \nCaught exception: " + getPertinentMessage(e));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment