Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 75891e5

Browse files
committed
#378 Tokens are now replaced in schemas
1 parent bb63514 commit 75891e5

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/main/java/com/marklogic/appdeployer/command/schemas/LoadSchemasCommand.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ protected SchemasLoader buildSchemasLoader(CommandContext context, DatabaseClien
111111
if (filter != null) {
112112
schemasLoader.addFileFilter(filter);
113113
}
114+
115+
// TODO Should rename this method to something more generic than "modules"; not sure what that should be yet
116+
if (appConfig.isReplaceTokensInModules()) {
117+
schemasLoader.setTokenReplacer(appConfig.buildTokenReplacer());
118+
}
119+
114120
return schemasLoader;
115121
}
116122

src/test/java/com/marklogic/appdeployer/command/schemas/LoadSchemasTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import com.marklogic.appdeployer.command.databases.DeployOtherDatabasesCommand;
66
import com.marklogic.client.DatabaseClient;
77
import com.marklogic.client.document.GenericDocumentManager;
8+
import com.marklogic.client.io.BytesHandle;
9+
import com.marklogic.client.io.DOMHandle;
810
import com.marklogic.client.io.DocumentMetadataHandle;
11+
import com.marklogic.client.io.StringHandle;
912
import org.junit.After;
1013
import org.junit.Test;
1114

@@ -49,6 +52,8 @@ public void databaseSpecificPaths() {
4952
@Test
5053
public void testSchemaLoading() {
5154
initializeAppDeployer(new DeployOtherDatabasesCommand(1), newCommand());
55+
56+
appConfig.getCustomTokens().put("%%replaceMe%%", "world");
5257
appDeployer.deploy(appConfig);
5358

5459
DatabaseClient client = appConfig.newSchemasDatabaseClient();
@@ -60,6 +65,10 @@ public void testSchemaLoading() {
6065
assertNotNull("XSD document loaded", docMgr.exists("/x.xsd").getUri());
6166
assertNull(docMgr.exists("/.do-not-load"));
6267
assertNull(docMgr.exists(".do-not-load"));
68+
69+
String content = new String(docMgr.read("/x.xsd", new BytesHandle()).get());
70+
assertTrue("Tokens should be replaced when schemas are loaded; actual content: " + content,
71+
content.contains("<hello>world</hello>"));
6372
}
6473

6574
@Test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<xsm>
2+
<hello>%%replaceMe%%</hello>
23
</xsm>

0 commit comments

Comments
 (0)