Unit test fix for PostgreSQL (which does not support '\u0000' embedded in a string)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19992 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2010-04-26 15:42:35 +00:00
parent 6239095959
commit f367dd8e74
3 changed files with 47 additions and 5 deletions

View File

@@ -62,6 +62,8 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.springframework.context.ApplicationContext;
@SuppressWarnings("unchecked")
@@ -112,6 +114,9 @@ public class AuthenticationTest extends TestCase
private PersonService personService;
private UserNameMatcher userNameMatcher;
// TODO: pending replacement
private Dialect dialect;
public AuthenticationTest()
{
@@ -125,7 +130,8 @@ public class AuthenticationTest extends TestCase
public void setUp() throws Exception
{
dialect = (Dialect) ctx.getBean("dialect");
nodeService = (NodeService) ctx.getBean("nodeService");
tenantService = (TenantService) ctx.getBean("tenantService");
searchService = (SearchService) ctx.getBean("searchService");
@@ -369,9 +375,17 @@ public class AuthenticationTest extends TestCase
if (! tenantService.isEnabled())
{
authenticationService.createAuthentication("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", "".toCharArray());
authenticationService.authenticate("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", "".toCharArray());
assertEquals("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", authenticationService.getCurrentUserName());
String un = "Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|";
if (dialect instanceof PostgreSQLDialect)
{
// Note: PostgreSQL does not support \u0000 char embedded in a string
// http://archives.postgresql.org/pgsql-jdbc/2007-02/msg00115.php
un = "Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n[]{};'#:@~,./<>?|";
}
authenticationService.createAuthentication(un, "".toCharArray());
authenticationService.authenticate(un, "".toCharArray());
assertEquals(un, authenticationService.getCurrentUserName());
}
else
{