Remove tests from ObjectPropertyTemplateModel_PropertyListConfigTest that had been superseded by tests in CustomListViewConfigFileTest

This commit is contained in:
j2blake 2012-04-20 20:04:39 +00:00
parent 68f88fe257
commit 21828f9233
8 changed files with 8 additions and 312 deletions

View file

@ -82,22 +82,15 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
createConfigFile("constructQueryMissing");
createConfigFile("constructQueryMultiple");
createConfigFile("default");
createConfigFile("notValidXml");
createConfigFile("postProcessorClassNotFound");
createConfigFile("postProcessorClassNotSuitable");
createConfigFile("postProcessorConstructorThrowsException");
createConfigFile("postProcessorNameEmpty");
createConfigFile("postProcessorOK");
createConfigFile("postProcessorWrongConstructor");
createConfigFile("selectQueryNodeBlank");
createConfigFile("selectQueryNodeNotFound");
createConfigFile("selectQuerySubNodes");
createConfigFile("selectQueryNoSubNodes");
createConfigFile("selectQueryCollatedValid");
createConfigFile("selectQueryCollatedNoSelect");
createConfigFile("selectQueryCollatedNoOrder");
createConfigFile("templateNodeIsEmpty");
createConfigFile("templateNodeNotFound");
createConfigFile("templateDoesNotExist");
}
@ -152,12 +145,13 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
// TODO - baseTemplateModel shouldn't require the servlet context to be set
// statically!!! ServletContext shouldn't be a static field.
// ----------------------------------------------------------------------
// The tests
//
// TODO - remove any tests that are covered by the newer
// CustomListViewConfigFileTest.
// ----------------------------------------------------------------------
/*
* These tests were removed because the newer CustomListViewConfigTest
* covered them: configFileNotValidXml(), selectQueryNodeIsNotFound(),
* selectQueryNodeIsBlank(), selectSubNodesCollatedCritical(),
* selectSubNodesCollatedUncritical(), selectSubNodesUncollatedCritical(),
* selectSubNodesUncollatedUncritical(), selectNoSubNodesCollatedCritical()
*/
//
// Null arguments
@ -227,68 +221,9 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
assertLogMessagesContains("file not found", "Can't find config file");
}
@Test
public void configFileNotValidXml() throws InvalidConfigurationException {
suppressSyserr();
captureLogsFromPropertyListConfig();
op = buildOperation("notValidXml");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertLogMessagesContains("not valid XML", "SAXParseException");
}
//
// Problems with the <query-select> node
//
@Test
public void selectQueryNodeIsNotFound()
throws InvalidConfigurationException {
captureLogsFromPropertyListConfig();
op = buildOperation("selectQueryNodeNotFound");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertLogMessagesContains("no select query",
"Missing select query specification");
}
@Test
public void selectQueryNodeIsBlank() throws InvalidConfigurationException {
captureLogsFromPropertyListConfig();
op = buildOperation("selectQueryNodeBlank");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertLogMessagesContains("blank select query",
"Missing select query specification");
}
//
// Problems with the <template> node
//
@Test
public void templateNodeNotFound() throws InvalidConfigurationException {
captureLogsFromPropertyListConfig();
op = buildOperation("templateNodeNotFound");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertLogMessagesContains("no template node",
"Config file must contain a template element");
}
@Test
public void templateNodeIsEmpty() throws InvalidConfigurationException {
captureLogsFromPropertyListConfig();
op = buildOperation("templateNodeIsEmpty");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertLogMessagesContains("empty template node",
"In a config file, the <template> element must not be empty.");
}
@Test
public void templateDoesNotExist() throws InvalidConfigurationException {
@ -302,52 +237,9 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
}
//
// Optional tags in the select query.
// Check for valid query.
//
@Test
public void selectSubNodesCollatedCritical()
throws InvalidConfigurationException {
op = buildOperation("selectQuerySubNodes");
optm = new SimpleCollatingOPTM(op, subject, vreq, false);
assertSelectQuery("collated, critical",
"Plain collated plain critical plain collated plain.");
}
@Test
public void selectSubNodesCollatedUncritical()
throws InvalidConfigurationException {
op = buildOperation("selectQuerySubNodes");
optm = new SimpleCollatingOPTM(op, subject, vreq, true);
assertSelectQuery("collated, UNcritical",
"Plain collated plain plain collated plain.");
}
@Test
public void selectSubNodesUncollatedCritical()
throws InvalidConfigurationException {
op = buildOperation("selectQuerySubNodes");
optm = new NonCollatingOPTM(op, subject, vreq, false);
assertSelectQuery("UNcollated, critical",
"Plain plain critical plain plain.");
}
@Test
public void selectSubNodesUncollatedUncritical()
throws InvalidConfigurationException {
op = buildOperation("selectQuerySubNodes");
optm = new NonCollatingOPTM(op, subject, vreq, true);
assertSelectQuery("UNcollated, UNcritical", "Plain plain plain plain.");
}
@Test
public void selectNoSubNodesCollatedCritical()
throws InvalidConfigurationException {
op = buildOperation("selectQueryNoSubNodes");
optm = new SimpleCollatingOPTM(op, subject, vreq, false);
assertSelectQuery("simple collated, critical", "Plain.");
}
@Test
public void collatedNoSubclassSelector()
throws InvalidConfigurationException {
@ -509,20 +401,6 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
+ expected);
}
private void assertSelectQuery(String message, String expected) {
String actual = "BOGUS";
try {
Method m = ObjectPropertyTemplateModel.class.getDeclaredMethod(
"getSelectQuery", new Class<?>[0]);
m.setAccessible(true);
actual = (String) m.invoke(optm, new Object[0]);
} catch (Exception e) {
fail(message + " - " + e);
}
assertEquals(message, expected, actual);
}
@SuppressWarnings("unchecked")
private void assertConstructQueries(String message, String... expectedArray) {
Set<String> expected = new HashSet<String>(Arrays.asList(expectedArray));
@ -587,31 +465,6 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
}
/*
* No populated properties and we don't do syntax checking on the select
* query.
*/
private class SimpleCollatingOPTM extends
CollatedObjectPropertyTemplateModel {
SimpleCollatingOPTM(ObjectProperty op, Individual subject,
VitroRequest vreq, boolean editing)
throws InvalidConfigurationException {
super(op, subject, vreq, editing, Collections
.<ObjectProperty> emptyList());
}
@Override
public ConfigError checkQuery(String queryString) {
return null;
}
@Override
protected TemplateLoader getFreemarkerTemplateLoader() {
return ObjectPropertyTemplateModel_PropertyListConfigTest.this.tl;
}
}
/** No populated properties but we do check the syntax of the select query. */
private class CheckingCollatingOPTM extends
CollatedObjectPropertyTemplateModel {

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
This would be valid except for the XML error.
-->
<list-view-config>
<query-select>
SELECT <collated> ?subclass </collated>
?object
WHERE {
?subject ?property ?object
<collated>
?object a ?subclass.
</collated>
}
</query-select>
<query-construct/>
CONSTRUCT {
?subject ?property ?object .
} WHERE {
?subject ?property ?object
}
</query-construct>
<template>propStatement-default.ftl</template>
</list-view-config>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
Test this with collated and uncollated, critical and uncritical, to insure that we don't need the nested tags.
-->
<list-view-config>
<query-select>Plain.</query-select>
<query-construct> Construct </query-construct>
<template>propStatement-default.ftl</template>
</list-view-config>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
Invalid - <query-select> is blank.
-->
<list-view-config>
<query-select>
</query-select>
<query-construct>
CONSTRUCT {
?subject ?property ?object .
} WHERE {
?subject ?property ?object
}
</query-construct>
<template>propStatement-default.ftl</template>
</list-view-config>

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
Invalid - no <query-select> node.
-->
<list-view-config>
<query-construct>
CONSTRUCT {
?subject ?property ?object .
} WHERE {
?subject ?property ?object
}
</query-construct>
<template>propStatement-default.ftl</template>
</list-view-config>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
Test this with collated and uncollated, critical and non-critical,
to be sure that we include or omit the appropriate text.
-->
<list-view-config>
<query-select>Plain <collated>collated </collated>plain <critical-data-required>critical </critical-data-required>plain <collated>collated </collated>plain.</query-select>
<query-construct> Construct </query-construct>
<template>propStatement-default.ftl</template>
</list-view-config>

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
Template node is empty - should throw an exception.
-->
<list-view-config>
<query-select>
SELECT <collated> ?subclass </collated>
?object
WHERE {
?subject ?property ?object
<collated>
?object a ?subclass.
</collated>
}
</query-select>
<query-construct>
CONSTRUCT {
?subject ?property ?object .
} WHERE {
?subject ?property ?object
}
</query-construct>
<template/>
</list-view-config>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!--
No template node. Should throw an exception.
-->
<list-view-config>
<query-select>
SELECT <collated> ?subclass </collated>
?object
WHERE {
?subject ?property ?object
<collated>
?object a ?subclass.
</collated>
}
</query-select>
<query-construct>
CONSTRUCT {
?subject ?property ?object .
} WHERE {
?subject ?property ?object
}
</query-construct>
</list-view-config>