Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LSC
lsc
Commits
80d741c4
Commit
80d741c4
authored
May 19, 2014
by
Raphaël OUAZANA
Browse files
Fix tests assuming JNDI connections are kept open (references #695)
parent
900f094d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/lsc/jndi/JndiServices.java
View file @
80d741c4
...
...
@@ -320,7 +320,11 @@ public final class JndiServices {
if
(!
cache
.
containsKey
(
props
))
{
cache
.
put
(
props
,
new
JndiServices
(
props
));
}
return
cache
.
get
(
props
);
JndiServices
instance
=
cache
.
get
(
props
);
if
(
instance
.
ctx
==
null
)
{
instance
.
initConnection
();
}
return
instance
;
}
}
...
...
@@ -1203,6 +1207,7 @@ public final class JndiServices {
// Close the connection to the LDAP server
ctx
.
close
();
ctx
=
null
;
super
.
finalize
();
}
...
...
src/test/java/org/lsc/Ldap2LdapSyncTest.java
View file @
80d741c4
...
...
@@ -91,6 +91,10 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
LscConfiguration
.
getInstance
();
Assert
.
assertNotNull
(
LscConfiguration
.
getConnection
(
"src-ldap"
));
Assert
.
assertNotNull
(
LscConfiguration
.
getConnection
(
"dst-ldap"
));
reloadJndiConnections
();
}
private
void
reloadJndiConnections
()
{
srcJndiServices
=
JndiServices
.
getInstance
((
LdapConnectionType
)
LscConfiguration
.
getConnection
(
"src-ldap"
));
dstJndiServices
=
JndiServices
.
getInstance
((
LdapConnectionType
)
LscConfiguration
.
getConnection
(
"dst-ldap"
));
}
...
...
@@ -105,7 +109,7 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
* @throws LscServiceException
*/
@Test
public
final
void
testReadUserPasswordFromLdap
()
throws
NamingException
,
IllegalArgumentException
,
IllegalAccessException
,
InvocationTargetException
,
LscService
Exception
{
public
final
void
testReadUserPasswordFromLdap
()
throws
Exception
{
Map
<
String
,
LscDatasets
>
ids
=
new
HashMap
<
String
,
LscDatasets
>(
1
);
Map
<
String
,
String
>
attributeValues
=
new
HashMap
<
String
,
String
>(
1
);
attributeValues
.
put
(
"sn"
,
"SN0001"
);
...
...
@@ -120,6 +124,8 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
// so we can't test the full value, just the beginning.
// This is sufficient to confirm we can read the attribute as a String.
assertTrue
(
userPassword
.
startsWith
(
"{SSHA}"
));
((
SimpleJndiSrcService
)
srcService
).
close
();
}
@Test
...
...
@@ -156,18 +162,21 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
launchSyncCleanTask
(
TASK_NAME
,
false
,
true
,
false
);
// check the results of the synchronization
reloadJndiConnections
();
checkSyncResultsFirstPass
();
// sync again to confirm convergence
launchSyncCleanTask
(
TASK_NAME
,
false
,
true
,
false
);
// check the results of the synchronization
reloadJndiConnections
();
checkSyncResultsSecondPass
();
// sync a third time to make sure nothing changed
launchSyncCleanTask
(
TASK_NAME
,
false
,
true
,
false
);
// check the results of the synchronization
reloadJndiConnections
();
checkSyncResultsSecondPass
();
}
...
...
@@ -233,7 +242,7 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
private
final
void
checkSyncResultsCommon
()
throws
Exception
{
List
<
String
>
attributeValues
=
null
;
// check MODRDN
assertTrue
(
dstJndiServices
.
exists
(
DN_MODRDN_DST_AFTER
));
assertFalse
(
dstJndiServices
.
exists
(
DN_MODRDN_DST_BEFORE
));
...
...
@@ -293,6 +302,7 @@ public class Ldap2LdapSyncTest extends CommonLdapSyncTest {
launchSyncCleanTask
(
TASK_NAME
,
false
,
false
,
true
);
// check the results of the clean
reloadJndiConnections
();
assertFalse
(
dstJndiServices
.
exists
(
DN_DELETE_DST
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment