use of org.apache.geode.pdx.internal.PdxString in project geode by apache.
the class PdxStringJUnitTest method testHashCodeEquals.
@Test
public void testHashCodeEquals() throws Exception {
PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeString("secId", "abc");
PdxInstanceImpl pi = (PdxInstanceImpl) pf.create();
PdxString pdx1 = (PdxString) pi.getRawField("secId");
Map<PdxString, String> map = new HashMap<PdxString, String>();
map.put(pdx1, "abc");
PdxString pdx2 = new PdxString("abc");
assertEquals(map.get(pdx2), "abc");
map = new Object2ObjectOpenHashMap();
map.put(pdx1, "abc");
assertEquals(map.get(pdx2), "abc");
}
use of org.apache.geode.pdx.internal.PdxString in project geode by apache.
the class PdxStringJUnitTest method testEquals.
@Test
public void testEquals() throws Exception {
PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeString("secId", "abc");
PdxInstanceImpl pi = (PdxInstanceImpl) pf.create();
PdxString pdx1 = (PdxString) pi.getRawField("secId");
assertEquals(false, pdx1.equals(null));
assertEquals(false, pdx1.equals(new Date(37)));
PdxString pdx2 = new PdxString("abc");
assertEquals(pdx1, pdx2);
pdx2 = new PdxString("ABC");
assertEquals(false, pdx1.equals(pdx2));
}
use of org.apache.geode.pdx.internal.PdxString in project geode by apache.
the class PdxStringQueryJUnitTest method testQueriesWithCompactRangeIndexPdxInstances.
@Test
public void testQueriesWithCompactRangeIndexPdxInstances() throws Exception {
Index index = qs.createIndex("index1", "secId", "/exampleRegion");
assertTrue(index instanceof CompactRangeIndex);
putPdxInstances();
CloseableIterator<IndexStoreEntry> indexIterator = null;
try {
indexIterator = ((CompactRangeIndex) index).getIndexStorage().iterator(null);
while (indexIterator.hasNext()) {
assertTrue(indexIterator.next().getDeserializedKey() instanceof PdxString);
}
} finally {
if (indexIterator != null) {
indexIterator.close();
}
}
executeQueriesValidateResults(INDEX_TYPE_COMPACTRANGE);
r.clear();
}
use of org.apache.geode.pdx.internal.PdxString in project geode by apache.
the class PdxStringQueryJUnitTest method testQueriesWithRangeIndex.
@Test
public void testQueriesWithRangeIndex() throws Exception {
Index index = qs.createIndex("index2", "p.secId", "/exampleRegion p, p.positions.values");
assertTrue(index instanceof RangeIndex);
PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeInt("ID", 111);
pf.writeString("secId", "IBM");
pf.writeString("status", "active");
HashMap positions = new HashMap();
positions.put("price", "50");
positions.put("price", "60");
pf.writeObject("positions", positions);
PdxInstance pi = pf.create();
r.put("IBM", pi);
positions = new HashMap();
positions.put("price", "100");
positions.put("price", "120");
r.put("YHOO", new TestObject(222, "YHOO", positions, "inactive"));
pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeInt("ID", 333);
pf.writeString("secId", "GOOGL");
pf.writeString("status", "active");
positions = new HashMap();
positions.put("price", "130");
positions.put("price", "150");
pf.writeObject("positions", positions);
pi = pf.create();
positions = new HashMap();
positions.put("price", "200");
positions.put("price", "220");
r.put("VMW", new TestObject(111, "VMW", positions, "inactive"));
r.put("GOOGL", pi);
Map map = ((RangeIndex) index).getValueToEntriesMap();
for (Object key : map.keySet()) {
assertTrue(key instanceof PdxString);
}
executeQueriesValidateResults(INDEX_TYPE_RANGE);
qs.removeIndex(index);
r.clear();
}
use of org.apache.geode.pdx.internal.PdxString in project geode by apache.
the class PdxStringQueryJUnitTest method testQueriesWithCompactRangeIndexPdxInstancesREUpdateInProgress.
@Test
public void testQueriesWithCompactRangeIndexPdxInstancesREUpdateInProgress() throws Exception {
Index index = qs.createIndex("index1", "secId", "/exampleRegion");
assertTrue(index instanceof CompactRangeIndex);
putPdxInstancesWithREUpdateInProgress();
CloseableIterator<IndexStoreEntry> indexIterator = null;
try {
indexIterator = ((CompactRangeIndex) index).getIndexStorage().iterator(null);
while (indexIterator.hasNext()) {
assertTrue(indexIterator.next().getDeserializedKey() instanceof PdxString);
}
} finally {
if (indexIterator != null) {
indexIterator.close();
}
}
executeQueriesValidateResults(INDEX_TYPE_COMPACTRANGE);
r.clear();
}
Aggregations