Search in sources :

Example 1 with EmptyObject

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);
}
Also used : EmptyObject(org.apache.servicecomb.demo.EmptyObject)

Example 2 with EmptyObject

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());
}
Also used : EmptyObject(org.apache.servicecomb.demo.EmptyObject) Holder(org.apache.servicecomb.foundation.common.Holder) EmptyObject(org.apache.servicecomb.demo.EmptyObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 3 with EmptyObject

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());
}
Also used : EmptyObject(org.apache.servicecomb.demo.EmptyObject)

Example 4 with EmptyObject

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);
}
Also used : EmptyObject(org.apache.servicecomb.demo.EmptyObject)

Example 5 with EmptyObject

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());
}
Also used : EmptyObject(org.apache.servicecomb.demo.EmptyObject) Holder(org.apache.servicecomb.foundation.common.Holder) EmptyObject(org.apache.servicecomb.demo.EmptyObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

EmptyObject (org.apache.servicecomb.demo.EmptyObject)6 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Holder (org.apache.servicecomb.foundation.common.Holder)2