org.alfresco.service.cmr.repository.MLText

Here are the examples of the java api class org.alfresco.service.cmr.repository.MLText taken from open source projects.

1. BaseNodeServiceTest#testMultiValueMLTextProperties()

Project: community-edition
File: BaseNodeServiceTest.java
@SuppressWarnings("unchecked")
public void testMultiValueMLTextProperties() throws Exception {
    NodeRef nodeRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), TYPE_QNAME_TEST_MANY_ML_PROPERTIES).getChildRef();
    // Create MLText properties and add to a collection
    List<MLText> mlTextCollection = new ArrayList<MLText>(2);
    MLText mlText0 = new MLText();
    mlText0.addValue(Locale.ENGLISH, "Hello");
    mlText0.addValue(Locale.FRENCH, "Bonjour");
    mlTextCollection.add(mlText0);
    MLText mlText1 = new MLText();
    mlText1.addValue(Locale.ENGLISH, "Bye bye");
    mlText1.addValue(Locale.FRENCH, "Au revoir");
    mlTextCollection.add(mlText1);
    nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) mlTextCollection);
    Collection<MLText> mlTextCollectionCheck = (Collection<MLText>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", mlTextCollection, mlTextCollectionCheck);
}

2. DBQueryTest#getOrderProperties()

Project: community-edition
File: DBQueryTest.java
/**
     * @return properties
     */
public Map<QName, Serializable> getOrderProperties() {
    Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
    testProperties.put(CREATED_DATE, orderDate);
    testProperties.put(ORDER_DOUBLE, orderDoubleCount);
    testProperties.put(ORDER_FLOAT, orderFloatCount);
    testProperties.put(ORDER_LONG, orderLongCount);
    testProperties.put(ORDER_INT, orderIntCount);
    testProperties.put(ORDER_TEXT, new String(new char[] { (char) ('a' + orderTextCount) }) + " cabbage");
    MLText mlText = new MLText();
    mlText.addValue(Locale.ENGLISH, new String(new char[] { (char) ('a' + orderTextCount) }) + " banana");
    mlText.addValue(Locale.FRENCH, new String(new char[] { (char) ('Z' - orderTextCount) }) + " banane");
    mlText.addValue(Locale.CHINESE, new String(new char[] { (char) ('?' + orderTextCount) }) + " ??");
    testProperties.put(ORDER_ML_TEXT, mlText);
    orderDate = Duration.subtract(orderDate, new Duration("P1D"));
    orderDoubleCount += 0.1d;
    orderFloatCount += 0.82f;
    orderLongCount += 299999999999999l;
    orderIntCount += 8576457;
    orderTextCount++;
    return testProperties;
}

3. ADMLuceneTest#getOrderProperties()

Project: community-edition
File: ADMLuceneTest.java
/**
     * @return properties
     */
public Map<QName, Serializable> getOrderProperties() {
    Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
    testProperties.put(createdDate, orderDate);
    testProperties.put(orderDouble, orderDoubleCount);
    testProperties.put(orderFloat, orderFloatCount);
    testProperties.put(orderLong, orderLongCount);
    testProperties.put(orderInt, orderIntCount);
    testProperties.put(orderText, new String(new char[] { (char) ('a' + orderTextCount) }) + " cabbage");
    MLText mlText = new MLText();
    mlText.addValue(Locale.ENGLISH, new String(new char[] { (char) ('a' + orderTextCount) }) + " banana");
    mlText.addValue(Locale.FRENCH, new String(new char[] { (char) ('Z' - orderTextCount) }) + " banane");
    mlText.addValue(Locale.CHINESE, new String(new char[] { (char) ('?' + orderTextCount) }) + " ??");
    testProperties.put(orderMLText, mlText);
    orderDate = Duration.subtract(orderDate, new Duration("P1D"));
    orderDoubleCount += 0.1d;
    orderFloatCount += 0.82f;
    orderLongCount += 299999999999999l;
    orderIntCount += 8576457;
    orderTextCount++;
    return testProperties;
}

4. OpenCmisQueryTest#addSortableNull()

Project: community-edition
File: OpenCmisQueryTest.java
private NodeRef addSortableNull(String id) {
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
    MLText ml = new MLText();
    ml.addValue(Locale.ENGLISH, "Test null");
    properties.put(ContentModel.PROP_DESCRIPTION, ml);
    properties.put(ContentModel.PROP_TITLE, ml);
    properties.put(ContentModel.PROP_NAME, "Test null " + id);
    properties.put(ContentModel.PROP_CREATED, new Date());
    NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CONTAINS, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef();
    return c0;
}

5. AuditComponentImplTest#testTrimStringsIfNecessary()

Project: community-edition
File: AuditComponentImplTest.java
public void testTrimStringsIfNecessary() {
    final int OVERLIMIT_SIZE = 1500;
    AuditComponentImpl auditComponent = new AuditComponentImpl();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < OVERLIMIT_SIZE; i++) {
        sb.append("a");
    }
    // Test map input
    HashMap<String, Serializable> map = new HashMap<String, Serializable>();
    String nullValue = null;
    String oversizeString = sb.toString();
    MLText mlTextValue = new MLText();
    mlTextValue.put(Locale.ENGLISH, oversizeString);
    HashMap<String, Serializable> mapEntry = new HashMap<String, Serializable>();
    MLText mlTextMap = new MLText();
    mlTextMap.put(Locale.ENGLISH, oversizeString);
    mapEntry.put("StringMapEntry", oversizeString);
    mapEntry.put("MLText", mlTextMap);
    ArrayList<Serializable> list = new ArrayList<Serializable>();
    MLText mlTextList = new MLText();
    mlTextList.put(Locale.ENGLISH, oversizeString);
    list.add(oversizeString);
    list.add(mlTextList);
    ArrayList<Serializable> listEntry = new ArrayList<Serializable>();
    MLText mlTextListEntry = new MLText();
    mlTextListEntry.put(Locale.ENGLISH, oversizeString);
    HashMap<String, Serializable> mapListEntry = new HashMap<String, Serializable>();
    mapListEntry.put("StringMapListEntry", oversizeString);
    listEntry.add(nullValue);
    listEntry.add(oversizeString);
    listEntry.add(mlTextListEntry);
    listEntry.add(mapListEntry);
    listEntry.add(list);
    ArrayList<Serializable> listForUnmd = new ArrayList<Serializable>();
    listForUnmd.add(oversizeString);
    Collection<Serializable> unmdCollection = Collections.unmodifiableCollection(listForUnmd);
    map.put("nullValue", nullValue);
    map.put("StringMap", oversizeString);
    map.put("MLText", mlTextValue);
    map.put("mapEntry", mapEntry);
    map.put("listEntry", listEntry);
    map.put("unmodifiableCollection", (Serializable) unmdCollection);
    // Test method
    Map<String, Serializable> processed = auditComponent.trimStringsIfNecessary(map);
    // Check that nothing changed with null
    assertNull(processed.get("nullValue"));
    // Check StringMap
    String stringMap = (String) processed.get("StringMap");
    assertNotSame(stringMap, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMap.length());
    // Check MLText
    MLText mlTextProc = (MLText) processed.get("MLText");
    assertNotSame(mlTextProc, mlTextValue);
    String stringMLText = mlTextProc.get(Locale.ENGLISH);
    assertNotSame(stringMLText, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMLText.length());
    // Check mapEntry
    HashMap<String, Serializable> mapEntryProc = (HashMap<String, Serializable>) processed.get("mapEntry");
    assertNotSame(mapEntryProc, mapEntry);
    String stringMapEntry = (String) mapEntryProc.get("StringMapEntry");
    assertNotSame(stringMapEntry, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMapEntry.length());
    MLText mlTextMapProc = (MLText) mapEntryProc.get("MLText");
    assertNotSame(mlTextMapProc, mlTextMap);
    String stringMLTextMap = mlTextMapProc.get(Locale.ENGLISH);
    assertNotSame(stringMLTextMap, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMLTextMap.length());
    // Check listEntry
    ArrayList<Serializable> listEntryProc = (ArrayList<Serializable>) processed.get("listEntry");
    assertNotSame(listEntryProc, listEntry);
    assertNull(listEntryProc.get(0));
    String stringListEntry = (String) listEntryProc.get(1);
    assertNotSame(stringListEntry, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringListEntry.length());
    MLText mlTextListEntryProc = (MLText) listEntryProc.get(2);
    assertNotSame(mlTextListEntryProc, mlTextListEntry);
    String stringMLTextListEntry = mlTextListEntryProc.get(Locale.ENGLISH);
    assertNotSame(stringMLTextListEntry, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMLTextListEntry.length());
    HashMap<String, Serializable> mapListEntryProc = (HashMap<String, Serializable>) listEntryProc.get(3);
    assertNotSame(mapListEntryProc, mapListEntry);
    String stringMapListEntry = (String) mapListEntryProc.get("StringMapListEntry");
    assertNotSame(stringMapListEntry, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMapListEntry.length());
    ArrayList<Serializable> listProc = (ArrayList<Serializable>) listEntryProc.get(4);
    assertNotSame(listProc, list);
    String stringList = (String) listProc.get(0);
    assertNotSame(stringList, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringList.length());
    MLText mlTextListProc = (MLText) listProc.get(1);
    assertNotSame(mlTextListProc, mlTextList);
    String stringMLTextList = mlTextListProc.get(Locale.ENGLISH);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringMLTextList.length());
    // Check unmodifiableCollection.
    Collection<Serializable> unmdCollectionProc = (Collection<Serializable>) processed.get("unmodifiableCollection");
    assertNotSame(unmdCollectionProc, unmdCollection);
    Object[] array = unmdCollectionProc.toArray();
    String stringUNMDCollection = (String) array[0];
    assertNotSame(stringUNMDCollection, oversizeString);
    assertEquals(SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH, stringUNMDCollection.length());
    // Check that initial string have not been changed
    assertEquals(OVERLIMIT_SIZE, oversizeString.length());
}

6. FullNodeServiceTest#testMultiValueMLTextProperties()

Project: community-edition
File: FullNodeServiceTest.java
@SuppressWarnings("unchecked")
public void testMultiValueMLTextProperties() throws Exception {
    NodeRef nodeRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), TYPE_QNAME_TEST_MANY_ML_PROPERTIES).getChildRef();
    // Create MLText properties and add to a collection
    List<MLText> mlTextCollection = new ArrayList<MLText>(2);
    MLText mlText0 = new MLText();
    mlText0.addValue(Locale.ENGLISH, "Hello");
    mlText0.addValue(Locale.FRENCH, "Bonjour");
    mlTextCollection.add(mlText0);
    MLText mlText1 = new MLText();
    mlText1.addValue(Locale.ENGLISH, "Bye bye");
    mlText1.addValue(Locale.FRENCH, "Au revoir");
    mlTextCollection.add(mlText1);
    nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) mlTextCollection);
    I18NUtil.setContentLocale(Locale.ENGLISH);
    Collection<String> mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Hello", "Bye bye" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.FRENCH);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Bonjour", "Au revoir" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.GERMAN);
    nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) Arrays.asList(new String[] { "eins", "zwei", "drie", "vier" }));
    I18NUtil.setContentLocale(Locale.ENGLISH);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Hello", "Bye bye" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.FRENCH);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Bonjour", "Au revoir" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.GERMAN);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "eins", "zwei", "drie", "vier" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.GERMAN);
    nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) Arrays.asList(new String[] { "eins" }));
    I18NUtil.setContentLocale(Locale.ENGLISH);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Hello", "Bye bye" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.FRENCH);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "Bonjour", "Au revoir" }), mlTextCollectionCheck);
    I18NUtil.setContentLocale(Locale.GERMAN);
    mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[] { "eins" }), mlTextCollectionCheck);
}

7. DbNodeServiceImplTest#testStringIntoMLTextProperty()

Project: community-edition
File: DbNodeServiceImplTest.java
/**
     * Ensure that plain strings going into MLText properties is handled
     */
@SuppressWarnings("unchecked")
public void testStringIntoMLTextProperty() throws Exception {
    String text = "Hello";
    nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text);
    Serializable mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
    assertTrue("Plain string insertion should be returned as MLText", mlTextCheck instanceof MLText);
    Locale defaultLocale = I18NUtil.getLocale();
    MLText mlTextCheck2 = (MLText) mlTextCheck;
    String mlTextDefaultCheck = mlTextCheck2.getDefaultValue();
    assertEquals("Default MLText value was not set correctly", text, mlTextDefaultCheck);
    // Reset the property
    nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, null);
    Serializable nullValueCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
    // Now, just pass a String in
    nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text);
    // Now update the property with some MLText
    MLText mlText = new MLText();
    mlText.addValue(Locale.ENGLISH, "Very good!");
    mlText.addValue(Locale.FRENCH, "Très bon!");
    mlText.addValue(Locale.GERMAN, "Sehr gut!");
    nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText);
    // Get it back and check
    mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
    assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck);
}

8. CopyServiceImplTest#testCopyMLText()

Project: community-edition
File: CopyServiceImplTest.java
/**
     * https://issues.alfresco.com/jira/browse/ALF-3119
     * 
     * Test copying of MLText values.
     */
public void testCopyMLText() {
    // Create a folder and content node        
    Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
    propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
    NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
    Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
    props.put(ContentModel.PROP_NAME, "myDoc.txt");
    String FRENCH_DESCRIPTION = "french description";
    String GERMAN_DESCRIPTION = "german description";
    String ITALY_DESCRIPTION = "italy description";
    String DEFAULT_DESCRIPTION = "default description";
    MLText description = new MLText();
    description.addValue(Locale.getDefault(), DEFAULT_DESCRIPTION);
    description.addValue(Locale.FRANCE, FRENCH_DESCRIPTION);
    description.addValue(Locale.GERMAN, GERMAN_DESCRIPTION);
    description.addValue(Locale.ITALY, ITALY_DESCRIPTION);
    props.put(ContentModel.PROP_DESCRIPTION, description);
    NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
    NodeRef copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
    assertEquals("Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
    QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
    assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
    // Test uses DB Node Service.
    Serializable desc = nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION);
    if (desc instanceof MLText) {
        // Using a node service without a MLProperty interceptor
        MLText value = (MLText) desc;
        assertEquals("French description is wrong", FRENCH_DESCRIPTION, value.get(Locale.FRANCE));
        assertEquals("German description is wrong", GERMAN_DESCRIPTION, value.get(Locale.GERMAN));
    } else {
        I18NUtil.setLocale(Locale.FRANCE);
        assertEquals("French description is wrong", FRENCH_DESCRIPTION, nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION));
        I18NUtil.setLocale(Locale.GERMAN);
        assertEquals("German description is wrong", GERMAN_DESCRIPTION, nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION));
    }
}

9. FullNodeServiceTest#testLongMLTextValues()

Project: community-edition
File: FullNodeServiceTest.java
public void testLongMLTextValues() throws Exception {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 4096; i++) {
        sb.append(" ").append(i);
    }
    String longString = sb.toString();
    // Set the server default locale
    Locale.setDefault(Locale.ENGLISH);
    // Set it as a normal string
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, longString);
    MLText mlTextProperty = new MLText();
    mlTextProperty.addValue(Locale.ENGLISH, longString);
    mlTextProperty.addValue(Locale.FRENCH, longString);
    mlTextProperty.addValue(Locale.GERMAN, longString);
    // Set it as MLText
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty);
}

10. FullNodeServiceTest#testMLTextValues()

Project: community-edition
File: FullNodeServiceTest.java
public void testMLTextValues() throws Exception {
    // Set the server default locale
    Locale.setDefault(Locale.ENGLISH);
    MLText mlTextProperty = new MLText();
    mlTextProperty.addValue(Locale.ENGLISH, "Very good!");
    mlTextProperty.addValue(Locale.FRENCH, "Très bon!");
    mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!");
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty);
    // Check filtered property retrieval
    Serializable textValueFiltered = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertEquals("Default locale value not taken for ML text", mlTextProperty.getValue(Locale.ENGLISH), textValueFiltered);
    // Check filtered mass property retrieval
    Map<QName, Serializable> propertiesFiltered = nodeService.getProperties(rootNodeRef);
    assertEquals("Default locale value not taken for ML text in Map", mlTextProperty.getValue(Locale.ENGLISH), propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
}

11. DbNodeServiceImplTest#testMLTextValues()

Project: community-edition
File: DbNodeServiceImplTest.java
public void testMLTextValues() throws Exception {
    // Set the server default locale
    Locale.setDefault(Locale.ENGLISH);
    MLText mlTextProperty = new MLText();
    mlTextProperty.addValue(Locale.ENGLISH, "Very good!");
    mlTextProperty.addValue(Locale.FRENCH, "Très bon!");
    mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!");
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty);
    // Check unfiltered property retrieval
    Serializable textValueDirect = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertEquals("MLText type not returned direct", mlTextProperty, textValueDirect);
    // Check unfiltered mass property retrieval
    Map<QName, Serializable> propertiesDirect = nodeService.getProperties(rootNodeRef);
    assertEquals("MLText type not returned direct in Map", mlTextProperty, propertiesDirect.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
}

12. OpenCmisQueryTest#makeMLTextMVP()

Project: community-edition
File: OpenCmisQueryTest.java
private ArrayList<MLText> makeMLTextMVP(int position) {
    MLText m1 = new MLText();
    m1.addValue(Locale.ENGLISH, mlOrderable_en[position]);
    MLText m2 = new MLText();
    m2.addValue(Locale.FRENCH, mlOrderable_fr[position]);
    ArrayList<MLText> answer = new ArrayList<MLText>(2);
    answer.add(m1);
    answer.add(m2);
    return answer;
}

13. FullNodeServiceTest#testNullMLText()

Project: community-edition
File: FullNodeServiceTest.java
public void testNullMLText() throws Exception {
    // Set an ML value to null
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null);
    // Get them again
    Serializable mlTextSer = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    MLText mlText = DefaultTypeConverter.INSTANCE.convert(MLText.class, mlTextSer);
    assertNull("Value returned is not null", mlText);
    // Now create an MLText object with a null entry
    mlText = new MLText(null);
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlText);
    MLText mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertNull("MLText value should have been converted to a null String", mlTextCheck);
    // Set an ML value to null
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null);
    // Do the same as ML-aware
    MLPropertyInterceptor.setMLAware(true);
    try {
        mlText = new MLText(null);
        nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlText);
        mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
        assertEquals("MLText value was not pulled out the same as it went in", mlText, mlTextCheck);
        // Set an ML value to null
        nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null);
    } finally {
        // Don't mess up the thread
        MLPropertyInterceptor.setMLAware(false);
    }
}

14. FullNodeServiceTest#testMLTextUpdatedForCorrectLanguage()

Project: community-edition
File: FullNodeServiceTest.java
/**
     * ALF-3756 - original fix didn't cope with existing MLText properties having one or more variants
     * of a particular language. Upgrading to the fix would therefore not solve the problem properly.
     * <p>
     * For example, if a property has en_GB text in it, then 'updating' that property
     * with a locale of en_US will result in the addition of the en_US text rather than a true update (they're both
     * English, and using two slightly differently configured browsers in this way leads to confusion).
     */
public void testMLTextUpdatedForCorrectLanguage() throws Exception {
    Locale.setDefault(Locale.UK);
    MLPropertyInterceptor.setMLAware(true);
    MLText mlTextProperty = new MLText();
    mlTextProperty.addValue(Locale.UK, "en_GB String");
    mlTextProperty.addValue(Locale.FRANCE, "fr_FR String");
    // Store the MLText property
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty);
    // Pre-test check that an MLText property has been created with the correct locale/text pairs.
    Serializable textValue = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertEquals(2, ((MLText) textValue).size());
    assertEquals("en_GB String", ((MLText) textValue).getValue(Locale.UK));
    assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE));
    // Enable MLText filtering - as this is how the repo will be used.
    MLPropertyInterceptor.setMLAware(false);
    // Retrieve the MLText - but it is filtered into an appropriate String
    textValue = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertEquals("en_GB String", (String) textValue);
    // Update the property, only this time using a different English variant
    // en_US
    Locale.setDefault(Locale.US);
    nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Not using MLText for this part.");
    // Check that the text was updated rather than added to
    // no filtering - see real MLText
    MLPropertyInterceptor.setMLAware(true);
    // Check that there are not too many English strings, we don't want one for en_GB and one for en_US
    textValue = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE);
    assertEquals(2, ((MLText) textValue).size());
    assertEquals("Text wasn't updated correctly", "Not using MLText for this part.", ((MLText) textValue).getValue(Locale.ENGLISH));
    assertEquals("Failed to get text using locale it was added with", "Not using MLText for this part.", ((MLText) textValue).getClosestValue(Locale.US));
    assertEquals("Failed to get text using original locale", "Not using MLText for this part.", ((MLText) textValue).getClosestValue(Locale.UK));
    assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE));
}

15. DbNodeServiceImplTest#testSingleStringMLTextProperty()

Project: community-edition
File: DbNodeServiceImplTest.java
/**
     * Ensure that plain strings going into MLText properties is handled
     */
@SuppressWarnings("unchecked")
public void testSingleStringMLTextProperty() throws Exception {
    // Set the property with single-value MLText
    MLText mlText = new MLText();
    mlText.addValue(Locale.GERMAN, "Sehr gut!");
    nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText);
    // Get it back and check
    MLText mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE);
    assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck);
}

16. ExporterComponentTest#testMLText()

Project: community-edition
File: ExporterComponentTest.java
public void testMLText() throws Exception {
    NodeRef rootNode = nodeService.getRootNode(storeRef);
    NodeRef folderNodeRef = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_FOLDER).getChildRef();
    FileInfo exportFolder = fileFolderService.create(folderNodeRef, "export", ContentModel.TYPE_FOLDER);
    FileInfo content = fileFolderService.create(exportFolder.getNodeRef(), "file", ContentModel.TYPE_CONTENT);
    MLText title = new MLText();
    title.addValue(Locale.ENGLISH, null);
    title.addValue(Locale.FRENCH, "bonjour");
    nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_TITLE, title);
    nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_NAME, "file");
    FileInfo importFolder = fileFolderService.create(folderNodeRef, "import", ContentModel.TYPE_FOLDER);
    // export
    File acpFile = exportContent(exportFolder.getNodeRef());
    // import
    FileInfo importFolderFileInfo = importContent(acpFile, importFolder.getNodeRef());
    assertNotNull(importFolderFileInfo);
    NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "file");
    assertNotNull("Couldn't find imported file: file", importedFileNode);
    Locale currentLocale = I18NUtil.getContentLocale();
    try {
        I18NUtil.setContentLocale(Locale.ENGLISH);
        String importedTitle = (String) nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE);
        assertNull(importedTitle);
        I18NUtil.setContentLocale(Locale.FRENCH);
        importedTitle = (String) nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE);
        assertNotNull(importedTitle);
        assertEquals("bonjour", importedTitle);
    } finally {
        I18NUtil.setContentLocale(currentLocale);
    }
}

17. OpenCmisQueryTest#makeMLText()

Project: community-edition
File: OpenCmisQueryTest.java
private MLText makeMLText(int position) {
    MLText ml = new MLText();
    ml.addValue(Locale.ENGLISH, mlOrderable_en[position]);
    ml.addValue(Locale.FRENCH, mlOrderable_fr[position]);
    return ml;
}

18. OpenCmisQueryTest#addTypeTestData()

Project: community-edition
File: OpenCmisQueryTest.java
private NodeRef addTypeTestData() {
    addTypeTestDataModel();
    I18NUtil.setLocale(Locale.UK);
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
    MLText ml = new MLText();
    ml.addValue(Locale.ENGLISH, "Test one");
    ml.addValue(Locale.US, "Test 1");
    properties.put(ContentModel.PROP_DESCRIPTION, ml);
    properties.put(ContentModel.PROP_TITLE, ml);
    properties.put(ContentModel.PROP_NAME, "Test one");
    properties.put(ContentModel.PROP_CREATED, new Date());
    properties.put(singleTextUntokenised, "Un tokenised");
    properties.put(singleTextTokenised, "Un tokenised");
    properties.put(singleTextBoth, "Un tokenised");
    properties.put(multipleTextUntokenised, asArray("Un tokenised", "two parts"));
    properties.put(multipleTextTokenised, asArray("Un tokenised", "two parts"));
    properties.put(multipleTextBoth, asArray("Un tokenised", "two parts"));
    properties.put(singleMLTextUntokenised, makeMLText());
    properties.put(singleMLTextTokenised, makeMLText());
    properties.put(singleMLTextBoth, makeMLText());
    properties.put(multipleMLTextUntokenised, makeMLTextMVP());
    properties.put(multipleMLTextTokenised, makeMLTextMVP());
    properties.put(multipleMLTextBoth, makeMLTextMVP());
    properties.put(singleFloat, 1f);
    properties.put(multipleFloat, asArray(1f, 1.1f));
    properties.put(singleDouble, 1d);
    properties.put(multipleDouble, asArray(1d, 1.1d));
    properties.put(singleInteger, 1);
    properties.put(multipleInteger, asArray(1, 2));
    properties.put(singleLong, 1l);
    properties.put(multipleLong, asArray(1l, 2l));
    date1 = new Date();
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date1);
    cal.add(Calendar.DAY_OF_MONTH, -1);
    date0 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 2);
    date2 = cal.getTime();
    properties.put(singleDate, date1);
    properties.put(multipleDate, asArray(date1, date2));
    properties.put(singleDatetime, date1);
    properties.put(multipleDatetime, asArray(date1, date2));
    properties.put(singleBoolean, true);
    properties.put(multipleBoolean, asArray(true, false));
    NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CONTAINS, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef();
    return c0;
}

19. CheckOutCheckInServiceImplTest#testDeleteUpdateOriginalOfCheckedOutDocument()

Project: community-edition
File: CheckOutCheckInServiceImplTest.java
/**
     * MNT-2641 
     */
public void testDeleteUpdateOriginalOfCheckedOutDocument() {
    // Create a FolderA
    final NodeRef folderA = createFolder("DeleteUpdateOriginalOfCheckedOutDocument_" + GUID.generate());
    // Create content in FolderA
    final NodeRef orig = createContent("original_" + GUID.generate(), folderA);
    // Check out the document
    NodeRef workingCopy = this.cociService.checkout(orig);
    assertNotNull(workingCopy);
    boolean thrown = false;
    // try to delete original, that has working copy - must be denied
    try {
        fileFolderService.delete(orig);
    } catch (NodeLockedException e) {
        thrown = true;
    }
    assertTrue("No one should be able to delete the original", thrown);
    // creating a properties
    final Map<QName, Serializable> propsToPersist = new HashMap<QName, Serializable>(3);
    MLText value = new MLText(Locale.ENGLISH, GUID.generate() + "");
    propsToPersist.put(ContentModel.PROP_DESCRIPTION, value);
    value = new MLText(Locale.ENGLISH, null);
    propsToPersist.put(ContentModel.PROP_TITLE, value);
    // try to modify properties of original, that has working copy - must be denied
    thrown = false;
    try {
        nodeService.addProperties(orig, propsToPersist);
    } catch (NodeLockedException e) {
        thrown = true;
    }
    assertTrue("No one should be able to update the original", thrown);
    // ////////////////////////////////////////////////////////////
    // testing "delete" and "update" actions with non-owner user //
    // ////////////////////////////////////////////////////////////
    // create another person
    final String denyUser = "COCITestUser123";
    createPerson(denyUser);
    // try to delete original, that has working copy - must be denied
    thrown = false;
    try {
        AuthenticationUtil.runAs(new RunAsWork<NodeRef>() {

            @Override
            public NodeRef doWork() throws Exception {
                fileFolderService.delete(orig);
                return null;
            }
        }, denyUser);
    } catch (AccessDeniedException e) {
        thrown = true;
    } catch (org.alfresco.repo.security.permissions.AccessDeniedException e) {
        thrown = true;
    }
    assertTrue(thrown);
    // try to delete original, that has working copy - must be denied
    thrown = false;
    try {
        AuthenticationUtil.runAs(new RunAsWork<Void>() {

            @Override
            public Void doWork() throws Exception {
                nodeService.addProperties(orig, propsToPersist);
                return null;
            }
        }, denyUser);
    } catch (AccessDeniedException e) {
        thrown = true;
    } catch (org.alfresco.repo.security.permissions.AccessDeniedException e) {
        thrown = true;
    } catch (NodeLockedException e) {
        thrown = true;
    }
    assertTrue(thrown);
}

20. OpenCmisQueryTest#addSortableNode()

Project: community-edition
File: OpenCmisQueryTest.java
private NodeRef addSortableNode(int position) {
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
    MLText ml = new MLText();
    ml.addValue(Locale.ENGLISH, "Test " + position);
    properties.put(ContentModel.PROP_DESCRIPTION, ml);
    properties.put(ContentModel.PROP_TITLE, ml);
    properties.put(ContentModel.PROP_NAME, "Test " + position);
    properties.put(ContentModel.PROP_CREATED, new Date());
    properties.put(singleTextUntokenised, orderable[position]);
    properties.put(singleTextTokenised, orderable[position]);
    properties.put(singleTextBoth, orderable[position]);
    properties.put(multipleTextUntokenised, asArray(orderable[position], orderable[position + 1]));
    properties.put(multipleTextTokenised, asArray(orderable[position], orderable[position + 1]));
    properties.put(multipleTextBoth, asArray(orderable[position], orderable[position + 1]));
    properties.put(singleMLTextUntokenised, makeMLText(position));
    properties.put(singleMLTextTokenised, makeMLText(position));
    properties.put(singleMLTextBoth, makeMLText(position));
    properties.put(multipleMLTextUntokenised, makeMLTextMVP(position));
    properties.put(multipleMLTextTokenised, makeMLTextMVP(position));
    properties.put(multipleMLTextBoth, makeMLTextMVP(position));
    properties.put(singleFloat, 1.1f * position);
    properties.put(multipleFloat, asArray(1.1f * position, 2.2f * position));
    properties.put(singleDouble, 1.1d * position);
    properties.put(multipleDouble, asArray(1.1d * position, 2.2d * position));
    properties.put(singleInteger, 1 * position);
    properties.put(multipleInteger, asArray(1 * position, 2 * position));
    properties.put(singleLong, 1l * position);
    properties.put(multipleLong, asArray(1l * position, 2l * position));
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date());
    cal.add(Calendar.DAY_OF_MONTH, position);
    Date d1 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, -1);
    // Date d0 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 2);
    Date d2 = cal.getTime();
    properties.put(singleDate, d1);
    properties.put(multipleDate, asArray(d1, d2));
    properties.put(singleDatetime, d1);
    properties.put(multipleDatetime, asArray(d1, d2));
    properties.put(singleBoolean, position % 2 == 0 ? true : false);
    properties.put(multipleBoolean, asArray(true, false));
    NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CONTAINS, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef();
    return c0;
}

21. DefaultTypeConverterTest#testToString()

Project: community-edition
File: DefaultTypeConverterTest.java
public void testToString() {
    assertEquals("true", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(true)));
    assertEquals("false", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(false)));
    assertEquals("v", DefaultTypeConverter.INSTANCE.convert(String.class, Character.valueOf('v')));
    assertEquals("3", DefaultTypeConverter.INSTANCE.convert(String.class, Byte.valueOf("3")));
    assertEquals("4", DefaultTypeConverter.INSTANCE.convert(String.class, Short.valueOf("4")));
    assertEquals("5", DefaultTypeConverter.INSTANCE.convert(String.class, Integer.valueOf("5")));
    assertEquals("6", DefaultTypeConverter.INSTANCE.convert(String.class, Long.valueOf("6")));
    assertEquals("7.1", DefaultTypeConverter.INSTANCE.convert(String.class, Float.valueOf("7.1")));
    assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NaN));
    assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NEGATIVE_INFINITY));
    assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.POSITIVE_INFINITY));
    assertEquals("123.123", DefaultTypeConverter.INSTANCE.convert(String.class, Double.valueOf("123.123")));
    assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NaN));
    assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NEGATIVE_INFINITY));
    assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.POSITIVE_INFINITY));
    assertEquals("1234567890123456789", DefaultTypeConverter.INSTANCE.convert(String.class, new BigInteger("1234567890123456789")));
    assertEquals("12345678901234567890.12345678901234567890", DefaultTypeConverter.INSTANCE.convert(String.class, new BigDecimal("12345678901234567890.12345678901234567890")));
    Date date = new Date();
    assertEquals(ISO8601DateFormat.format(date), DefaultTypeConverter.INSTANCE.convert(String.class, date));
    assertEquals("P0Y25D", DefaultTypeConverter.INSTANCE.convert(String.class, new Duration("P0Y25D")));
    assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, "woof"));
    // MLText
    MLText mlText = new MLText("woof");
    mlText.addValue(Locale.SIMPLIFIED_CHINESE, "?");
    assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, mlText));
    // Locale
    assertEquals("fr_FR_", DefaultTypeConverter.INSTANCE.convert(String.class, Locale.FRANCE));
    // VersionNumber
    assertEquals("1.2.3", DefaultTypeConverter.INSTANCE.convert(String.class, new VersionNumber("1.2.3")));
    // Period
    assertEquals("period", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period")));
    assertEquals("period|12", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period|12")));
    // Java Class
    assertEquals(this.getClass(), DefaultTypeConverter.INSTANCE.convert(Class.class, this.getClass().getName()));
}

22. FullNodeServiceTest#getExpectedPropertyValues()

Project: community-edition
File: FullNodeServiceTest.java
/**
     * {@inheritDoc}
     * 
     * This instance modifies the ML text value to be just the default locale string.
     */
protected void getExpectedPropertyValues(Map<QName, Serializable> checkProperties) {
    MLText mlTextValue = (MLText) checkProperties.get(PROP_QNAME_ML_TEXT_VALUE);
    String strValue = mlTextValue.getDefaultValue();
    checkProperties.put(PROP_QNAME_ML_TEXT_VALUE, strValue);
}

23. FullNodeServiceTest#testMLTextCollectionUpdatedForCorrectLanguage()

Project: community-edition
File: FullNodeServiceTest.java
@SuppressWarnings("unchecked")
public void testMLTextCollectionUpdatedForCorrectLanguage() {
    Locale.setDefault(Locale.UK);
    MLPropertyInterceptor.setMLAware(true);
    ArrayList<Serializable> values = new ArrayList<Serializable>();
    values.add(new MLText(Locale.UK, "en_GB text"));
    values.add(new MLText(Locale.US, "en_US text"));
    values.add(new MLText(Locale.FRANCE, "fr_FR text"));
    // Set the property with no MLText filtering
    nodeService.setProperty(rootNodeRef, PROP_QNAME_MULTI_ML_VALUE, values);
    // Pre-test check
    List<Serializable> checkValues = (List<Serializable>) nodeService.getProperty(rootNodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("Expected 3 MLText values back", 3, checkValues.size());
    assertEquals("en_GB text", ((MLText) checkValues.get(0)).getValue(Locale.UK));
    assertEquals("en_US text", ((MLText) checkValues.get(1)).getValue(Locale.US));
    assertEquals("fr_FR text", ((MLText) checkValues.get(2)).getValue(Locale.FRANCE));
    // Enable MLText filtering - as this is how the repo will be used.
    MLPropertyInterceptor.setMLAware(false);
    // Filtering will result in a list containing en_GB only
    checkValues = (List<Serializable>) nodeService.getProperty(rootNodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("Expected 1 MLText values back", 1, checkValues.size());
    assertEquals("en_GB text", (String) checkValues.get(0));
    // Update the property, only this time using a different English variant
    // en_US
    Locale.setDefault(Locale.US);
    values.clear();
    values.add("text 1 added using en_US");
    values.add("text 2 added using en_US");
    values.add("text 3 added using en_US");
    values.add("text 4 added using en_US");
    nodeService.setProperty(rootNodeRef, PROP_QNAME_MULTI_ML_VALUE, values);
    // Check that the text was updated correctly
    // no filtering - see real MLText
    MLPropertyInterceptor.setMLAware(true);
    checkValues = (List<Serializable>) nodeService.getProperty(rootNodeRef, PROP_QNAME_MULTI_ML_VALUE);
    assertEquals("Expected 3 MLText values back", 4, checkValues.size());
    MLText mlText = ((MLText) checkValues.get(0));
    assertEquals("en_GB should be replaced with new, not added to", 1, mlText.size());
    assertEquals("text 1 added using en_US", mlText.getValue(Locale.ENGLISH));
    mlText = ((MLText) checkValues.get(1));
    assertEquals("en_US should be replaced with new, not added to", 1, mlText.size());
    assertEquals("text 2 added using en_US", mlText.getValue(Locale.ENGLISH));
    mlText = ((MLText) checkValues.get(2));
    assertEquals("en_US should be added to fr_FR", 2, mlText.size());
    assertEquals("fr_FR text", mlText.getValue(Locale.FRANCE));
    assertEquals("text 3 added using en_US", mlText.getValue(Locale.ENGLISH));
    mlText = ((MLText) checkValues.get(3));
    assertEquals("entirely new text value should be added", 1, mlText.size());
    assertEquals("text 4 added using en_US", mlText.getValue(Locale.ENGLISH));
}

24. DefaultTypeConverterTest#testFromString()

Project: community-edition
File: DefaultTypeConverterTest.java
public void testFromString() {
    assertEquals(Boolean.valueOf(true), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "True"));
    assertEquals(Boolean.valueOf(false), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "woof"));
    assertEquals(Character.valueOf('w'), DefaultTypeConverter.INSTANCE.convert(Character.class, "w"));
    assertEquals(Byte.valueOf("3"), DefaultTypeConverter.INSTANCE.convert(Byte.class, "3"));
    assertEquals(Short.valueOf("4"), DefaultTypeConverter.INSTANCE.convert(Short.class, "4"));
    assertEquals(Integer.valueOf("5"), DefaultTypeConverter.INSTANCE.convert(Integer.class, "5"));
    assertEquals(Long.valueOf("6"), DefaultTypeConverter.INSTANCE.convert(Long.class, "6"));
    assertEquals(Float.valueOf("7.1"), DefaultTypeConverter.INSTANCE.convert(Float.class, "7.1"));
    assertEquals(Float.NaN, DefaultTypeConverter.INSTANCE.convert(Float.class, "NaN"));
    assertEquals(Float.NEGATIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Float.class, "-Infinity"));
    assertEquals(Float.POSITIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Float.class, "Infinity"));
    assertEquals(Double.valueOf("123.123"), DefaultTypeConverter.INSTANCE.convert(Double.class, "123.123"));
    assertEquals(Double.NaN, DefaultTypeConverter.INSTANCE.convert(Double.class, "NaN"));
    assertEquals(Double.NEGATIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Double.class, "-Infinity"));
    assertEquals(Double.POSITIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Double.class, "Infinity"));
    assertEquals(new BigInteger("1234567890123456789"), DefaultTypeConverter.INSTANCE.convert(BigInteger.class, "1234567890123456789"));
    assertEquals(new BigDecimal("12345678901234567890.12345678901234567890"), DefaultTypeConverter.INSTANCE.convert(BigDecimal.class, "12345678901234567890.12345678901234567890"));
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(Calendar.YEAR, 2004);
    cal.set(Calendar.MONTH, 3);
    cal.set(Calendar.DAY_OF_MONTH, 12);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    String isoDate = ISO8601DateFormat.format(cal.getTime());
    assertEquals(isoDate, ISO8601DateFormat.format(DefaultTypeConverter.INSTANCE.convert(Date.class, isoDate)));
    assertEquals(new Duration("P25D"), DefaultTypeConverter.INSTANCE.convert(Duration.class, "P25D"));
    assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, "woof"));
    MLText converted = DefaultTypeConverter.INSTANCE.convert(MLText.class, "woof");
    assertEquals("woof", converted.getValue(Locale.getDefault()));
    assertEquals(Locale.FRANCE, DefaultTypeConverter.INSTANCE.convert(Locale.class, "fr_FR"));
    assertEquals(Locale.FRANCE, DefaultTypeConverter.INSTANCE.convert(Locale.class, "fr_FR_"));
    assertEquals(new VersionNumber("1.2.3"), DefaultTypeConverter.INSTANCE.convert(VersionNumber.class, "1.2.3"));
    assertEquals(new Period("period"), DefaultTypeConverter.INSTANCE.convert(Period.class, "period"));
    assertEquals(new Period("period|12"), DefaultTypeConverter.INSTANCE.convert(Period.class, "period|12"));
    // Java Class
    assertEquals(this.getClass().getName(), DefaultTypeConverter.INSTANCE.convert(String.class, this.getClass()));
}