Search in sources :

Example 1 with TypedJson

use of org.apache.geode.management.internal.cli.json.TypedJson in project geode by apache.

the class TypedJsonJUnitTest method testPDXObject.

@Test
public void testPDXObject() {
    final Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    DistributedSystem.connect(props);
    Cache cache = new CacheFactory().create();
    PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
    Portfolio p = new Portfolio(2);
    pf.writeInt("ID", 111);
    pf.writeString("status", "active");
    pf.writeString("secId", "IBM");
    pf.writeObject("portfolio", p);
    PdxInstance pi = pf.create();
    TypedJson tJsonObj = new TypedJson(RESULT, pi);
    System.out.println(tJsonObj);
    cache.close();
}
Also used : PdxInstanceFactory(org.apache.geode.pdx.PdxInstanceFactory) PdxInstance(org.apache.geode.pdx.PdxInstance) Portfolio(org.apache.geode.cache.query.data.Portfolio) TypedJson(org.apache.geode.management.internal.cli.json.TypedJson) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with TypedJson

use of org.apache.geode.management.internal.cli.json.TypedJson in project geode by apache.

the class TypedJsonJUnitTest method testMap.

@Test
public void testMap() {
    Map<String, String> testMap = new HashMap<String, String>();
    testMap.put("1", "ONE");
    testMap.put("2", "TWO");
    testMap.put("3", "THREE");
    testMap.put("4", "FOUR");
    TypedJson tjson = new TypedJson(RESULT, testMap);
    System.out.println(tjson);
}
Also used : TypedJson(org.apache.geode.management.internal.cli.json.TypedJson) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 3 with TypedJson

use of org.apache.geode.management.internal.cli.json.TypedJson in project geode by apache.

the class TypedJsonJUnitTest method testUserObjectArray.

@Test
public void testUserObjectArray() {
    Portfolio[] p = createPortfoliosAndPositions(2);
    TypedJson t1 = new TypedJson(RESULT, p);
    System.out.println(t1);
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) TypedJson(org.apache.geode.management.internal.cli.json.TypedJson) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with TypedJson

use of org.apache.geode.management.internal.cli.json.TypedJson in project geode by apache.

the class TypedJsonJUnitTest method testNestedPDXObject.

@Test
public void testNestedPDXObject() {
    final Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    DistributedSystem.connect(props);
    Cache cache = new CacheFactory().create();
    PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
    pf.writeInt("ID", 111);
    pf.writeString("status", "active");
    pf.writeString("secId", "IBM");
    PdxInstance pi = pf.create();
    PDXContainer cont = new PDXContainer(1);
    cont.setPi(pi);
    TypedJson tJsonObj = new TypedJson(RESULT, cont);
    System.out.println(tJsonObj);
    cache.close();
}
Also used : PdxInstanceFactory(org.apache.geode.pdx.PdxInstanceFactory) PdxInstance(org.apache.geode.pdx.PdxInstance) TypedJson(org.apache.geode.management.internal.cli.json.TypedJson) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with TypedJson

use of org.apache.geode.management.internal.cli.json.TypedJson in project geode by apache.

the class TypedJsonJUnitTest method testMemUsage.

@Test
public void testMemUsage() {
    Portfolio[] p = createPortfoliosAndPositions(1000);
    System.out.println("Size Of port " + ObjectSizer.REFLECTION_SIZE.sizeof(p));
    TypedJson t1 = new TypedJson(RESULT, p);
    System.out.println("Size Of json " + ObjectSizer.REFLECTION_SIZE.sizeof(t1));
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) TypedJson(org.apache.geode.management.internal.cli.json.TypedJson) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

TypedJson (org.apache.geode.management.internal.cli.json.TypedJson)15 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)14 Test (org.junit.Test)14 Portfolio (org.apache.geode.cache.query.data.Portfolio)5 Cache (org.apache.geode.cache.Cache)2 CacheFactory (org.apache.geode.cache.CacheFactory)2 GfJsonObject (org.apache.geode.management.internal.cli.json.GfJsonObject)2 PdxInstance (org.apache.geode.pdx.PdxInstance)2 PdxInstanceFactory (org.apache.geode.pdx.PdxInstanceFactory)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Region (org.apache.geode.cache.Region)1 Function (org.apache.geode.cache.execute.Function)1 FunctionException (org.apache.geode.cache.execute.FunctionException)1 ResultCollector (org.apache.geode.cache.execute.ResultCollector)1 Query (org.apache.geode.cache.query.Query)1 QueryInvalidException (org.apache.geode.cache.query.QueryInvalidException)1 QueryService (org.apache.geode.cache.query.QueryService)1 SelectResults (org.apache.geode.cache.query.SelectResults)1 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)1