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

Commit

Permalink
Fixing failed merge of LoadModulesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrudin committed Sep 3, 2017
1 parent 14cad2e commit b15b751
Showing 1 changed file with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import java.io.File;

import java.io.File;

public class LoadModulesTest extends AbstractAppDeployerTest {

private XccTemplate xccTemplate;
Expand Down Expand Up @@ -86,50 +84,43 @@ public void loadModulesFromMultiplePaths() {

@Test
public void loadModulesWithCustomPermissions() {
appConfig.setModulePermissions(appConfig.getModulePermissions() + ",app-user,execute");
appConfig.setModulePermissions(appConfig.getModulePermissions() + ",app-user,execute");

initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand());

appDeployer.deploy(appConfig);

PermissionsFragment perms = getDocumentPermissions("/ext/sample-lib.xqy", xccTemplate);
perms.assertPermissionCount(6);
PermissionsFragment perms = getDocumentPermissions("/ext/sample-lib.xqy", xccTemplate);
perms.assertPermissionCount(6);

// Default permissions set by AppConfig
perms.assertPermissionExists("rest-admin", "read");
perms.assertPermissionExists("rest-admin", "update");
perms.assertPermissionExists("rest-extension-user", "execute");
// Default permissions set by AppConfig
perms.assertPermissionExists("rest-admin", "read");
perms.assertPermissionExists("rest-admin", "update");
perms.assertPermissionExists("rest-extension-user", "execute");

// Custom permission
perms.assertPermissionExists("app-user", "execute");
// Custom permission
perms.assertPermissionExists("app-user", "execute");

// Permissions that the REST API still applies, which seems like a bug
// Permissions that the REST API still applies, which seems like a bug
perms.assertPermissionExists("rest-reader", "read");
perms.assertPermissionExists("rest-writer", "update");
}

@Test
public void deleteTestModules() {
appConfig.setDeleteTestModules(true);
appConfig.setDeleteTestModulesPattern("/ext/lib/*.xqy");

initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand(),
new DeleteTestModulesCommand());
appDeployer.deploy(appConfig);

String xquery = "fn:count(cts:uri-match('/ext/**.xqy'))";
assertEquals(1, Integer.parseInt(xccTemplate.executeAdhocQuery(xquery)));
}

@Test
public void loadModulesWithAssetFileFilterAndTokenReplacement() {
appConfig.setAssetFileFilter(new TestFileFilter());

String xml = xccTemplate.executeAdhocQuery("doc('/ext/lib/test.xqy')");
Fragment f = parse(xml);
f.assertElementValue("/test/color", "red");
f.assertElementValue("/test/description", "red description");
}
/**
* Add a couple tokens to replace in the modules. It's still a good practice to ensure these tokens don't
* hit on anything accidentally, so their names are capitalized. But since the module token replacement
* follows the Roxy convention by default and prefixes properties with "@ml.", our modules then need
* "@ml.%%COLOR%%", for example.
*/
appConfig.getCustomTokens().put("COLOR", "red");
appConfig.getCustomTokens().put("DESCRIPTION", "${COLOR} description");

initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand());
appDeployer.deploy(appConfig);

assertEquals("true", xccTemplate.executeAdhocQuery("doc-available('/ext/lib/test.xqy')"));
assertEquals("false", xccTemplate.executeAdhocQuery("doc-available('/ext/lib/test2.xqy')"));
Expand All @@ -138,7 +129,21 @@ public void loadModulesWithAssetFileFilterAndTokenReplacement() {
Fragment f = parse(xml);
f.assertElementValue("/test/color", "red");
f.assertElementValue("/test/description", "red description");
}

@Test
public void testServerExists() {
appConfig.getConfigDir().setBaseDir(new File(("src/test/resources/sample-app/db-only-config")));
appConfig.setTestRestPort(8541);
initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand());

appDeployer.deploy(appConfig);

String[] uris = new String[] { "/Default/sample-app/rest-api/options/sample-app-options.xml",
"/Default/sample-app/rest-api/options/sample-app-options.xml" };
for (String uri : uris) {
assertEquals("true", xccTemplate.executeAdhocQuery(format("doc-available('%s')", uri)));
}
}

@Test
Expand Down

0 comments on commit b15b751

Please sign in to comment.