Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS-9199 Bump subethasmtp version to 7.1.3 #3207

Merged
merged 7 commits into from
Feb 19, 2025

Conversation

damianujma
Copy link
Contributor

Since subethasmtp switched to Jakarta Mail 2.1, some tests failed due to the incompatible com.sun.mail:jakarta.mail implementation (See: https://github.com/Alfresco/alfresco-community-repo/actions/runs/12918991059/job/36029451587#step:13:603)
This PR is to bump subethasmtp version to 7.1.3 and use org.eclipse.angus:angus-mail:2.0.3 which is a compatible implementation of the Jakarta Mail Specification 2.1+.

Ref. https://eclipse-ee4j.github.io/angus-mail/

Comment on lines +26 to +866
IMAPResponse unexpected = (IMAPResponse) r[i];
sb.append("key=" + unexpected.getKey());
sb.append("number=" + unexpected.getNumber());
sb.append("rest=" + unexpected.getRest());

sb.append("r[" + i + "]=" + r[i] + '\n');
}
throw new ProtocolException("getMessageUid: " + sb.toString());
}
});
}

/**
* Returns size of the message
*
* @param folder
* Folder containing the message
* @param uid
* Message UID
* @return Returns size of the message
* @throws MessagingException
*/
private static Integer getMessageSize(IMAPFolder folder, final Long uid) throws MessagingException
{
return getMessageBody(folder, uid).getByteArray().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
{
Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[])", null);
logResponse(r);
Response response = r[r.length - 1];

// Grab response
if (!response.isOK())
{
throw new ProtocolException("Unable to retrieve message size");
}
FetchResponse fetchResponse = (FetchResponse) r[0];
BODY body = (BODY) fetchResponse.getItem(BODY.class);
return body;
}
});
}

/**
* Simple util for logging response
*
* @param r
* response
*/
private static void logResponse(Response[] r)
{
for (int i = 0; i < r.length; i++)
{
logger.debug(r[i]);
}
}

@Override
public void tearDown() throws Exception
{
// Deleting created test environment
logger.debug("tearDown ");

UserTransaction txn = transactionService.getUserTransaction();
txn.begin();

List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + IMAP_FOLDER_NAME, null,
namespaceService, false);
if (nodeRefs != null && nodeRefs.size() > 0)
{
fileFolderService.delete(nodeRefs.get(0));
}

authenticationService.deleteAuthentication(anotherUserName);
personService.deletePerson(anotherUserName);

txn.commit();

// Closing client connection
folder.forceClose();
store.close();
logger.debug("tearDown end");
}

}

Check warning

Code scanning / PMD

High amount of different objects as members denotes a high coupling Warning test

High amount of different objects as members denotes a high coupling
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
public class ImapMessageTest extends TestCase
{
private static Log logger = LogFactory.getLog(ImapMessageTest.class);

Check warning

Code scanning / PMD

Logger should be defined private static final and have the correct class Warning test

Logger should be defined private static final and have the correct class
private static final String ADMIN_USER_PASSWORD = "admin";
private static final String IMAP_FOLDER_NAME = "test";

private Session session = null;

Check warning

Code scanning / PMD

Avoid using redundant field initializer for 'folder' Warning test

Avoid using redundant field initializer for 'session'
private static final String IMAP_FOLDER_NAME = "test";

private Session session = null;
private Store store = null;

Check warning

Code scanning / PMD

Avoid using redundant field initializer for 'folder' Warning test

Avoid using redundant field initializer for 'store'

private Session session = null;
private Store store = null;
private IMAPFolder folder = null;

Check warning

Code scanning / PMD

Avoid using redundant field initializer for 'folder' Warning test

Avoid using redundant field initializer for 'folder'
private Store store = null;
private IMAPFolder folder = null;

private ApplicationContext ctx;

Check warning

Code scanning / PMD

Perhaps 'ctx' could be replaced by a local variable. Warning test

Perhaps 'ctx' could be replaced by a local variable.
Copy link
Contributor

@cezary-witkowski cezary-witkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done

@damianujma damianujma merged commit 1adddb0 into master Feb 19, 2025
89 checks passed
@damianujma damianujma deleted the feature/ACS-9199_bump_subethasmtp_version branch February 19, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants