use of org.apache.servicecomb.demo.EmptyObject in project java-chassis by ServiceComb.
the class TestObject method testEmptyObject_highway.
private void testEmptyObject_highway() {
// This is a behavior change in 2.0.0, before 2.0.0 this return null
EmptyObject result = intf.testEmpty(new EmptyObject());
TestMgr.check(result instanceof EmptyObject, true);
result = restTemplate.postForObject(prefix + "/emptyObject", new EmptyObject(), EmptyObject.class);
TestMgr.check(result instanceof EmptyObject, true);
}
use of org.apache.servicecomb.demo.EmptyObject in project java-chassis by ServiceComb.
the class TestObject method testObject.
@SuppressWarnings("unchecked")
private void testObject() {
// int
Object result = intf.testObject(1);
TestMgr.check(1, result);
TestMgr.check(Integer.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", 1, Integer.class);
TestMgr.check(1, result);
TestMgr.check(Integer.class, result.getClass());
// string
result = intf.testObject("str");
TestMgr.check("str", result);
TestMgr.check(String.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", "str", String.class);
TestMgr.check("str", result);
TestMgr.check(String.class, result.getClass());
// emptyObject
result = intf.testObject(new EmptyObject());
// result may not be an empty map in highway
// TestMgr.check("{}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", new EmptyObject(), EmptyObject.class);
TestMgr.check(EmptyObject.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", new EmptyObject(), EmptyObject.class);
TestMgr.check(EmptyObject.class, result.getClass());
// map
Map<String, String> map = Collections.singletonMap("k", "v");
result = intf.testObject(map);
TestMgr.check("{k=v}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", map, Map.class);
TestMgr.check("{k=v}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
// list
List<String> list = Collections.singletonList("v");
result = intf.testObject(list);
TestMgr.check("[v]", result);
TestMgr.check(true, List.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", list, List.class);
TestMgr.check("[v]", result);
TestMgr.check(true, List.class.isAssignableFrom(result.getClass()));
// generic
Holder<String> holder = new Holder<>("v");
result = intf.testObject(holder);
TestMgr.check("v", ((Map<String, String>) result).get("value"));
TestMgr.check(LinkedHashMap.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", holder, Holder.class);
TestMgr.check("v", ((Map<String, String>) result).get("value"));
TestMgr.check(LinkedHashMap.class, result.getClass());
}
use of org.apache.servicecomb.demo.EmptyObject in project java-chassis by ServiceComb.
the class TestObject method testEmptyObject_rest.
private void testEmptyObject_rest() {
EmptyObject result = intf.testEmpty(new EmptyObject());
TestMgr.check(EmptyObject.class, result.getClass());
result = restTemplate.postForObject(prefix + "/emptyObject", new EmptyObject(), EmptyObject.class);
TestMgr.check(EmptyObject.class, result.getClass());
}
use of org.apache.servicecomb.demo.EmptyObject in project incubator-servicecomb-java-chassis by apache.
the class TestObject method testEmptyObject_highway.
private void testEmptyObject_highway() {
// This is a behavior change in 2.0.0, before 2.0.0 this return null
EmptyObject result = intf.testEmpty(new EmptyObject());
TestMgr.check(result instanceof EmptyObject, true);
result = restTemplate.postForObject(prefix + "/emptyObject", new EmptyObject(), EmptyObject.class);
TestMgr.check(result instanceof EmptyObject, true);
}
use of org.apache.servicecomb.demo.EmptyObject in project incubator-servicecomb-java-chassis by apache.
the class TestObject method testObject.
@SuppressWarnings("unchecked")
private void testObject() {
// int
Object result = intf.testObject(1);
TestMgr.check(1, result);
TestMgr.check(Integer.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", 1, Integer.class);
TestMgr.check(1, result);
TestMgr.check(Integer.class, result.getClass());
// string
result = intf.testObject("str");
TestMgr.check("str", result);
TestMgr.check(String.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", "str", String.class);
TestMgr.check("str", result);
TestMgr.check(String.class, result.getClass());
// emptyObject
result = intf.testObject(new EmptyObject());
// result may not be an empty map in highway
// TestMgr.check("{}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", new EmptyObject(), EmptyObject.class);
TestMgr.check(EmptyObject.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", new EmptyObject(), EmptyObject.class);
TestMgr.check(EmptyObject.class, result.getClass());
// map
Map<String, String> map = Collections.singletonMap("k", "v");
result = intf.testObject(map);
TestMgr.check("{k=v}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", map, Map.class);
TestMgr.check("{k=v}", result);
TestMgr.check(true, Map.class.isAssignableFrom(result.getClass()));
// list
List<String> list = Collections.singletonList("v");
result = intf.testObject(list);
TestMgr.check("[v]", result);
TestMgr.check(true, List.class.isAssignableFrom(result.getClass()));
result = restTemplate.postForObject(prefix + "/object", list, List.class);
TestMgr.check("[v]", result);
TestMgr.check(true, List.class.isAssignableFrom(result.getClass()));
// generic
Holder<String> holder = new Holder<>("v");
result = intf.testObject(holder);
TestMgr.check("v", ((Map<String, String>) result).get("value"));
TestMgr.check(LinkedHashMap.class, result.getClass());
result = restTemplate.postForObject(prefix + "/object", holder, Holder.class);
TestMgr.check("v", ((Map<String, String>) result).get("value"));
TestMgr.check(LinkedHashMap.class, result.getClass());
}
Aggregations