You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/08/26 11:02:25 UTC
lucene-solr git commit: SOLR-8029 : Addressing a few feedback back comments by steve. The rest to follow
Repository: lucene-solr
Updated Branches:
refs/heads/apiv2 1d131592c -> 327aaffae
SOLR-8029 : Addressing a few feedback back comments by steve. The rest to follow\u2028 \u2028
* "int" is used instead of "integer" in schemas (json-schema requires "integer")\u2028
* JsonSchemaValidator has no "integer" support, only "number" (e.g. no INTEGER in JsonSchemaValidator.Type, ApiBag.KNOWN_TYPES)\u2028
* JsonSchemaValidator doesn't validate type values - using an invalid type gives an NPE instead of a useful error message\u2028
* JsonValidatorTest is incomplete: it should test all supported schema validation aspects\u2028
* Did you explore existing JSON validation libraries (instead of implementing from scratch)?\u2028
* JsonSchemaValidator\u2028
* Class javadocs should fully describe the limitations it has compared to full JSON schema support\u2028
* Type.valdateData() is misspelled, should be validateData()\u2028
* Attribute.validateData is unused, should be removed\u2028
* Attribute class name is too vague - it could be named SchemaNode instead, since it represents a node in a JSON schema graph.\u2028
* ObjectAttribute class name is too vague - it could be named SchemaAttribute instead, since it is a set of schema object attribute validators \u2028
* /url/path appears to be an orphan in many *.json files \u2028
* These orphaned spec files should be removed:\u2028
* cores.core.Commands.requestRecovery.json (directly specified in cores.core.Commands.json)\u2028
* cores.json (handled by cores.Status.json)\u2028
* cluster.config.Commands.json:\u2028
* "delete" command should be removed, since that functionality is covered by cluster.config.delete.json\u2028
* cluster.security.RuleBasedAuthorization.json:\u2028
* /commands/delete-permission:\u2028
* "type" key is present twice - "type":"object" should be removed (since it should be "int")\u2028
* collections.Commands.json:\u2028
* description is spelled "Description" (capital "D") but should be lowercase\u2028
* description is a copy-paste-o:"The add-field command adds a new field definition to your schema."\u2028
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/327aaffa
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/327aaffa
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/327aaffa
Branch: refs/heads/apiv2
Commit: 327aaffae4bd32df6f591a5a3c823ad19fb18df5
Parents: 1d13159
Author: Noble Paul <no...@apache.org>
Authored: Fri Aug 26 16:32:04 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Fri Aug 26 16:32:04 2016 +0530
----------------------------------------------------------------------
.../apache/solr/util/JsonSchemaValidator.java | 126 +++++++++++--------
.../apispec/cluster.config.Commands.json | 3 -
.../cluster.security.BasicAuth.Commands.json | 1 -
...cluster.security.RuleBasedAuthorization.json | 12 +-
.../resources/apispec/collections.Commands.json | 4 +-
.../apispec/core.SchemaEdit.addCopyField.json | 2 +-
.../core/src/resources/apispec/core.Update.json | 1 -
.../core.config.Commands.addRuntimeLib.json | 2 +-
.../core.config.Commands.updateRuntimeLib.json | 2 +-
.../src/resources/apispec/cores.Commands.json | 1 -
.../src/resources/apispec/cores.Status.json | 1 -
.../resources/apispec/cores.core.Commands.json | 1 -
.../cores.core.Commands.requestRecovery.json | 4 -
solr/core/src/resources/apispec/cores.json | 19 ---
.../org/apache/solr/util/JsonValidatorTest.java | 38 ++++++
.../org/apache/solr/common/util/Lookup.java | 22 ----
16 files changed, 119 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java b/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
index 370d711..10b008c 100644
--- a/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
+++ b/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
@@ -33,12 +33,14 @@ import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toMap;
/**A very basic json schema parsing and data validation tool.
+ * It validates only certain aspects of json schema
+ *
*/
public class JsonSchemaValidator {
- private final Attribute root;
+ private final SchemaNode root;
public JsonSchemaValidator(Map jsonSchema) {
- root = new Attribute(null);
+ root = new SchemaNode(null);
root.isRequired = true;
List<String> errs = new LinkedList<>();
root.validateSchema(jsonSchema, errs);
@@ -47,21 +49,20 @@ public class JsonSchemaValidator {
}
}
- private static class Attribute {
- final Attribute parent;
+ private static class SchemaNode {
+ final SchemaNode parent;
Type type;
Type arrayElementType;
boolean isRequired = false;
Boolean additionalProperties;
- Object validateData;
- Map<String, Attribute> children;
+ Map<String, SchemaNode> children;
- private Attribute(Attribute parent) {
+ private SchemaNode(SchemaNode parent) {
this.parent = parent;
}
private void validateSchema(Map jsonSchema, List<String> errs) {
- for (ObjectAttribute attr : ObjectAttribute.values()) {
+ for (SchemaAttribute attr : SchemaAttribute.values()) {
attr.validate(jsonSchema, this, errs);
}
jsonSchema.keySet().forEach(o -> {
@@ -69,6 +70,7 @@ public class JsonSchemaValidator {
});
if (!errs.isEmpty()) return;
Type type = Type.get(jsonSchema.get("type"));
+ if (type == null) throw new RuntimeException("Unknown type " + jsonSchema.get("type"));
if (type == Type.OBJECT) {
Map m = (Map) jsonSchema.get("properties");
if (m != null) {
@@ -77,7 +79,7 @@ public class JsonSchemaValidator {
if (e.getValue() instanceof Map) {
Map od = (Map) e.getValue();
if (children == null) children = new LinkedHashMap<>();
- Attribute child = new Attribute(this);
+ SchemaNode child = new SchemaNode(this);
children.put((String) e.getKey(), child);
child.validateSchema(od, errs);
} else {
@@ -88,7 +90,7 @@ public class JsonSchemaValidator {
additionalProperties = Boolean.TRUE;
}
}
- for (ObjectAttribute attr : ObjectAttribute.values()) {
+ for (SchemaAttribute attr : SchemaAttribute.values()) {
attr.postValidateSchema(jsonSchema, this, errs);
}
@@ -101,10 +103,10 @@ public class JsonSchemaValidator {
return;
}
} else {
- type.valdateData (key, data, this,errs);
+ type.validateData(key, data, this, errs);
if(!errs.isEmpty()) return;
if (children != null && type == Type.OBJECT) {
- for (Map.Entry<String, Attribute> e : children.entrySet()) {
+ for (Map.Entry<String, SchemaNode> e : children.entrySet()) {
e.getValue().validate(e.getKey(), ((Map) data).get(e.getKey()), errs);
}
if (Boolean.TRUE != additionalProperties) {
@@ -126,17 +128,17 @@ public class JsonSchemaValidator {
return errs.isEmpty() ? null : errs;
}
- enum ObjectAttribute {
+ enum SchemaAttribute {
type(true, Type.STRING) {
@Override
- public void validate(Map attrSchema, Attribute attr, List<String> errors) {
+ public void validate(Map attrSchema, SchemaNode attr, List<String> errors) {
super.validate(attrSchema, attr, errors);
attr.type = Type.get(attrSchema.get(key));
}
},
properties(false, Type.OBJECT) {
@Override
- public void validate(Map attrSchema, Attribute attr, List<String> errors) {
+ public void validate(Map attrSchema, SchemaNode attr, List<String> errors) {
super.validate(attrSchema, attr, errors);
if (attr.type != Type.OBJECT) return;
Object val = attrSchema.get(key);
@@ -151,7 +153,7 @@ public class JsonSchemaValidator {
additionalProperties(false, Type.BOOLEAN),
items(false, Type.OBJECT) {
@Override
- public void validate(Map attrSchema, Attribute attr, List<String> errors) {
+ public void validate(Map attrSchema, SchemaNode attr, List<String> errors) {
super.validate(attrSchema, attr, errors);
Object itemsVal = attrSchema.get(key);
if (itemsVal != null) {
@@ -182,12 +184,12 @@ public class JsonSchemaValidator {
_schema(false, Type.STRING),
required(false, Type.ARRAY) {
@Override
- public void postValidateSchema(Map attrSchema, Attribute attr, List<String> errors) {
+ public void postValidateSchema(Map attrSchema, SchemaNode attr, List<String> errors) {
Object val = attrSchema.get(key);
if (val instanceof List) {
List list = (List) val;
if (attr.children != null) {
- for (Map.Entry<String, Attribute> e : attr.children.entrySet()) {
+ for (Map.Entry<String, SchemaNode> e : attr.children.entrySet()) {
if (list.contains(e.getKey())) e.getValue().isRequired = true;
}
}
@@ -203,7 +205,7 @@ public class JsonSchemaValidator {
return key;
}
- void validate(Map attrSchema, Attribute attr, List<String> errors) {
+ void validate(Map attrSchema, SchemaNode attr, List<String> errors) {
Object val = attrSchema.get(key);
if (val == null) {
if (_required)
@@ -213,73 +215,89 @@ public class JsonSchemaValidator {
}
}
- void postValidateSchema(Map attrSchema, Attribute attr, List<String> errs) {
+ void postValidateSchema(Map attrSchema, SchemaNode attr, List<String> errs) {
}
- ObjectAttribute(boolean required, Type type) {
+ SchemaAttribute(boolean required, Type type) {
this.key = name().replaceAll("__","").replace('_', '$');
this._required = required;
this.typ = type;
}
}
+ interface TypeValidator {
+ void valdateData(String key, Object o, SchemaNode attr, List<String> errs);
+ }
+
enum Type {
STRING(o -> o instanceof String),
- ARRAY(o -> o instanceof List) {
- @Override
- public void valdateData(String key, Object o, Attribute attr, List<String> errs) {
- List l = o instanceof List ? (List) o : Collections.singletonList(o);
- if (attr.arrayElementType != null) {
- for (Object elem : l) {
- if (!attr.arrayElementType.validate(elem)) {
- errs.add("Expected elements of type : " + key + " but found : " + Utils.toJSONString(o));
- break;
- }
+ ARRAY(o -> o instanceof List, (key, o, attr, errs) -> {
+ List l = o instanceof List ? (List) o : Collections.singletonList(o);
+ if (attr.arrayElementType != null) {
+ for (Object elem : l) {
+ if (!attr.arrayElementType.validate(elem)) {
+ errs.add("Expected elements of type : " + key + " but found : " + Utils.toJSONString(o));
+ break;
}
}
}
- },
- NUMBER(o -> o instanceof Number) {
- @Override
- void valdateData(String key, Object o, Attribute attr, List<String> errs) {
- if (o instanceof String) {
- try {
- Double.parseDouble((String) o);
- } catch (NumberFormatException e) {
- errs.add(e.getClass().getName()+" "+ e.getMessage());
- }
+ }),
+ NUMBER(o -> o instanceof Number, (key, o, attr, errs) -> {
+ if (o instanceof String) {
+ try {
+ Double.parseDouble((String) o);
+ } catch (NumberFormatException e) {
+ errs.add(e.getClass().getName() + " " + e.getMessage());
+ }
+ }
+
+ }),
+ INTEGER(o -> o instanceof Integer, (key, o, attr, errs) -> {
+ if (o instanceof String) {
+ try {
+ Integer.parseInt((String) o);
+ } catch (NumberFormatException e) {
+ errs.add(e.getClass().getName() + " " + e.getMessage());
}
}
- },
- BOOLEAN(o -> o instanceof Boolean) {
- @Override
- void valdateData(String key, Object o, Attribute attr, List<String> errs) {
- if (o instanceof String) {
- try {
- Boolean.parseBoolean((String) o);
- } catch (Exception e) {
- errs.add(e.getClass().getName()+" "+ e.getMessage());
- }
+ }),
+ BOOLEAN(o -> o instanceof Boolean, (key, o, attr, errs) -> {
+ if (o instanceof String) {
+ try {
+ Boolean.parseBoolean((String) o);
+ } catch (Exception e) {
+ errs.add(e.getClass().getName() + " " + e.getMessage());
}
}
- },
+ }),
OBJECT(o -> o instanceof Map),
UNKNOWN((o -> true));
final String _name;
final java.util.function.Predicate typeValidator;
+ private final TypeValidator validator;
Type(java.util.function.Predicate validator) {
+ this(validator, null);
+
+ }
+
+ Type(java.util.function.Predicate validator, TypeValidator v) {
_name = this.name().toLowerCase(Locale.ROOT);
this.typeValidator = validator;
+ this.validator = v;
}
boolean validate(Object o) {
return typeValidator.test(o);
}
- void valdateData(String key, Object o, Attribute attr, List<String> errs) {
+ void validateData(String key, Object o, SchemaNode attr, List<String> errs) {
+ if (validator != null) {
+ validator.valdateData(key, o, attr, errs);
+ return;
+ }
if (!typeValidator.test(o)) errs.add("Expected type : " + _name + " but found : " + Utils.toJSONString(o));
}
@@ -292,6 +310,6 @@ public class JsonSchemaValidator {
}
- static final Map<String, ObjectAttribute> knownAttributes = unmodifiableMap(asList(ObjectAttribute.values()).stream().collect(toMap(ObjectAttribute::getKey, identity())));
+ static final Map<String, SchemaAttribute> knownAttributes = unmodifiableMap(asList(SchemaAttribute.values()).stream().collect(toMap(SchemaAttribute::getKey, identity())));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cluster.config.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.config.Commands.json b/solr/core/src/resources/apispec/cluster.config.Commands.json
index eda56d6..305bf25 100644
--- a/solr/core/src/resources/apispec/cluster.config.Commands.json
+++ b/solr/core/src/resources/apispec/cluster.config.Commands.json
@@ -25,9 +25,6 @@
}
},
"required" : ["name", "baseConfigSet"]
- },
- "delete" : {
- "type":"string"
}
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cluster.security.BasicAuth.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.security.BasicAuth.Commands.json b/solr/core/src/resources/apispec/cluster.security.BasicAuth.Commands.json
index aee2a4d..36f5e75 100644
--- a/solr/core/src/resources/apispec/cluster.security.BasicAuth.Commands.json
+++ b/solr/core/src/resources/apispec/cluster.security.BasicAuth.Commands.json
@@ -12,7 +12,6 @@
"set-user": {
"type":"object",
"description": "The set-user command allows you to add users and change their passwords",
- "properties": {},
"additionalProperties": true
},
"delete-user": {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cluster.security.RuleBasedAuthorization.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.security.RuleBasedAuthorization.json b/solr/core/src/resources/apispec/cluster.security.RuleBasedAuthorization.json
index 694ba3a..42386e6 100644
--- a/solr/core/src/resources/apispec/cluster.security.RuleBasedAuthorization.json
+++ b/solr/core/src/resources/apispec/cluster.security.RuleBasedAuthorization.json
@@ -38,16 +38,15 @@
"description":"A request handler name, such as /update or /select. A wild card is supported, to allow for all paths as appropriate (such as, /update/*)."
},
"index": {
- "type": "int",
+ "type": "integer",
"description": "The index of the permission you wish to overwrite"
},
"before":{
- "type": "int",
+ "type": "integer",
"description":"This property allows ordering of permissions. The value for this property is the name of the permission that this new permission should be placed before in security.json."
},
"params":{
"type":"object",
- "properties":{},
"additionalProperties":true,
"description":"The names and values of request parameters. This property can be omitted if all request parameters are allowed, but will restrict access only to the values provided if defined."
}
@@ -82,11 +81,11 @@
"description": "A request handler name, such as /update or /select. A wild card is supported, to allow for all paths as appropriate (such as, /update/*)."
},
"index": {
- "type": "int",
+ "type": "integer",
"description": "The index of the permission you wish to overwrite"
},
"before": {
- "type": "int",
+ "type": "integer",
"description": "This property allows ordering of permissions. The value for this property is the name of the permission that this new permission should be placed before in security.json."
},
"params": {
@@ -101,9 +100,8 @@
]
},
"delete-permission":{
- "type":"object",
"description":"delete a permission by it's index",
- "type":"int"
+ "type":"integer"
},
"set-user-role": {
"type":"object",
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/collections.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.Commands.json b/solr/core/src/resources/apispec/collections.Commands.json
index b6c0361..17ff34a 100644
--- a/solr/core/src/resources/apispec/collections.Commands.json
+++ b/solr/core/src/resources/apispec/collections.Commands.json
@@ -1,9 +1,7 @@
{
"documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1",
- "Description": "The add-field command adds a new field definition to your schema.",
"methods": [
- "POST",
- "GET"
+ "POST"
],
"url": {
"paths": [
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/core.SchemaEdit.addCopyField.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.SchemaEdit.addCopyField.json b/solr/core/src/resources/apispec/core.SchemaEdit.addCopyField.json
index 8becd61..d80b92f 100644
--- a/solr/core/src/resources/apispec/core.SchemaEdit.addCopyField.json
+++ b/solr/core/src/resources/apispec/core.SchemaEdit.addCopyField.json
@@ -14,7 +14,7 @@
"description": "A field or an array of fields to which the source field will be copied."
},
"maxChars": {
- "type": "int",
+ "type": "integer",
"description": "The upper limit for the number of characters to be copied. The section Copying Fields has more details."
}
},
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/core.Update.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.Update.json b/solr/core/src/resources/apispec/core.Update.json
index f243568..2d521df 100644
--- a/solr/core/src/resources/apispec/core.Update.json
+++ b/solr/core/src/resources/apispec/core.Update.json
@@ -4,7 +4,6 @@
"POST"
],
"url": {
- "path": "/update",
"paths": [
"/update",
"/update/xml",
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/core.config.Commands.addRuntimeLib.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.config.Commands.addRuntimeLib.json b/solr/core/src/resources/apispec/core.config.Commands.addRuntimeLib.json
index 42a229d..d95f502 100644
--- a/solr/core/src/resources/apispec/core.config.Commands.addRuntimeLib.json
+++ b/solr/core/src/resources/apispec/core.config.Commands.addRuntimeLib.json
@@ -8,7 +8,7 @@
"type": "string"
},
"version": {
- "type": "int",
+ "type": "integer",
"description": "The version of the blob in .system colection"
},
"sig": {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/core.config.Commands.updateRuntimeLib.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.config.Commands.updateRuntimeLib.json b/solr/core/src/resources/apispec/core.config.Commands.updateRuntimeLib.json
index 42a229d..d95f502 100644
--- a/solr/core/src/resources/apispec/core.config.Commands.updateRuntimeLib.json
+++ b/solr/core/src/resources/apispec/core.config.Commands.updateRuntimeLib.json
@@ -8,7 +8,7 @@
"type": "string"
},
"version": {
- "type": "int",
+ "type": "integer",
"description": "The version of the blob in .system colection"
},
"sig": {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cores.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.Commands.json b/solr/core/src/resources/apispec/cores.Commands.json
index 27602e4..6a994f8 100644
--- a/solr/core/src/resources/apispec/cores.Commands.json
+++ b/solr/core/src/resources/apispec/cores.Commands.json
@@ -4,7 +4,6 @@
"POST"
],
"url": {
- "path": "/cores",
"paths": [
"/cores"
]
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cores.Status.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.Status.json b/solr/core/src/resources/apispec/cores.Status.json
index 78cae51..d2b0603 100644
--- a/solr/core/src/resources/apispec/cores.Status.json
+++ b/solr/core/src/resources/apispec/cores.Status.json
@@ -4,7 +4,6 @@
"GET"
],
"url": {
- "path": "/cores",
"paths": [
"/cores",
"/cores/{core}/status"
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cores.core.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.core.Commands.json b/solr/core/src/resources/apispec/cores.core.Commands.json
index f7a93ee..f1be59ad 100644
--- a/solr/core/src/resources/apispec/cores.core.Commands.json
+++ b/solr/core/src/resources/apispec/cores.core.Commands.json
@@ -4,7 +4,6 @@
"POST"
],
"url": {
- "path": "/cores/{core}",
"paths": [
"/cores/{core}"
]
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cores.core.Commands.requestRecovery.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.core.Commands.requestRecovery.json b/solr/core/src/resources/apispec/cores.core.Commands.requestRecovery.json
deleted file mode 100644
index f5fff5b..0000000
--- a/solr/core/src/resources/apispec/cores.core.Commands.requestRecovery.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "properties": {},
- "additionalProperties": true
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/resources/apispec/cores.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.json b/solr/core/src/resources/apispec/cores.json
deleted file mode 100644
index ab070d0..0000000
--- a/solr/core/src/resources/apispec/cores.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "documentation": "https://cwiki.apache.org",
- "methods": [
- "GET"
- ],
- "url": {
- "path": "/cores",
- "paths": [
- "/cores"
- ],
- "params": {
- "indexInfo": {
- "type": "boolean",
- "description": "return index info",
- "default": false
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
index eafac1b..3bae53f 100644
--- a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
+++ b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
@@ -31,6 +31,7 @@ import static org.apache.solr.common.util.Utils.toJSONString;
public class JsonValidatorTest extends SolrTestCaseJ4 {
+
public void testSchema() {
checkSchema("collections.Commands");
checkSchema("collections.collection.Commands");
@@ -83,8 +84,45 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
errs = validator.validateJson(Utils.fromJSONString("{name:x, age:'x21', adult:'true'}"));
assertEquals(1, errs.size());
+ schema = (Map) Utils.fromJSONString("{" +
+ " type:object," +
+ " properties: {" +
+ " age : {type: int}," +
+ " adult : {type: Boolean}," +
+ " name: {type: string}}}");
+ try {
+ validator = new JsonSchemaValidator(schema);
+ fail("should have failed");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Unknown type"));
+ }
+ schema = (Map) Utils.fromJSONString("{" +
+ " type:object," +
+ " x : y,"+
+ " properties: {" +
+ " age : {type: number}," +
+ " adult : {type: boolean}," +
+ " name: {type: string}}}");
+ try {
+ validator = new JsonSchemaValidator(schema);
+ fail("should have failed");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Unknown key"));
+ }
+ schema = (Map) Utils.fromJSONString("{" +
+ " type:object," +
+ " propertes: {" +
+ " age : {type: number}," +
+ " adult : {type: boolean}," +
+ " name: {type: string}}}");
+ try {
+ validator = new JsonSchemaValidator(schema);
+ fail("should have failed");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("'properties' tag is missing"));
+ }
}
private void checkSchema(String name) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/327aaffa/solr/solrj/src/java/org/apache/solr/common/util/Lookup.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Lookup.java b/solr/solrj/src/java/org/apache/solr/common/util/Lookup.java
deleted file mode 100644
index a5df109..0000000
--- a/solr/solrj/src/java/org/apache/solr/common/util/Lookup.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.common.util;
-
-public interface Lookup<K, V> {
- V get(K key);
-}