Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-1059: PRQueryDUnitHelper no longer inherits PartitionedRegionDUnitTestCase #132

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
import java.util.Collection;
import java.util.Iterator;

import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.data.PortfolioData;
import com.gemstone.gemfire.cache.query.data.Position;

import parReg.query.unittest.NewPortfolio;

/**
*
*/
Expand Down Expand Up @@ -53,4 +59,36 @@ public static String printResult(Object r){
sb.append(r);
return sb.toString();
}
/**
* This function <br>
* 1. The Creates an array of PortfolioData objects
*
* @return PortFolioData Objects
*/

public static PortfolioData[] createPortfolioData(final int cnt, final int cntDest) {
PortfolioData[] portfolio = new PortfolioData[cntDest];
for (int k = cnt; k < cntDest; k++) {
portfolio[k] = new PortfolioData(k);
}
return portfolio;
}

public static Portfolio[] createPortfoliosAndPositions(int count) {
Position.cnt = 0; // reset Portfolio counter
Portfolio[] portfolios = new Portfolio[count];
for (int i = 0; i < count; i++) {
portfolios[i] = new Portfolio(i);
}
return portfolios;
}

public static NewPortfolio[] createNewPortfoliosAndPositions(int count) {
Position.cnt = 0; // reset Portfolio counter
NewPortfolio[] portfolios = new NewPortfolio[count];
for (int i = 0; i < count; i++) {
portfolios[i] = new NewPortfolio("" + i, i);
}
return portfolios;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public class QueryDataInconsistencyDUnitTest extends CacheTestCase {
public static String[] queriesForRR = new String[] { "<trace> select * from /"
+ repRegionName + " where ID=1" };

private static PRQueryDUnitHelper PRQHelp = new PRQueryDUnitHelper("");

public static volatile boolean hooked = false;
/**
* @param name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.cache.query.dunit;

import static com.gemstone.gemfire.cache.query.Utils.createPortfoliosAndPositions;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -125,13 +127,11 @@ public class QueryUsingFunctionContextDUnitTest extends CacheTestCase {

public static String[] queriesForRR = new String[]{"<trace> select * from /"+repRegionName+" where ID>=0"};

private static PRQueryDUnitHelper PRQHelp = new PRQueryDUnitHelper("");
/**
* @param name
*/
public QueryUsingFunctionContextDUnitTest(String name) {
super(name);

}

@Override
Expand Down Expand Up @@ -671,7 +671,7 @@ private Set getBucketsForFilter(Set filter) {

public void fillValuesInRegions() {
//Create common Portflios and NewPortfolios
final Portfolio[] portfolio = PRQHelp.createPortfoliosAndPositions(cntDest);
final Portfolio[] portfolio = createPortfoliosAndPositions(cntDest);

//Fill local region
server1.invoke(getCacheSerializableRunnableForPRPuts(localRegionName,
Expand Down Expand Up @@ -1015,7 +1015,7 @@ public void run2() throws CacheException
region.put(new Integer(j), portfolio[j]);
LogWriterUtils.getLogWriter()
.info(
"PRQueryDUnitHelper#getCacheSerializableRunnableForPRPuts: Inserted Portfolio data on Region "
"getCacheSerializableRunnableForPRPuts: Inserted Portfolio data on Region "
+ regionName);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package com.gemstone.gemfire.cache.query.functional;

import static com.gemstone.gemfire.cache.query.Utils.createPortfoliosAndPositions;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand All @@ -39,7 +40,6 @@
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.SelectResults;
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.partitioned.PRQueryDUnitHelper;
import com.gemstone.gemfire.cache.query.types.ObjectType;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.LocalRegion.NonTXEntry;
Expand Down Expand Up @@ -368,21 +368,21 @@ private void compareLimitQueryResults(Object[][] r, int len) {
if ((r[j][0] != null) && (r[j][1] != null)) {
type1 = ((SelectResults) r[j][0]).getCollectionType().getElementType();
assertNotNull(
"PRQueryDUnitHelper#compareTwoQueryResults: Type 1 is NULL "
"#compareTwoQueryResults: Type 1 is NULL "
+ type1, type1);
type2 = ((SelectResults) r[j][1]).getCollectionType().getElementType();
assertNotNull(
"PRQueryDUnitHelper#compareTwoQueryResults: Type 2 is NULL "
"#compareTwoQueryResults: Type 2 is NULL "
+ type2, type2);
if ( !(type1.getClass().getName()).equals(type2.getClass().getName()) ) {
fail("PRQueryDUnitHelper#compareTwoQueryResults: FAILED:Search result Type is different in both the cases: "
fail("#compareTwoQueryResults: FAILED:Search result Type is different in both the cases: "
+ type1.getClass().getName() + " "
+ type2.getClass().getName());
}
int size0 = ((SelectResults) r[j][0]).size();
int size1 = ((SelectResults) r[j][1]).size();
if (size0 != size1) {
fail("PRQueryDUnitHelper#compareTwoQueryResults: FAILED:Search resultSet size are different in both cases; size0="
fail("#compareTwoQueryResults: FAILED:Search resultSet size are different in both cases; size0="
+ size0 + ";size1=" + size1 + ";j=" + j);
}
}
Expand All @@ -401,7 +401,7 @@ private String[] getLimitQueries() {

private void putREWithUpdateInProgressTrue(String region) {
Region reg = CacheUtils.getRegion(region);
Portfolio[] values = new PRQueryDUnitHelper("").createPortfoliosAndPositions(numOfEntries);
Portfolio[] values = createPortfoliosAndPositions(numOfEntries);

int i=0;
for (Object val: values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.gemstone.gemfire.cache.query.data.Portfolio;
import com.gemstone.gemfire.cache.query.data.PortfolioData;
import com.gemstone.gemfire.cache.query.internal.index.IndexManager.TestHook;
import com.gemstone.gemfire.cache.query.partitioned.PRQueryDUnitHelper;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
import com.gemstone.gemfire.cache30.CacheTestCase;
Expand All @@ -58,8 +57,6 @@
*/
public class ConcurrentIndexInitOnOverflowRegionDUnitTest extends CacheTestCase {

PRQueryDUnitHelper PRQHelp = new PRQueryDUnitHelper("");

String name;

final int redundancy = 0;
Expand Down Expand Up @@ -92,7 +89,7 @@ public void testAsyncIndexInitDuringEntryDestroyAndQueryOnRR() {
"Create local region with synchronous index maintenance") {
@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();
Region partitionRegion = null;
IndexManager.testHook = null;
try {
Expand Down Expand Up @@ -140,10 +137,10 @@ public void run2() throws CacheException {

@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();

// Do a put in region.
Region r = PRQHelp.getCache().getRegion(name);
Region r = getCache().getRegion(name);

for (int i = 0; i < 100; i++) {
r.put(i, new PortfolioData(i));
Expand All @@ -153,7 +150,7 @@ public void run2() throws CacheException {
IndexManager.testHook = new IndexManagerTestHook();

// Destroy one of the values.
PRQHelp.getCache().getLogger().fine("Destroying the value");
getCache().getLogger().fine("Destroying the value");
r.destroy(1);

IndexManager.testHook = null;
Expand All @@ -165,7 +162,7 @@ public void run2() throws CacheException {

@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();

while (!hooked) {
Wait.pause(100);
Expand Down Expand Up @@ -204,7 +201,7 @@ public void testAsyncIndexInitDuringEntryPutUsingClientOnRR() {
"Create local region with synchronous index maintenance") {
@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();

Region partitionRegion = null;
IndexManager.testHook = null;
Expand Down Expand Up @@ -305,7 +302,7 @@ public void run2() throws CacheException {

@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();

while (!hooked) {
Wait.pause(100);
Expand Down Expand Up @@ -355,7 +352,7 @@ public void testIndexUpdateWithRegionClear() {

@Override
public void run2() throws CacheException {
Cache cache = PRQHelp.getCache();
Cache cache = getCache();
Region region = cache.createRegionFactory(RegionShortcut.LOCAL).create(regionName);
QueryService qService = cache.getQueryService();

Expand Down Expand Up @@ -391,7 +388,7 @@ public void hook(int spot) throws RuntimeException {
@Override
public void run2() throws CacheException {

Region region = PRQHelp.getCache().getRegion(regionName);
Region region = getCache().getRegion(regionName);
for (int i=0; i<100; i++) {
if (i == 50) IndexManager.testHook = new LocalTestHook();
region.put(i, new Portfolio(i));
Expand All @@ -405,7 +402,7 @@ public void run2() throws CacheException {

@Override
public void run2() throws CacheException {
Region region = PRQHelp.getCache().getRegion(regionName);
Region region = getCache().getRegion(regionName);

while(!hooked) {
Wait.pause(100);
Expand All @@ -417,7 +414,7 @@ public void run2() throws CacheException {
}

try {
QueryService qservice = PRQHelp.getCache().getQueryService();
QueryService qservice = getCache().getQueryService();
Index index = qservice.getIndex(region, "idIndex");
if (((CompactRangeIndex)index).getIndexStorage().size() > 1) {
fail("After clear region size is supposed to be zero as all index updates are blocked. Current region size is: "+ region.size());
Expand All @@ -436,7 +433,7 @@ public void run2() throws CacheException {

@Override
public void run2() throws CacheException {
Region region = PRQHelp.getCache().getRegion(regionName);
Region region = getCache().getRegion(regionName);
if (region.size() > 50) {
fail("After clear region size is supposed to be 50 as all index updates are blocked " + region.size());
}
Expand Down
Loading