use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest method test_0.
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
config.addDeny(null);
config.addDeny("com.alibaba.json.bvtVO.deny");
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest9 method test_autoTypeDeny.
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
properties.put(ParserConfig.AUTOTYPE_ACCEPT, "com.alibaba.json.bvt.parser.deser.deny.DenyTest9");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
assertEquals(Model.class, obj.getClass());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest2 method test_0.
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
Properties properties = new Properties();
properties.put(ParserConfig.DENY_PROPERTY, "com.alibaba.json.bvtVO.deny");
config.configFromPropety(properties);
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest6 method test_autoTypeDeny.
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
config.addDeny("com.alibaba.json.bvt.parser.deser.deny.DenyTest6");
config.setAutoTypeSupport(false);
Exception error = null;
try {
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest6$Model\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest7 method test_autoTypeDeny.
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
Exception error = null;
try {
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest7$Model\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
Aggregations