assertEquals( numDefaultFields+1+1, requiredFields.size()); // also the uniqueKey
}
@Test
public void testRequiredFieldsSingleAdd() {
SolrCore core = h.getCore();
// Add a single document
assertU("adding document",
adoc("id", "529", "name", "document with id, name, and subject", "field_t", "what's inside?", "subject", "info"));
assertU(commit());
// Check it it is in the index
assertQ("should find one", req("id:529") ,"//result[@numFound=1]" );
// Add another document without the required subject field, which
// has a configured defaultValue of "Stuff"
assertU("adding a doc without field w/ configured default",
adoc("id", "530", "name", "document with id and name", "field_t", "what's inside?"));
assertU(commit());
// Add another document without a subject, which has a default in schema
String subjectDefault = core.getSchema().getField("subject").getDefaultValue();
assertNotNull("subject has no default value", subjectDefault);
assertQ("should find one with subject="+subjectDefault, req("id:530 subject:"+subjectDefault) ,"//result[@numFound=1]" );
// Add another document without a required name, which has no default
assertNull(core.getSchema().getField("name").getDefaultValue());
ignoreException("missing required field");
assertFailedU("adding doc without required field",
adoc("id", "531", "subject", "no name document", "field_t", "what's inside?") );
resetExceptionIgnores();
assertU(commit());