Skip to content

Commit

Permalink
OAK-11113 : Used Utils api to calculate Id from Path
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh Kumar committed Oct 2, 2024
1 parent 8c190de commit 641feef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public abstract class AbstractDocumentStoreTest {
protected DocumentStore ds;
protected DocumentStoreFixture dsf;
protected DataSource rdbDataSource;
protected List<String> removeMe = new ArrayList<>();
protected List<String> removeMeSettings = new ArrayList<>();
protected List<String> removeMeJournal = new ArrayList<>();
protected List<String> removeMeClusterNodes = new ArrayList<>();
protected List<String> removeMe = new ArrayList<String>();
protected List<String> removeMeSettings = new ArrayList<String>();
protected List<String> removeMeJournal = new ArrayList<String>();
protected List<String> removeMeClusterNodes = new ArrayList<String>();

static final Logger LOG = LoggerFactory.getLogger(AbstractDocumentStoreTest.class);

Expand All @@ -59,7 +59,7 @@ public DocumentMK.Builder getBuilder() {
}

@Before
public void startUp() {
public void startUp() throws Exception{
logNodesPresent(true);
}

Expand All @@ -82,7 +82,7 @@ protected static Collection<Object[]> fixtures(boolean multi) {
Collection<Object[]> result = new ArrayList<>();
Collection<String> names = new ArrayList<>();

DocumentStoreFixture[] candidates = new DocumentStoreFixture[] { DocumentStoreFixture.MEMORY, DocumentStoreFixture.MONGO,
DocumentStoreFixture candidates[] = new DocumentStoreFixture[] { DocumentStoreFixture.MEMORY, DocumentStoreFixture.MONGO,
DocumentStoreFixture.RDB_H2, DocumentStoreFixture.RDB_DERBY, DocumentStoreFixture.RDB_PG,
DocumentStoreFixture.RDB_DB2, DocumentStoreFixture.RDB_MYSQL, DocumentStoreFixture.RDB_ORACLE,
DocumentStoreFixture.RDB_MSSQL };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
import org.apache.jackrabbit.oak.commons.Compression;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

Expand All @@ -68,24 +68,13 @@ public InputStream getInputStream(String blobId)
}
};

private DocumentNodeStore ns;

public CompressedDocumentPropertyStateTest(DocumentStoreFixture dsf) {
super(dsf);
}

@Before
public void before() {
ns = builderProvider.newBuilder().setBlobStore(bs).getNodeStore();
}

@After
public void tearDown() {
try {
ns.dispose();
} finally {
CompressedDocumentPropertyState.setCompressionThreshold(DISABLED_COMPRESSION);
}
CompressedDocumentPropertyState.setCompressionThreshold(DISABLED_COMPRESSION);
}

@Test(expected = IllegalArgumentException.class)
Expand Down Expand Up @@ -198,7 +187,7 @@ public void testBrokenSurrogateWithCompression() throws CommitFailedException {
private void getBrokenSurrogateAndInitializeDifferentStores(boolean compressionEnabled) throws CommitFailedException {
assumeTrue(dsf.isAvailable());
String test = "brokensurrogate:dfsa\ud800";
DocumentNodeStore nodeStore;
DocumentNodeStore store;

if (ds instanceof MongoDocumentStore) {
// Enforce primary read preference, otherwise tests may fail on a
Expand All @@ -208,24 +197,25 @@ private void getBrokenSurrogateAndInitializeDifferentStores(boolean compressionE
// test using a virtual clock
MongoTestUtils.setReadPreference(ds, ReadPreference.primary());
}
nodeStore = new DocumentMK.Builder().setDocumentStore(ds).getNodeStore();
createPropAndCheckValue(nodeStore, test, compressionEnabled);
store = builderProvider.newBuilder().setDocumentStore(ds).getNodeStore();
removeMeClusterNodes.add("" + store.getClusterId());
createPropAndCheckValue(store, test, compressionEnabled);
}

private void createPropAndCheckValue(DocumentNodeStore nodeStore, String test, boolean compressionEnabled) throws CommitFailedException {
NodeBuilder builder = nodeStore.getRoot().builder();
String testNodeName1 = "cdpst1";
final String testNodeName = "cdpst";

if (compressionEnabled) {
CompressedDocumentPropertyState.setCompressionThreshold(1);
}
builder.child(testNodeName1).setProperty("p", test, Type.STRING);
builder.child(testNodeName).setProperty("p", test, Type.STRING);
TestUtils.merge(nodeStore, builder);

PropertyState p = nodeStore.getRoot().getChildNode(testNodeName1).getProperty("p");
PropertyState p = nodeStore.getRoot().getChildNode(testNodeName).getProperty("p");
assertEquals(Objects.requireNonNull(p).getValue(Type.STRING), test);
removeMe.add("0:/");
removeMe.add("1:/" + testNodeName1);
removeMe.add(Utils.getIdFromPath("/"));
removeMe.add(Utils.getIdFromPath("/" + testNodeName));
}


Expand Down

0 comments on commit 641feef

Please sign in to comment.