Skip to content

Commit be68827

Browse files
georgeajitgeorgeajit
authored andcommitted
#995 - Release clients for negative tests.
1 parent 0fad4df commit be68827

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/functionaltest/TestDatabaseClientKerberosFromFile.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,21 +1162,25 @@ public void testValidDCUserNotInKeytabFile() {
11621162

11631163
// User "user2" is not in the ML Data folder's services.keytab file. But "user2" is in Active Directory and valid.
11641164
StringBuilder msg = new StringBuilder();
1165+
DatabaseClient client2 = null;
11651166
try {
11661167
KerberosConfig krbConfigUser2 = new DatabaseClientFactory.KerberosConfig().withPrincipal("user2")
11671168
.withUseKeyTab(true)
11681169
.withDoNotPrompt(true)
11691170
.withStoreKey(true)
11701171
.withKeyTab(keytabFile);
11711172
System.out.println("Principal of key tab file is " + krbConfigUser2.getPrincipal());
1172-
client = DatabaseClientFactory.newClient(appServerHostName,
1173+
client2 = DatabaseClientFactory.newClient(appServerHostName,
11731174
appServerHostPort, new DatabaseClientFactory.KerberosAuthContext(krbConfigUser2));
11741175
} catch (Exception e) {
11751176
msg.append(e.getMessage());
11761177
e.printStackTrace();
11771178
}
11781179

11791180
assertTrue("Exception is not thrown for user2", msg.toString().contains("Unable to obtain password from user"));
1181+
if (client2 != null) {
1182+
client2.release();
1183+
}
11801184
}
11811185

11821186
//Test DatabaseCLient with invalid ADC user. Should expect an Exception.
@@ -1186,21 +1190,25 @@ public void testInValidDCUserNotInKeytabFile() {
11861190

11871191
// User "builder890" is not in the ML Data folder's services.keytab file.
11881192
StringBuilder msg = new StringBuilder();
1193+
DatabaseClient client890 = null;
11891194
try {
11901195
KerberosConfig krbConfigUser890 = new DatabaseClientFactory.KerberosConfig().withPrincipal("builder890")
11911196
.withUseKeyTab(true)
11921197
.withDoNotPrompt(true)
11931198
.withStoreKey(true)
11941199
.withKeyTab(keytabFile);
11951200
System.out.println("Principal of key tab file is " + krbConfigUser890.getPrincipal());
1196-
client = DatabaseClientFactory.newClient(appServerHostName,
1201+
client890 = DatabaseClientFactory.newClient(appServerHostName,
11971202
appServerHostPort, new DatabaseClientFactory.KerberosAuthContext(krbConfigUser890));
11981203
} catch (Exception e) {
11991204
msg.append(e.getMessage());
12001205
e.printStackTrace();
12011206
}
12021207

12031208
assertTrue("Exception is not thrown for builder890", msg.toString().contains("Unable to obtain password from user"));
1209+
if (client890 != null) {
1210+
client890.release();
1211+
}
12041212
}
12051213

12061214
}

0 commit comments

Comments
 (0)