mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
59337: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (4.3/Cloud) 59273: Merged DEV to V4.2-BUG-FIX (4.2.1) 58959, 59195 : MNT-10111 : MSSQL: JBPM: A plenty of schema differences are present after schema bootstrap on a clean start - Type names only validator added. Validate nvarchar(max) fields with it - TypeNameOnlyValidatorTest added for TypeNameOnlyValidator 59299: MNT-10111 : MSSQL: JBPM: A plenty of schema differences are present after schema bootstrap on a clean start - Additional commit of Schema-Reference-JBPM.xml, it was corrupted in r59273 59335: Fix errors introduced into mergeinfo in r59273 (MNT-10111) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62129 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,6 +33,7 @@ system.schema_comp.validation=Validation: {0} {1}="{2}" fails to match rule: {3}
|
|||||||
# Specific validator (implementations) messages...
|
# Specific validator (implementations) messages...
|
||||||
system.schema_comp.name_validator=name must match pattern ''{0}''
|
system.schema_comp.name_validator=name must match pattern ''{0}''
|
||||||
system.schema_comp.index_columns_validator=Number of columns in index doesn''t match. Was {0}, but expected {1}
|
system.schema_comp.index_columns_validator=Number of columns in index doesn''t match. Was {0}, but expected {1}
|
||||||
|
system.schema_comp.column_names_validator=Column types do not match. Was {0}, but expected {1}
|
||||||
system.schema_comp.schema_version_validator=version must be at least ''{0}''
|
system.schema_comp.schema_version_validator=version must be at least ''{0}''
|
||||||
|
|
||||||
# Clustering
|
# Clustering
|
||||||
|
@@ -0,0 +1,55 @@
|
|||||||
|
package org.alfresco.util.schemacomp.validator;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.util.schemacomp.DbProperty;
|
||||||
|
import org.alfresco.util.schemacomp.DiffContext;
|
||||||
|
import org.alfresco.util.schemacomp.ValidationResult;
|
||||||
|
import org.alfresco.util.schemacomp.model.DbObject;
|
||||||
|
import org.alfresco.util.schemacomp.model.Column;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates columns types without column size.
|
||||||
|
*
|
||||||
|
* @author sergei.shcherbovich
|
||||||
|
*/
|
||||||
|
public class TypeNameOnlyValidator extends NameValidator
|
||||||
|
{
|
||||||
|
private static String TYPE_SIZE_SPLITTER = "(";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(DbObject reference, DbObject target, DiffContext ctx)
|
||||||
|
{
|
||||||
|
if (!(target instanceof Column))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("TypeNameOnlyValidator could be used only in context of column object but was: " + target.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
String referenceTypeName = ((Column)reference).getType();
|
||||||
|
String targetTypeName = ((Column)target).getType();
|
||||||
|
|
||||||
|
if (referenceTypeName.contains(TYPE_SIZE_SPLITTER))
|
||||||
|
{
|
||||||
|
referenceTypeName = referenceTypeName.substring(0, referenceTypeName.indexOf(TYPE_SIZE_SPLITTER));
|
||||||
|
}
|
||||||
|
if (targetTypeName.contains(TYPE_SIZE_SPLITTER))
|
||||||
|
{
|
||||||
|
targetTypeName = targetTypeName.substring(0, targetTypeName.indexOf(TYPE_SIZE_SPLITTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!referenceTypeName.equals(targetTypeName))
|
||||||
|
{
|
||||||
|
String message = I18NUtil.getMessage("system.schema_comp.column_names_validator", targetTypeName, referenceTypeName);
|
||||||
|
ValidationResult result = new ValidationResult(new DbProperty(target, "type"), message);
|
||||||
|
ctx.getComparisonResults().add(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validatesFullObject()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,78 @@
|
|||||||
|
package org.alfresco.util.schemacomp.validator;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect;
|
||||||
|
import org.alfresco.util.schemacomp.DiffContext;
|
||||||
|
import org.alfresco.util.schemacomp.Results;
|
||||||
|
import org.alfresco.util.schemacomp.model.Column;
|
||||||
|
import org.alfresco.util.schemacomp.model.DbObject;
|
||||||
|
import org.alfresco.util.schemacomp.model.Index;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the TypeNameOnlyValidator class.
|
||||||
|
*
|
||||||
|
* @author sergei.shcherbovich
|
||||||
|
*/
|
||||||
|
public class TypeNameOnlyValidatorTest
|
||||||
|
{
|
||||||
|
private TypeNameOnlyValidator validator;
|
||||||
|
private DiffContext ctx;
|
||||||
|
private Results validationResults;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception
|
||||||
|
{
|
||||||
|
validator = new TypeNameOnlyValidator();
|
||||||
|
validationResults = new Results();
|
||||||
|
ctx = new DiffContext(new AlfrescoSQLServerDialect(), validationResults, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validateOnlyColumnsTest()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
validator.validate(null, new Index(null, null, new ArrayList<String>()), ctx);
|
||||||
|
fail("TypeNameOnlyValidator should validate only Column");
|
||||||
|
}
|
||||||
|
catch(AlfrescoRuntimeException e)
|
||||||
|
{
|
||||||
|
// should validate only Column
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validateColumnNamesTest()
|
||||||
|
{
|
||||||
|
// shouldn't fail
|
||||||
|
assertValidation(column("nvarchar(1)"), column("nvarchar(2)"), false);
|
||||||
|
// shouldn't fail
|
||||||
|
assertValidation(column("numeric"), column("numeric"), false);
|
||||||
|
// should fail
|
||||||
|
assertValidation(column("nvarchar(1)"), column("varchar(1)"), true);
|
||||||
|
// shouldn't fail
|
||||||
|
assertValidation(column("numeric() identity"), column("numeric() identity"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertValidation(DbObject reference, DbObject target, boolean shouldFail)
|
||||||
|
{
|
||||||
|
int shouldFailInt = shouldFail ? 1 : 0;
|
||||||
|
int beforeValidationResultsSize = validationResults.size();
|
||||||
|
|
||||||
|
validator.validate(reference, target, ctx);
|
||||||
|
assertEquals(validationResults.size() - beforeValidationResultsSize, shouldFailInt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Column column(String typeName)
|
||||||
|
{
|
||||||
|
return new Column(null, null, typeName, true);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user