mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -44,6 +44,8 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.ISO9075;
|
import org.alfresco.util.ISO9075;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +65,8 @@ public class SearcherComponentTest extends TestCase
|
|||||||
|
|
||||||
private static String COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u0000\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
private static String COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u0000\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
||||||
|
|
||||||
|
private static String COMPLEX_LOCAL_NAME_NO_U0000 = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
||||||
|
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@@ -80,8 +84,19 @@ public class SearcherComponentTest extends TestCase
|
|||||||
|
|
||||||
private UserTransaction txn;
|
private UserTransaction txn;
|
||||||
|
|
||||||
|
// TODO: pending replacement
|
||||||
|
private Dialect dialect;
|
||||||
|
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
dialect = (Dialect) ctx.getBean("dialect");
|
||||||
|
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
|
||||||
|
COMPLEX_LOCAL_NAME = COMPLEX_LOCAL_NAME_NO_U0000;
|
||||||
|
}
|
||||||
|
|
||||||
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
transactionService = serviceRegistry.getTransactionService();
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
dictionaryService = BaseNodeServiceTest.loadModel(ctx);
|
dictionaryService = BaseNodeServiceTest.loadModel(ctx);
|
||||||
|
@@ -97,6 +97,8 @@ import org.alfresco.util.CachingDateFormat;
|
|||||||
import org.alfresco.util.ISO9075;
|
import org.alfresco.util.ISO9075;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
@@ -211,6 +213,9 @@ public class ADMLuceneTest extends TestCase implements DictionaryListener
|
|||||||
|
|
||||||
private M2Model model;
|
private M2Model model;
|
||||||
|
|
||||||
|
// TODO: pending replacement
|
||||||
|
private Dialect dialect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -240,6 +245,8 @@ public class ADMLuceneTest extends TestCase implements DictionaryListener
|
|||||||
|
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
dialect = (Dialect) ctx.getBean("dialect");
|
||||||
|
|
||||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||||
dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
|
dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
|
||||||
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
|
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
|
||||||
@@ -5927,6 +5934,12 @@ public class ADMLuceneTest extends TestCase implements DictionaryListener
|
|||||||
public void testAddEscapedChild() throws Exception
|
public void testAddEscapedChild() throws Exception
|
||||||
{
|
{
|
||||||
String COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u0000\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
String COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u0000\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
||||||
|
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
|
||||||
|
COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
|
||||||
|
}
|
||||||
|
|
||||||
luceneFTS.pause();
|
luceneFTS.pause();
|
||||||
buildBaseIndex();
|
buildBaseIndex();
|
||||||
|
@@ -62,6 +62,8 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -113,6 +115,9 @@ public class AuthenticationTest extends TestCase
|
|||||||
|
|
||||||
private UserNameMatcher userNameMatcher;
|
private UserNameMatcher userNameMatcher;
|
||||||
|
|
||||||
|
// TODO: pending replacement
|
||||||
|
private Dialect dialect;
|
||||||
|
|
||||||
public AuthenticationTest()
|
public AuthenticationTest()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
@@ -125,6 +130,7 @@ public class AuthenticationTest extends TestCase
|
|||||||
|
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
|
dialect = (Dialect) ctx.getBean("dialect");
|
||||||
|
|
||||||
nodeService = (NodeService) ctx.getBean("nodeService");
|
nodeService = (NodeService) ctx.getBean("nodeService");
|
||||||
tenantService = (TenantService) ctx.getBean("tenantService");
|
tenantService = (TenantService) ctx.getBean("tenantService");
|
||||||
@@ -369,9 +375,17 @@ public class AuthenticationTest extends TestCase
|
|||||||
|
|
||||||
if (! tenantService.isEnabled())
|
if (! tenantService.isEnabled())
|
||||||
{
|
{
|
||||||
authenticationService.createAuthentication("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", "".toCharArray());
|
String un = "Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|";
|
||||||
authenticationService.authenticate("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", "".toCharArray());
|
if (dialect instanceof PostgreSQLDialect)
|
||||||
assertEquals("Andy `\u00ac\u00a6!\u00a3$%^&*()-_=+\t\n\u0000[]{};'#:@~,./<>?|", authenticationService.getCurrentUserName());
|
{
|
||||||
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user