mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.4-BUG-FIX to HEAD
32832: Merged V3.4 to V3.4-BUG-FIX 32825: ImapMessageTest.testMessageModifiedBetweenReads() - should now be deterministic and not depend on which way the wind is blowing - Got rid of message mangling and introduced proper multi-part message parsing - We should ensure the updated message parses and is different rather than checking for a random concatenation throwing an IOException 32831: (RECORD ONLY) ALF-10828: Merged V3.4-BUG-FIX to V3.4 32541: Fix for ALF-11677 - Doing an HTTP POST to a repository webscript through the Share proxy fails on certain input git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32833 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -250,11 +250,18 @@ public class ImapMessageTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Get test message UID
|
// Get test message UID
|
||||||
final Long uid = getMessageUid(folder, 1);
|
final Long uid = getMessageUid(folder, 1);
|
||||||
// Get Message size
|
|
||||||
final int count = getMessageSize(folder, uid);
|
|
||||||
|
|
||||||
// Get first part
|
// Get unmodified message
|
||||||
BODY body = getMessageBodyPart(folder, uid, 0, count - 100);
|
BODY body = getMessageBody(folder, uid);
|
||||||
|
|
||||||
|
// Parse the multipart MIME message
|
||||||
|
MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()), new BufferedInputStream(body.getByteArrayInputStream()));
|
||||||
|
|
||||||
|
// Reading first part - should be successful
|
||||||
|
MimeMultipart content = (MimeMultipart) message.getContent();
|
||||||
|
assertNotNull(content.getBodyPart(0).getContent());
|
||||||
|
// Reading second part - should be successful
|
||||||
|
assertNotNull(content.getBodyPart(1).getContent());
|
||||||
|
|
||||||
// Modify message. The size of letter describing the node may change
|
// Modify message. The size of letter describing the node may change
|
||||||
// These changes should be committed because it should be visible from client
|
// These changes should be committed because it should be visible from client
|
||||||
@@ -270,26 +277,20 @@ public class ImapMessageTest extends TestCase
|
|||||||
writer.putContent(sb.toString());
|
writer.putContent(sb.toString());
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
// Read second message part
|
// Read updated message part
|
||||||
BODY bodyRest = getMessageBodyPart(folder, uid, count - 10, 10);
|
BODY bodyNew = getMessageBody(folder, uid);
|
||||||
|
|
||||||
// Creating and parsing message from 2 parts
|
// The body should be updated
|
||||||
MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()), new SequenceInputStream(new BufferedInputStream(body.getByteArrayInputStream()),
|
assertFalse(Arrays.equals(bodyNew.data.getBytes(), body.data.getBytes()));
|
||||||
new BufferedInputStream(bodyRest.getByteArrayInputStream())));
|
|
||||||
|
// Parse the multipart MIME message
|
||||||
|
message = new MimeMessage(Session.getDefaultInstance(new Properties()), new BufferedInputStream(bodyNew.getByteArrayInputStream()));
|
||||||
|
|
||||||
// Reading first part - should be successful
|
// Reading first part - should be successful
|
||||||
MimeMultipart content = (MimeMultipart) message.getContent();
|
content = (MimeMultipart) message.getContent();
|
||||||
assertNotNull(content.getBodyPart(0).getContent());
|
assertNotNull(content.getBodyPart(0).getContent());
|
||||||
|
// Reading second part - should be successful
|
||||||
try
|
assertNotNull(content.getBodyPart(1).getContent());
|
||||||
{
|
|
||||||
// Reading second part cause error
|
|
||||||
content.getBodyPart(1).getContent();
|
|
||||||
fail("Should raise an IOException");
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMessageRenamedBetweenReads() throws Exception
|
public void testMessageRenamedBetweenReads() throws Exception
|
||||||
@@ -690,7 +691,20 @@ public class ImapMessageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private static Integer getMessageSize(IMAPFolder folder, final Long uid) throws MessagingException
|
private static Integer getMessageSize(IMAPFolder folder, final Long uid) throws MessagingException
|
||||||
{
|
{
|
||||||
return (Integer) folder.doCommand(new IMAPFolder.ProtocolCommand()
|
return getMessageBody(folder, uid).data.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a full message body
|
||||||
|
*
|
||||||
|
* @param folder Folder containing the message
|
||||||
|
* @param uid Message UID
|
||||||
|
* @return Returns size of the message
|
||||||
|
* @throws MessagingException
|
||||||
|
*/
|
||||||
|
private static BODY getMessageBody(IMAPFolder folder, final Long uid) throws MessagingException
|
||||||
|
{
|
||||||
|
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand()
|
||||||
{
|
{
|
||||||
public Object doCommand(IMAPProtocol p) throws ProtocolException
|
public Object doCommand(IMAPProtocol p) throws ProtocolException
|
||||||
{
|
{
|
||||||
@@ -705,7 +719,7 @@ public class ImapMessageTest extends TestCase
|
|||||||
}
|
}
|
||||||
FetchResponse fetchResponse = (FetchResponse) r[0];
|
FetchResponse fetchResponse = (FetchResponse) r[0];
|
||||||
BODY body = (BODY) fetchResponse.getItem(BODY.class);
|
BODY body = (BODY) fetchResponse.getItem(BODY.class);
|
||||||
return body.data.getCount();
|
return body;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user