12
12
13
13
import java .io .File ;
14
14
15
- import java .io .File ;
16
-
17
15
public class LoadModulesTest extends AbstractAppDeployerTest {
18
16
19
17
private XccTemplate xccTemplate ;
@@ -86,50 +84,43 @@ public void loadModulesFromMultiplePaths() {
86
84
87
85
@ Test
88
86
public void loadModulesWithCustomPermissions () {
89
- appConfig .setModulePermissions (appConfig .getModulePermissions () + ",app-user,execute" );
87
+ appConfig .setModulePermissions (appConfig .getModulePermissions () + ",app-user,execute" );
90
88
91
89
initializeAppDeployer (new DeployRestApiServersCommand (true ), buildLoadModulesCommand ());
92
90
93
91
appDeployer .deploy (appConfig );
94
92
95
- PermissionsFragment perms = getDocumentPermissions ("/ext/sample-lib.xqy" , xccTemplate );
96
- perms .assertPermissionCount (6 );
93
+ PermissionsFragment perms = getDocumentPermissions ("/ext/sample-lib.xqy" , xccTemplate );
94
+ perms .assertPermissionCount (6 );
97
95
98
- // Default permissions set by AppConfig
99
- perms .assertPermissionExists ("rest-admin" , "read" );
100
- perms .assertPermissionExists ("rest-admin" , "update" );
101
- perms .assertPermissionExists ("rest-extension-user" , "execute" );
96
+ // Default permissions set by AppConfig
97
+ perms .assertPermissionExists ("rest-admin" , "read" );
98
+ perms .assertPermissionExists ("rest-admin" , "update" );
99
+ perms .assertPermissionExists ("rest-extension-user" , "execute" );
102
100
103
- // Custom permission
104
- perms .assertPermissionExists ("app-user" , "execute" );
101
+ // Custom permission
102
+ perms .assertPermissionExists ("app-user" , "execute" );
105
103
106
- // Permissions that the REST API still applies, which seems like a bug
104
+ // Permissions that the REST API still applies, which seems like a bug
107
105
perms .assertPermissionExists ("rest-reader" , "read" );
108
106
perms .assertPermissionExists ("rest-writer" , "update" );
109
- }
110
-
111
- @ Test
112
- public void deleteTestModules () {
113
- appConfig .setDeleteTestModules (true );
114
- appConfig .setDeleteTestModulesPattern ("/ext/lib/*.xqy" );
115
-
116
- initializeAppDeployer (new DeployRestApiServersCommand (true ), buildLoadModulesCommand (),
117
- new DeleteTestModulesCommand ());
118
- appDeployer .deploy (appConfig );
119
-
120
- String xquery = "fn:count(cts:uri-match('/ext/**.xqy'))" ;
121
- assertEquals (1 , Integer .parseInt (xccTemplate .executeAdhocQuery (xquery )));
122
107
}
123
108
124
109
@ Test
125
110
public void loadModulesWithAssetFileFilterAndTokenReplacement () {
126
111
appConfig .setAssetFileFilter (new TestFileFilter ());
127
112
128
- String xml = xccTemplate .executeAdhocQuery ("doc('/ext/lib/test.xqy')" );
129
- Fragment f = parse (xml );
130
- f .assertElementValue ("/test/color" , "red" );
131
- f .assertElementValue ("/test/description" , "red description" );
132
- }
113
+ /**
114
+ * Add a couple tokens to replace in the modules. It's still a good practice to ensure these tokens don't
115
+ * hit on anything accidentally, so their names are capitalized. But since the module token replacement
116
+ * follows the Roxy convention by default and prefixes properties with "@ml.", our modules then need
117
+ * "@ml.%%COLOR%%", for example.
118
+ */
119
+ appConfig .getCustomTokens ().put ("COLOR" , "red" );
120
+ appConfig .getCustomTokens ().put ("DESCRIPTION" , "${COLOR} description" );
121
+
122
+ initializeAppDeployer (new DeployRestApiServersCommand (true ), buildLoadModulesCommand ());
123
+ appDeployer .deploy (appConfig );
133
124
134
125
assertEquals ("true" , xccTemplate .executeAdhocQuery ("doc-available('/ext/lib/test.xqy')" ));
135
126
assertEquals ("false" , xccTemplate .executeAdhocQuery ("doc-available('/ext/lib/test2.xqy')" ));
@@ -138,7 +129,21 @@ public void loadModulesWithAssetFileFilterAndTokenReplacement() {
138
129
Fragment f = parse (xml );
139
130
f .assertElementValue ("/test/color" , "red" );
140
131
f .assertElementValue ("/test/description" , "red description" );
132
+ }
141
133
134
+ @ Test
135
+ public void testServerExists () {
136
+ appConfig .getConfigDir ().setBaseDir (new File (("src/test/resources/sample-app/db-only-config" )));
137
+ appConfig .setTestRestPort (8541 );
138
+ initializeAppDeployer (new DeployRestApiServersCommand (true ), buildLoadModulesCommand ());
139
+
140
+ appDeployer .deploy (appConfig );
141
+
142
+ String [] uris = new String [] { "/Default/sample-app/rest-api/options/sample-app-options.xml" ,
143
+ "/Default/sample-app/rest-api/options/sample-app-options.xml" };
144
+ for (String uri : uris ) {
145
+ assertEquals ("true" , xccTemplate .executeAdhocQuery (format ("doc-available('%s')" , uri )));
146
+ }
142
147
}
143
148
144
149
@ Test
0 commit comments