Skip to content

Commit 2f898d2

Browse files
committed
Remove impl test dependency
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent b0e1ed6 commit 2f898d2

File tree

4 files changed

+113
-64
lines changed

4 files changed

+113
-64
lines changed

api/pom.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@
106106
<artifactId>junit</artifactId>
107107
<scope>test</scope>
108108
</dependency>
109-
<dependency>
110-
<groupId>org.eclipse.angus</groupId>
111-
<artifactId>angus-mail</artifactId>
112-
<version>1.0.0-SNAPSHOT</version>
113-
<scope>test</scope>
114-
</dependency>
115109
</dependencies>
116110

117111
<build>
@@ -410,6 +404,8 @@ Use is subject to <a href="{@docRoot}/doc-files/speclicense.html" target="_top">
410404
<configuration>
411405
<forkCount>2</forkCount>
412406
<reuseForks>false</reuseForks>
407+
<!-- Test service loader is not loaded if modules are enabled -->
408+
<useModulePath>false</useModulePath>
413409
</configuration>
414410
</plugin>
415411
<plugin>

api/src/test/java/jakarta/mail/internet/MimeBodyPartTest.java

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.assertFalse;
2020
import static org.junit.Assert.assertTrue;
2121

22+
import java.io.ByteArrayInputStream;
2223
import java.io.IOException;
2324
import java.io.InputStream;
2425
import java.util.Properties;
@@ -32,11 +33,11 @@ public class MimeBodyPartTest {
3233

3334
@Test
3435
public void sessionProperties() throws MessagingException, IOException {
35-
try {
36+
InputStream input = new ByteArrayInputStream(new byte[0]);
3637
Properties prop = new Properties();
37-
MimeMessage orig = buildFromProperties(prop);
38-
MimeMultipart omp = (MimeMultipart) orig.getContent();
39-
MimeBodyPart obp = (MimeBodyPart) omp.getBodyPart(0);
38+
Session session = Session.getInstance(prop);
39+
MimeMessage orig = new MimeMessage(session, input);
40+
MimeBodyPart obp = new MimeBodyPart(session, input);
4041
// No properties added, so default will be checked
4142
// MimeMessage
4243
assertTrue(orig.setDefaultTextCharset);
@@ -62,9 +63,11 @@ public void sessionProperties() throws MessagingException, IOException {
6263
prop.put("mail.mime.ignoremultipartencoding", Boolean.FALSE);
6364
prop.put("mail.mime.allowutf8", Boolean.FALSE);
6465
prop.put("mail.mime.cachemultipart", Boolean.FALSE);
65-
orig = buildFromProperties(prop);
66-
omp = (MimeMultipart) orig.getContent();
67-
obp = (MimeBodyPart) omp.getBodyPart(0);
66+
67+
session = Session.getInstance(prop);
68+
orig = new MimeMessage(session, input);
69+
obp = new MimeBodyPart(session, input);
70+
6871
// MimeMessage
6972
assertFalse(orig.setDefaultTextCharset);
7073
assertFalse(orig.setContentTypeFileName);
@@ -81,56 +84,5 @@ public void sessionProperties() throws MessagingException, IOException {
8184
assertFalse(obp.ignoreMultipartEncoding);
8285
assertFalse(obp.allowutf8);
8386
assertFalse(obp.cacheMultipart);
84-
} catch (Exception e) {
85-
e.printStackTrace();
86-
throw new IllegalArgumentException(e);
87-
}
88-
}
89-
90-
private MimeMessage buildFromProperties(Properties prop) throws MessagingException, IOException {
91-
Session s = Session.getInstance(prop);
92-
MimeMessage orig = createMessage(s);
93-
return orig;
94-
}
95-
96-
private static MimeMessage createMessage(Session s) throws MessagingException {
97-
String content = "Mime-Version: 1.0\n" + "Subject: Example\n"
98-
+ "Content-Type: multipart/mixed; boundary=\"-\"\n" + "\n" + "preamble\n" + "---\n"
99-
+ "Content-Type: text/x-test\n" + "Content-Transfer-Encoding: quoted-printable\n" + "\n" + "test part\n"
100-
+ "\n" + "-----\n";
101-
102-
InputStream input = new AsciiStringInputStream(content);
103-
return new MimeMessage(s, input);
104-
}
105-
106-
private static class AsciiStringInputStream extends InputStream {
107-
108-
private final String input;
109-
private int position;
110-
111-
public AsciiStringInputStream(String input) {
112-
this(input, true);
113-
}
114-
115-
public AsciiStringInputStream(String input, boolean strict) {
116-
if (strict) {
117-
for (int i = 0; i < input.length(); i++) {
118-
if (input.charAt(i) > 0x7F) {
119-
throw new IllegalArgumentException("Not an ASCII string");
120-
}
121-
}
122-
}
123-
this.input = input;
124-
}
125-
126-
@Override
127-
public int read() {
128-
if (position < input.length()) {
129-
return input.charAt(position++) & 0xFF;
130-
} else {
131-
return -1;
132-
}
133-
}
134-
13587
}
13688
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package jakarta.mail.util;
18+
19+
import java.io.IOException;
20+
import java.io.InputStream;
21+
import java.io.OutputStream;
22+
23+
public class DummyStreamProvider implements StreamProvider {
24+
25+
@Override
26+
public InputStream inputBase64(InputStream in) {
27+
return null;
28+
}
29+
30+
@Override
31+
public OutputStream outputBase64(OutputStream out) {
32+
return null;
33+
}
34+
35+
@Override
36+
public InputStream inputBinary(InputStream in) {
37+
return null;
38+
}
39+
40+
@Override
41+
public OutputStream outputBinary(OutputStream out) {
42+
return null;
43+
}
44+
45+
@Override
46+
public OutputStream outputB(OutputStream out) {
47+
return null;
48+
}
49+
50+
@Override
51+
public InputStream inputQ(InputStream in) {
52+
return null;
53+
}
54+
55+
@Override
56+
public OutputStream outputQ(OutputStream out, boolean encodingWord) {
57+
return null;
58+
}
59+
60+
@Override
61+
public LineInputStream inputLineStream(InputStream in, boolean allowutf8) {
62+
return new LineInputStream() {
63+
@Override
64+
public String readLine() throws IOException {
65+
return null;
66+
}
67+
};
68+
}
69+
70+
@Override
71+
public LineOutputStream outputLineStream(OutputStream out, boolean allowutf8) {
72+
return null;
73+
}
74+
75+
@Override
76+
public InputStream inputQP(InputStream in) {
77+
return null;
78+
}
79+
80+
@Override
81+
public OutputStream outputQP(OutputStream out) {
82+
return null;
83+
}
84+
85+
@Override
86+
public InputStream inputSharedByteArray(byte[] buff) {
87+
return null;
88+
}
89+
90+
@Override
91+
public InputStream inputUU(InputStream in) {
92+
return null;
93+
}
94+
95+
@Override
96+
public OutputStream outputUU(OutputStream out, String filename) {
97+
return null;
98+
}
99+
100+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jakarta.mail.util.DummyStreamProvider

0 commit comments

Comments
 (0)