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

Passage/feature/add support attach for mail client #21

Merged
merged 29 commits into from
Nov 3, 2019
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
de9e373
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
59637aa
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
109c7e7
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
aa6d6bd
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
ff22f97
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
ad579d0
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
1339aa2
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
7a280ff
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
a35ce28
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
8686b23
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
f8519f4
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 4, 2019
a3ce59a
Bug 550956 - [Passage] Support mail attachment
serjiokov Oct 6, 2019
4050bf0
Bug 550956 - [Passage] Support mail attachment …
serjiokov Oct 11, 2019
6f1713c
Bug 550956 - [Passage] Support mail attachment …
serjiokov Oct 13, 2019
aa3a8c5
Bug 550956 - [Passage] Support mail attachment …
serjiokov Oct 14, 2019
d46e507
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Oct 21, 2019
32e492f
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Oct 21, 2019
51ac48e
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Oct 21, 2019
4c29a6e
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Oct 21, 2019
4e8cb45
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Oct 21, 2019
1d05ee7
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 2, 2019
28e383c
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 2, 2019
f678a5a
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
057ea4c
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
2320306
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
472b4cb
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
81ff675
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
66aca83
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
9394532
Bug 550956 - [Passage] Support mail attachment
ruspl-afed Nov 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug 550956 - [Passage] Support mail attachment
Rename LicensingMailImpl to MailImpl

Signed-off-by: Alexander Fedorov <[email protected]>
ruspl-afed committed Nov 3, 2019
commit 472b4cbcdbe571f06df4b606d2003be054c961ef
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
classpath=true
dsVersion=V1_3
eclipse.preferences.version=1
enabled=true
generateBundleActivationPolicyLazy=true
path=OSGI-INF
validationErrorLevel=error
validationErrorLevel.missingImplicitUnbindMethod=error
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.passage.lic.internal.mail.MailImpl">
<service>
<provide interface="org.eclipse.passage.lic.net.mail.Mailing"/>
</service>
<implementation class="org.eclipse.passage.lic.internal.mail.MailImpl"/>
</scr:component>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -32,30 +32,28 @@

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.passage.lic.net.mail.Mailing;
import org.eclipse.passage.lic.net.mail.EmailDescriptor;
import org.eclipse.passage.lic.net.mail.Mailing;
import org.osgi.service.component.annotations.Component;

/**
* The Licensing mail service implementation
* The Mailing service implementation based on javax.mail
*
* @since 0.1
*
*/
@Component
public class LicensingMailImpl implements Mailing {

public static final String BUNDLE_ID = "org.eclipse.passage.lic.mail"; //$NON-NLS-1$
public class MailImpl implements Mailing {

@Override
public void writeEml(EmailDescriptor descriptor, OutputStream output,
Consumer<IStatus> consumerStatus) {
public void writeEml(EmailDescriptor descriptor, OutputStream output, Consumer<IStatus> consumerStatus) {
try {
Message message = createMessage(descriptor);
fulfillMessage(descriptor, message);
message.writeTo(output);
} catch (MessagingException | IOException | NullPointerException e) {
IStatus status = new Status(IStatus.ERROR, BUNDLE_ID, e.getMessage(), e);
} catch (MessagingException | IOException e) {
String pluginId = "org.eclipse.passage.lic.mail"; //$NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, pluginId, e.getMessage(), e);
consumerStatus.accept(status);
}
}
Original file line number Diff line number Diff line change
@@ -34,13 +34,13 @@

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.passage.lic.internal.mail.LicensingMailImpl;
import org.eclipse.passage.lic.internal.mail.MailImpl;
import org.eclipse.passage.lic.net.mail.Mailing;
import org.eclipse.passage.lic.net.mail.EmailDescriptor;
import org.junit.After;
import org.junit.Test;

public class LicensingMailServiceTest {
public class MailImplTest {

private static final String MAIL_TO = "[email protected]"; //$NON-NLS-1$
private static final String MAIL_FROM = "[email protected]"; //$NON-NLS-1$
@@ -53,42 +53,42 @@ public class LicensingMailServiceTest {

@Test
public void shouldCreateEmlByParametersPositiveTest() {
Mailing licensingEmlService = new LicensingMailImpl();
Mailing mailing = new MailImpl();
String attachment = createAttachment();
assertFalse(attachment.isEmpty());
EmailDescriptor mailDescriptor = licensingEmlService.createMail(MAIL_TO, MAIL_FROM, MAIL_SUBJECT,
EmailDescriptor mailDescriptor = mailing.createMail(MAIL_TO, MAIL_FROM, MAIL_SUBJECT,
MAIL_BODY, Collections.singleton(attachment));
assertNotNull(mailDescriptor);
try (FileOutputStream fileOutput = new FileOutputStream(MAIL_FILE_OUT)) {
IStatus okStatus = new Status(IStatus.OK, this.getClass().getCanonicalName(), 0, "", null);
LicensingMailStatusConsumer statusConsumer = new LicensingMailStatusConsumer(okStatus);
licensingEmlService.writeEml(mailDescriptor, fileOutput, statusConsumer);
mailing.writeEml(mailDescriptor, fileOutput, statusConsumer);
} catch (IOException e) {
assumeNoException(e);
}
}

@Test
public void shouldCreateEmlByParametersNagativeTest() {
Mailing licensingEmlService = new LicensingMailImpl();
Mailing mailing = new MailImpl();
String attachment = createAttachment();
assertFalse(attachment.isEmpty());
EmailDescriptor mailDescriptor = licensingEmlService.createMail("", "", "", "", Collections.singleton(attachment));
EmailDescriptor mailDescriptor = mailing.createMail("", "", "", "", Collections.singleton(attachment));
assertNotNull(mailDescriptor);
try (FileOutputStream fileOutput = new FileOutputStream(MAIL_FILE_OUT)) {
IStatus errorStatus = new Status(IStatus.ERROR, this.getClass().getCanonicalName(), 1, "", null);
LicensingMailStatusConsumer statusConsumer = new LicensingMailStatusConsumer(errorStatus);
licensingEmlService.writeEml(mailDescriptor, fileOutput, statusConsumer);
mailing.writeEml(mailDescriptor, fileOutput, statusConsumer);
} catch (IOException e) {
assumeNoException(e);
}
}

@Test
public void shouldFailWithNullAttachmentTest() {
Mailing licensingEmlService = new LicensingMailImpl();
Mailing mailing = new MailImpl();
try {
licensingEmlService.createMail("", "", "", "", null);
mailing.createMail("", "", "", "", null);
fail();
} catch (Exception e) {
assertEquals(NullPointerException.class, e.getClass());