Example usage for java.util Locale ITALY

List of usage examples for java.util Locale ITALY

Introduction

In this page you can find the example usage for java.util Locale ITALY.

Prototype

Locale ITALY

To view the source code for java.util Locale ITALY.

Click Source Link

Document

Useful constant for country.

Usage

From source file:org.jfree.data.time.junit.MonthTest.java

/**
 * Some checks for the getEnd() method./*from w w  w .  j  a  v a2 s . c om*/
 */
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Month m = new Month(1, 2006);
    assertEquals(cal.getTime(), m.getEnd());
    Locale.setDefault(saved);
}

From source file:org.alfresco.repo.node.NodeServiceTest.java

@Test
public void testLocaleSupport() throws Exception {
    // Ensure that the root node has the default locale
    Locale locale = (Locale) nodeService.getProperty(rootNodeRef, ContentModel.PROP_LOCALE);
    assertNotNull("Locale property must occur on every node", locale);
    assertEquals("Expected default locale on the root node", I18NUtil.getLocale(), locale);
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(rootNodeRef, ContentModel.ASPECT_LOCALIZED));

    // Now switch to a specific locale and create a new node
    I18NUtil.setLocale(Locale.CANADA_FRENCH);

    // Create a node using an explicit locale
    NodeRef nodeRef1 = nodeService//from  w w w  .j  a v a 2  s  . c  o  m
            .createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
                    QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
                    ContentModel.TYPE_CONTAINER,
                    Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) Locale.GERMAN))
            .getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef1, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the explicit locale during create. ", Locale.GERMAN,
            nodeService.getProperty(nodeRef1, ContentModel.PROP_LOCALE));

    // Create a node using the thread's locale
    NodeRef nodeRef2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
            ContentModel.TYPE_CONTAINER).getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the locale during create. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Switch Locale and modify ml:text property
    I18NUtil.setLocale(Locale.CHINESE);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "Chinese description");
    I18NUtil.setLocale(Locale.FRENCH);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "French description");

    // Expect that we have MLText (if we are ML aware)
    boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
    try {
        MLText checkDescription = (MLText) nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION);
        assertEquals("Chinese description", checkDescription.getValue(Locale.CHINESE));
        assertEquals("French description", checkDescription.getValue(Locale.FRENCH));
    } finally {
        MLPropertyInterceptor.setMLAware(wasMLAware);
    }
    // But the node locale must not have changed
    assertEquals("Node modification should not affect node locale. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Now explicitly set the node's locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, Locale.ITALY);
    assertEquals("Node locale must be settable. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    // But mltext must be unchanged
    assertEquals("Canada-French must be closest to French. ", "French description",
            nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION));

    // Finally, ensure that setting Locale to 'null' is takes the node back to its original locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, null);
    assertEquals("Node locale set to 'null' does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    nodeService.removeProperty(nodeRef2, ContentModel.PROP_LOCALE);
    assertEquals("Node locale removal does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Mass-set the properties, changing the locale in the process
    Map<QName, Serializable> props = nodeService.getProperties(nodeRef2);
    props.put(ContentModel.PROP_LOCALE, Locale.GERMAN);
    nodeService.setProperties(nodeRef2, props);
    assertEquals("Node locale not set in setProperties(). ", Locale.GERMAN,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
}

From source file:it.publisys.liferay.hook.shibboleth.ShibbolethAutoLogin.java

/**
 * Creazione di un nuovo utente utilizzando gli attributi inoltrati dallo ShibbolethSP
 *
 * @param companyId companyId//  w  w w.j a va 2  s . c  o  m
 * @param request   companyId
 * @return User
 * @throws AutoLoginException
 */
private User _createNewUser(long companyId, HttpServletRequest request) throws AutoLoginException {
    if (_log.isDebugEnabled())
        _log.debug("[START] Nuovo utente");

    try {
        long creatorUserId = 0;
        boolean autoPassword = true;
        String password1 = UUID.randomUUID().toString().replaceAll("-", "");
        Locale locale = Locale.ITALY;//PortalUtil.getLocale(request);
        //
        String emailAddress = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_EMAIL);

        String username = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_FISCAL_NUMBER);
        username = username.toUpperCase();

        String firstname = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_NAME);
        String middlename = null;
        String lastname = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_FAMILY_NAME);
        boolean male = !"F".equalsIgnoreCase(request.getHeader(ShibbolethPropsValues.SHIBBOLETH_GENDER));

        if (_log.isDebugEnabled())
            _log.debug("Caricati i dati dall'header.");

        // ddn
        String _ddnStr = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_DATE_OF_BIRTH);
        int birthdayDay = 1;
        int birthdayMonth = 0;
        int birthdayYear = 1970;
        if (Validator.isNotNull(_ddnStr)) {
            try {
                Date _ddn = _parseDate(_ddnStr);
                if (_ddn != null) {
                    Calendar _ddnCal = Calendar.getInstance();
                    _ddnCal.setTime(_ddn);
                    birthdayDay = _ddnCal.get(Calendar.DAY_OF_MONTH);
                    birthdayMonth = _ddnCal.get(Calendar.MONTH);
                    birthdayYear = _ddnCal.get(Calendar.YEAR);

                    if (_log.isDebugEnabled())
                        _log.debug("Caricata data di nascita.");
                }
            } catch (Exception e) {
                e.printStackTrace(System.out);
            }
        }

        //
        String jobTitle = null;
        //
        long facebookId = 0;
        String openId = "";
        int prefixId = 0;
        int suffixId = 0;
        //
        boolean sendEmail = false;
        boolean autoScreenName = false;
        //
        long[] groupIds = null;
        long[] organizationIds = null;
        long[] roleIds = null;
        long[] userGroupIds = null;
        ServiceContext serviceContext = new ServiceContext();

        User user = UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password1, password1,
                autoScreenName, username, emailAddress, facebookId, openId, locale, firstname, middlename,
                lastname, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
                groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

        _log.info("Nuovo utente creato: " + user.getUserId());

        return user;
    } catch (PortalException e) {
        _log.error("Method addUser launched a PortalException.", e);
        e.printStackTrace(System.out);
        SessionMessages.add(request, "shibbError",
                "Si &egrave; verificato un errore durante la configurazione dell'account. [Codice:PE]");
        throw new AutoLoginException(e);
    } catch (SystemException e) {
        _log.error("Method addUser launched a SystemException.", e);
        e.printStackTrace(System.out);
        SessionMessages.add(request, "shibbError",
                "Si &egrave; verificato un errore durante la configurazione dell'account. [Codice:SE]");
        throw new AutoLoginException(e);
    } catch (RuntimeException e) {
        _log.error("Method addUser launched a Exception.", e);
        e.printStackTrace(System.out);
        SessionMessages.add(request, "shibbError",
                "Si &egrave; verificato un errore durante la creazione dell'account. [Codice:E]");
        throw new AutoLoginException(e);
    } catch (Exception e) {
        _log.error("Method addUser launched a Exception.", e);
        e.printStackTrace(System.out);
        SessionMessages.add(request, "shibbError",
                "Si &egrave; verificato un errore durante la creazione dell'account. [Codice:E]");
        throw new AutoLoginException(e);
    }
}

From source file:org.jfree.data.time.WeekTest.java

/**
 * Some checks for the getStart() method.
 *///from  ww w. java 2 s.c o  m
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Week w = new Week(3, 2006);
    assertEquals(cal.getTime(), w.getStart());
    Locale.setDefault(saved);
}

From source file:org.jfree.data.time.WeekTest.java

/**
 * Some checks for the getEnd() method.//from  ww w  .  j  a v  a  2  s  .c om
 */
@Test
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 8, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Week w = new Week(1, 2006);
    assertEquals(cal.getTime(), w.getEnd());
    Locale.setDefault(saved);
}

From source file:net.sourceforge.eclipsetrader.yahoo.ItalianNewsProvider.java

private Date parseDateString(String date) {
    Calendar gc = Calendar.getInstance(Locale.ITALY);
    StringTokenizer st = new StringTokenizer(date, " ,:"); //$NON-NLS-1$
    st.nextToken();/*w w  w.ja va 2  s.  com*/
    Integer vint = new Integer(st.nextToken());
    gc.set(Calendar.DAY_OF_MONTH, vint.intValue());
    gc.set(Calendar.MONTH, getMonth(st.nextToken()) - 1);
    vint = new Integer(st.nextToken());
    gc.set(Calendar.YEAR, vint.intValue());
    vint = new Integer(st.nextToken());
    gc.set(Calendar.HOUR_OF_DAY, vint.intValue());
    vint = new Integer(st.nextToken());
    gc.set(Calendar.MINUTE, vint.intValue());
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    return gc.getTime();
}

From source file:org.alfresco.filesys.repo.ContentDiskDriverTest.java

/**
 * This test tries to simulate the shuffling that is done by MS Word 2003 upon file save
 * /*  www. ja  v a  2 s. c  om*/
 * a) TEST.DOC
 * b) Save to ~WRDnnnn.TMP
 * c) Delete ~WRLnnnn.TMP
 * d) Rename TEST.DOC ~WDLnnnn.TMP
 * e) Delete TEST.DOC
 * f) Rename ~WRDnnnn.TMP to TEST.DOC
 * g) Delete ~WRLnnnn.TMP
 * 
 * We need to check that properties, aspects, primary assocs, secondary assocs, peer assocs, node type, 
 * version history, creation date are maintained.
 */
public void testScenarioMSWord2003SaveShuffle() throws Exception {
    logger.debug("testScenarioMSWord2003SaveShuffle");
    final String FILE_NAME = "TEST.DOC";
    final String FILE_TITLE = "Test document";
    final String FILE_DESCRIPTION = "This is a test document to test CIFS shuffle";
    final String FILE_OLD_TEMP = "~WRL0002.TMP";
    final String FILE_NEW_TEMP = "~WRD0002.TMP";

    final QName RESIDUAL_MTTEXT = QName.createQName("{gsxhjsx}", "whatever");

    class TestContext {
        NetworkFile firstFileHandle;
        NetworkFile newFileHandle;
        NetworkFile oldFileHandle;

        NodeRef testNodeRef; // node ref of test.doc

        Serializable testCreatedDate;
    }
    ;

    final TestContext testContext = new TestContext();

    final String TEST_DIR = TEST_ROOT_DOS_PATH + "\\testScenarioMSWord2003SaveShuffle";

    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);

    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteGarbageFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    /**
     * Create a file in the test directory
     */

    try {
        tran.doInTransaction(deleteGarbageFileCB);
    } catch (Exception e) {
        // expect to go here
    }

    RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {

            /**
             * Create the test directory we are going to use 
             */
            FileOpenParams createRootDirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            FileOpenParams createDirParams = new FileOpenParams(TEST_DIR, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            driver.createDirectory(testSession, testConnection, createRootDirParams);
            driver.createDirectory(testSession, testConnection, createDirParams);

            /**
             * Create the file we are going to use
             */
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.firstFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.firstFileHandle);

            // now load up the node with lots of other stuff that we will test to see if it gets preserved during the
            // shuffle.
            testContext.testNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            // test non CM namespace property
            nodeService.setProperty(testContext.testNodeRef, TransferModel.PROP_ENABLED, true);
            // test CM property not related to an aspect
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_ADDRESSEE, "Fred");

            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_TITLE, FILE_TITLE);
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_DESCRIPTION, FILE_DESCRIPTION);

            /**
             * MLText value - also a residual value in a non cm namespace
             */
            MLText mltext = new MLText();
            mltext.addValue(Locale.FRENCH, "Bonjour");
            mltext.addValue(Locale.ENGLISH, "Hello");
            mltext.addValue(Locale.ITALY, "Buongiorno");
            mlAwareNodeService.setProperty(testContext.testNodeRef, RESIDUAL_MTTEXT, mltext);

            // classifiable chosen since its not related to any properties.
            nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_CLASSIFIABLE, null);
            //nodeService.createAssociation(testContext.testNodeRef, targetRef, assocTypeQName);

            return null;
        }
    };
    tran.doInTransaction(createFileCB, false, true);

    /**
     * Write some content to the test file
     */
    RetryingTransactionCallback<Void> writeFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            String testContent = "MS Word 2003 shuffle test";
            byte[] testContentBytes = testContent.getBytes();
            testContext.firstFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.firstFileHandle.close();

            testContext.testCreatedDate = nodeService.getProperty(testContext.testNodeRef,
                    ContentModel.PROP_CREATED);

            MLText multi = (MLText) mlAwareNodeService.getProperty(testContext.testNodeRef, RESIDUAL_MTTEXT);
            multi.getValues();

            return null;
        }
    };
    tran.doInTransaction(writeFileCB, false, true);

    /**
     * b) Save the new file
     */
    RetryingTransactionCallback<Void> saveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NEW_TEMP, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.newFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.newFileHandle);
            String testContent = "MS Word 2003 shuffle test This is new content";
            byte[] testContentBytes = testContent.getBytes();
            testContext.newFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.newFileHandle.close();

            return null;
        }
    };
    tran.doInTransaction(saveNewFileCB, false, true);

    /**
     * rename the old file
     */
    RetryingTransactionCallback<Void> renameOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME,
                    TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };
    tran.doInTransaction(renameOldFileCB, false, true);

    RetryingTransactionCallback<Void> validateOldFileGoneCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            try {
                driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            } catch (IOException e) {
                // expect to go here since previous step renamed the file.
            }

            return null;
        }
    };
    tran.doInTransaction(validateOldFileGoneCB, false, true);

    logger.debug("Shuffle step next");
    /**
     * Move the new file into place, stuff should get shuffled
     */
    RetryingTransactionCallback<Void> moveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NEW_TEMP,
                    TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    tran.doInTransaction(moveNewFileCB, false, true);
    logger.debug("end of shuffle step");

    RetryingTransactionCallback<Void> validateCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            NodeRef shuffledNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            Map<QName, Serializable> props = nodeService.getProperties(shuffledNodeRef);

            // Check trx:enabled has been shuffled.
            assertTrue("node does not contain shuffled ENABLED property",
                    props.containsKey(TransferModel.PROP_ENABLED));
            // check my residual MLText has been transferred
            assertTrue(props.containsKey(RESIDUAL_MTTEXT));

            // Check the titled aspect is correct
            assertEquals("name wrong", FILE_NAME,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_NAME));
            assertEquals("title wrong", FILE_TITLE,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_TITLE));
            assertEquals("description wrong", FILE_DESCRIPTION,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_DESCRIPTION));

            // ALF-7641 - CIFS shuffle, does not preseve MLText values.
            Map<QName, Serializable> mlProps = mlAwareNodeService.getProperties(shuffledNodeRef);

            MLText multi = (MLText) mlAwareNodeService.getProperty(shuffledNodeRef, RESIDUAL_MTTEXT);
            assertTrue("MLText has lost values", multi.getValues().size() > 2);

            //               // ALF-7635 check auditable properties 
            assertEquals("creation date not preserved",
                    ((java.util.Date) testContext.testCreatedDate).getTime(),
                    ((java.util.Date) nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_CREATED))
                            .getTime());

            // ALF-7628 - preserve addressee and classifiable
            assertEquals("ADDRESSEE PROPERTY Not copied", "Fred",
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_ADDRESSEE));
            assertTrue("CLASSIFIABLE aspect not present",
                    nodeService.hasAspect(shuffledNodeRef, ContentModel.ASPECT_CLASSIFIABLE));

            // ALF-7584 - preserve node ref.
            assertEquals("noderef changed", testContext.testNodeRef, shuffledNodeRef);
            return null;
        }
    };

    tran.doInTransaction(validateCB, true, true);

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };

    tran.doInTransaction(deleteOldFileCB, false, true);

}

From source file:eu.cloud4soa.soa.jaxrs.test.Initializer.java

private void createDeveloperInstance() {
    developerInstance = new DeveloperInstance();
    developerInstance.setFirstName("Francesco");
    developerInstance.setFamilyname("D'Andria");
    developerInstance.setGeekcode("fdandria");
    developerInstance.setSurname("D'Andria");
    Calendar calendar = Calendar.getInstance(Locale.ITALY);
    calendar.set(1974, 4, 11);//  w ww. java2s  . c  om
    developerInstance.setBirthday(calendar.getTime());
    //        Cloud4SoaAccountInstance cloud4SoaAccountInstance = new Cloud4SoaAccountInstance();
    //        cloud4SoaAccountInstance.setAccountname("fdandria");
    //        developerInstance.setHoldsaccount(cloud4SoaAccountInstance);
    developerUsername = "fdandria";
    developerPassword = "fdandriaPassword";
}

From source file:org.alfresco.filesys.repo.ContentDiskDriverTest.java

/**
 * Excel 2003 With Versionable file/*from   www . ja v a 2s. c  om*/
 *
 * CreateFile 5EE27100
 * RenameFile oldPath:\Espaces Utilisateurs\System\Cherries.xls, 
 *          newPath:\Espaces Utilisateurs\System\Cherries.xls~RF172f241.TMP
 * RenameFile oldName=\Espaces Utilisateurs\System\5EE27100, 
 *          newName=\Espaces Utilisateurs\System\Cherries.xls, session:WNB0
 *
 * Set Delete On Close for Cherries.xls~RF172f241.TMP
 */
public void testExcel2003SaveShuffle() throws Exception {
    //fail("not yet implemented");
    logger.debug("testScenarioExcel2003SaveShuffle");
    final String FILE_NAME = "Cherries.xls";
    final String FILE_TITLE = "Cherries";
    final String FILE_DESCRIPTION = "This is a test document to test CIFS shuffle";
    final String FILE_OLD_TEMP = "Cherries.xls~RF172f241.TMP";
    final String FILE_NEW_TEMP = "5EE27100";

    final QName RESIDUAL_MTTEXT = QName.createQName("{gsxhjsx}", "whatever");

    class TestContext {
        NetworkFile firstFileHandle;
        NetworkFile newFileHandle;
        NetworkFile oldFileHandle;

        NodeRef testNodeRef; // node ref of test.doc

        Serializable testCreatedDate;
    }
    ;

    final TestContext testContext = new TestContext();

    final String TEST_DIR = TEST_ROOT_DOS_PATH + "\\testScenarioMSExcel2003SaveShuffle";

    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteGarbageFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    /**
     * Create a file in the test directory
     */

    try {
        tran.doInTransaction(deleteGarbageFileCB);
    } catch (Exception e) {
        // expect to go here
    }

    RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {

            /**
             * Create the test directory we are going to use 
             */
            FileOpenParams createRootDirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            FileOpenParams createDirParams = new FileOpenParams(TEST_DIR, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            driver.createDirectory(testSession, testConnection, createRootDirParams);
            driver.createDirectory(testSession, testConnection, createDirParams);

            /**
             * Create the file we are going to use
             */
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.firstFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.firstFileHandle);

            // now load up the node with lots of other stuff that we will test to see if it gets preserved during the
            // shuffle.
            testContext.testNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_VERSIONABLE, null);

            // test non CM namespace property
            nodeService.setProperty(testContext.testNodeRef, TransferModel.PROP_ENABLED, true);
            // test CM property not related to an aspect
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_ADDRESSEE, "Fred");

            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_TITLE, FILE_TITLE);
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_DESCRIPTION, FILE_DESCRIPTION);

            /**
             * MLText value - also a residual value in a non cm namespace
             */
            MLText mltext = new MLText();
            mltext.addValue(Locale.FRENCH, "Bonjour");
            mltext.addValue(Locale.ENGLISH, "Hello");
            mltext.addValue(Locale.ITALY, "Buongiorno");
            mlAwareNodeService.setProperty(testContext.testNodeRef, RESIDUAL_MTTEXT, mltext);

            // classifiable chosen since its not related to any properties.
            nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_CLASSIFIABLE, null);
            //nodeService.createAssociation(testContext.testNodeRef, targetRef, assocTypeQName);

            return null;
        }
    };
    tran.doInTransaction(createFileCB, false, true);

    /**
     * Write some content to the test file
     */
    RetryingTransactionCallback<Void> writeFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            String testContent = "MS Excel 2003 shuffle test";
            byte[] testContentBytes = testContent.getBytes();
            testContext.firstFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.firstFileHandle.close();

            testContext.testCreatedDate = nodeService.getProperty(testContext.testNodeRef,
                    ContentModel.PROP_CREATED);

            MLText multi = (MLText) mlAwareNodeService.getProperty(testContext.testNodeRef, RESIDUAL_MTTEXT);
            multi.getValues();

            return null;
        }
    };
    tran.doInTransaction(writeFileCB, false, true);

    /**
     * b) Save the new file
     */
    RetryingTransactionCallback<Void> saveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NEW_TEMP, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.newFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.newFileHandle);
            String testContent = "MS Word 2003 shuffle test This is new content";
            byte[] testContentBytes = testContent.getBytes();
            testContext.newFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.newFileHandle.close();

            return null;
        }
    };
    tran.doInTransaction(saveNewFileCB, false, true);

    /**
     * rename the old file
     */
    RetryingTransactionCallback<Void> renameOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME,
                    TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };
    tran.doInTransaction(renameOldFileCB, false, true);

    RetryingTransactionCallback<Void> validateOldFileGoneCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            try {
                driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            } catch (IOException e) {
                // expect to go here since previous step renamed the file.
            }

            return null;
        }
    };
    tran.doInTransaction(validateOldFileGoneCB, false, true);

    /**
     * Move the new file into place, stuff should get shuffled
     */
    RetryingTransactionCallback<Void> moveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NEW_TEMP,
                    TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    tran.doInTransaction(moveNewFileCB, false, true);

    RetryingTransactionCallback<Void> validateCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            NodeRef shuffledNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            Map<QName, Serializable> props = nodeService.getProperties(shuffledNodeRef);

            // Check trx:enabled has been shuffled.
            assertTrue("node does not contain shuffled ENABLED property",
                    props.containsKey(TransferModel.PROP_ENABLED));
            // check my residual MLText has been transferred
            assertTrue(props.containsKey(RESIDUAL_MTTEXT));

            // Check the titled aspect is correct
            assertEquals("name wrong", FILE_NAME,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_NAME));
            assertEquals("title wrong", FILE_TITLE,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_TITLE));
            assertEquals("description wrong", FILE_DESCRIPTION,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_DESCRIPTION));

            // commented out due to ALF-7641
            // CIFS shuffle, does not preseve MLText values.
            // Map<QName, Serializable> mlProps = mlAwareNodeService.getProperties(shuffledNodeRef);

            // MLText multi = (MLText)mlAwareNodeService.getProperty(shuffledNodeRef, RESIDUAL_MTTEXT) ;
            // multi.getValues();

            // check auditable properties 
            // commented out due to ALF-7635
            // assertEquals("creation date not preserved", ((Date)testContext.testCreatedDate).getTime(), ((Date)nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_CREATED)).getTime());

            // commented out due to ALF-7628 
            // assertEquals("ADDRESSEE PROPERTY Not copied", "Fred", nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_ADDRESSEE));
            // assertTrue("CLASSIFIABLE aspect not present", nodeService.hasAspect(shuffledNodeRef, ContentModel.ASPECT_CLASSIFIABLE));

            // commented out due to ALF-7584.
            // assertEquals("noderef changed", testContext.testNodeRef, shuffledNodeRef);
            return null;
        }
    };

    tran.doInTransaction(validateCB, true, true);

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };

    tran.doInTransaction(deleteOldFileCB, false, true);

}