mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
76603: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (5.0BF) 75807 : Merged DEV to V4.2-BUG-FIX (4.2.3) 75768 : MNT-11304 : Type definition response for exif aspect using browser binding is causing some JSON parsers to fail - Use default boundaries only for numeric types 75778 : MNT-11304 : Type definition response for exif aspect using browser binding is causing some JSON parsers to fail - Test for the fix git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77664 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,10 +23,12 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -100,6 +102,7 @@ import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionEleme
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
|
||||
@@ -2252,4 +2255,63 @@ public class CMISTest
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-11304: Test that Alfresco has no default boundaries for decimals
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testDecimalDefaultBoundaries() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
try
|
||||
{
|
||||
withCmisService(new CmisServiceCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute(CmisService cmisService)
|
||||
{
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
String repositoryId = repo.getId();
|
||||
|
||||
TypeDefinition decimalTypeDef = cmisService.getTypeDefinition(repositoryId, "D:tcdm:testdecimalstype", null);
|
||||
|
||||
PropertyDecimalDefinitionImpl floatNoBoundsTypeDef =
|
||||
(PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:float");
|
||||
PropertyDecimalDefinitionImpl doubleNoBoundsTypeDef =
|
||||
(PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:double");
|
||||
|
||||
PropertyDecimalDefinitionImpl floatWithBoundsTypeDef =
|
||||
(PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:floatwithbounds");
|
||||
PropertyDecimalDefinitionImpl doubleWithBoundsTypeDef =
|
||||
(PropertyDecimalDefinitionImpl)decimalTypeDef.getPropertyDefinitions().get("tcdm:doublewithbounds");
|
||||
|
||||
// test that there is not default boundaries for decimals
|
||||
assertNull(floatNoBoundsTypeDef.getMinValue());
|
||||
assertNull(floatNoBoundsTypeDef.getMaxValue());
|
||||
|
||||
assertNull(doubleNoBoundsTypeDef.getMinValue());
|
||||
assertNull(doubleNoBoundsTypeDef.getMaxValue());
|
||||
|
||||
// test for pre-defined boundaries
|
||||
assertTrue(floatWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10f)));
|
||||
assertTrue(floatWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10f)));
|
||||
|
||||
assertTrue(doubleWithBoundsTypeDef.getMinValue().equals(BigDecimal.valueOf(-10d)));
|
||||
assertTrue(doubleWithBoundsTypeDef.getMaxValue().equals(BigDecimal.valueOf(10d)));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
source/test-resources/opencmis/testcmisdecimal_model.xml
Normal file
62
source/test-resources/opencmis/testcmisdecimal_model.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<model name="tcdm:myDecimalTestModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
<!-- Meta-data about the model -->
|
||||
<description>Test CMIS Decimal for Boundaries Model</description>
|
||||
<author>SSergey</author>
|
||||
<version>1.0</version>
|
||||
|
||||
<imports>
|
||||
<!-- Import Alfresco Dictionary Definitions -->
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0"
|
||||
prefix="d" />
|
||||
<!-- Import Alfresco Content Domain Model Definitions -->
|
||||
<import uri="http://www.alfresco.org/model/content/1.0"
|
||||
prefix="cm" />
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://testCMISDecimalModel/1.0/"
|
||||
prefix="tcdm" />
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
<type name="tcdm:testdecimalstype">
|
||||
<title>Test Decimals Type</title>
|
||||
<parent>cm:content</parent>
|
||||
<properties>
|
||||
<property name="tcdm:float">
|
||||
<title>Float</title>
|
||||
<description>Float</description>
|
||||
<type>d:float</type>
|
||||
</property>
|
||||
<property name="tcdm:double">
|
||||
<title>Double</title>
|
||||
<description>Double</description>
|
||||
<type>d:double</type>
|
||||
</property>
|
||||
<property name="tcdm:floatwithbounds">
|
||||
<title>Float With Boundaries</title>
|
||||
<description>Float With Boundaries</description>
|
||||
<type>d:float</type>
|
||||
<constraints>
|
||||
<constraint type="MINMAX">
|
||||
<parameter name="minValue"><value>-10</value></parameter>
|
||||
<parameter name="maxValue"><value>10</value></parameter>
|
||||
</constraint>
|
||||
</constraints>
|
||||
</property>
|
||||
<property name="tcdm:doublewithbounds">
|
||||
<title>Double With Boundaries</title>
|
||||
<description>Double With Boundaries</description>
|
||||
<type>d:double</type>
|
||||
<constraints>
|
||||
<constraint type="MINMAX">
|
||||
<parameter name="minValue"><value>-10</value></parameter>
|
||||
<parameter name="maxValue"><value>10</value></parameter>
|
||||
</constraint>
|
||||
</constraints>
|
||||
</property>
|
||||
</properties>
|
||||
</type>
|
||||
</types>
|
||||
</model>
|
@@ -7,6 +7,7 @@
|
||||
<property name="models">
|
||||
<list>
|
||||
<value>opencmis/testcmisinteger_model.xml</value>
|
||||
<value>opencmis/testcmisdecimal_model.xml</value>
|
||||
<value>opencmis/testcmis_item_model.xml</value>
|
||||
<value>tenant/exampleModel.xml</value>
|
||||
</list>
|
||||
|
Reference in New Issue
Block a user