8000 [RESTEASY-2772] changed exception type and adjusted unit tests · resteasy/resteasy@1f773f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f773f3

Browse files
rsearlsasoldano
authored andcommitted
[RESTEASY-2772] changed exception type and adjusted unit tests
1 parent fe8e06c commit 1f773f3

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

providers/multipart/src/main/java/org/jboss/resteasy/plugins/providers/multipart/MultipartReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.InputStream;
1616
import java.lang.annotation.Annotation;
1717
import java.lang.reflect.Type;
18+
import javax.ws.rs.BadRequestException;
1819

1920
/**
2021
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@@ -35,7 +36,7 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati
3536
public MultipartInput readFrom(Class<MultipartInput> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException
3637
{
3738
String boundary = mediaType.getParameters().get("boundary");
38-
if (boundary == null) throw new IOException(Messages.MESSAGES.unableToGetBoundary());
39+
if (boundary == null) throw new BadRequestException(Messages.MESSAGES.unableToGetBoundary());
3940
MultipartInputImpl input = new MultipartInputImpl(mediaType, workers);
4041
/*
4142
StringWriter writer = new StringWriter();

resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.ws.rs.ext.RuntimeDelegate;
88

99
import java.util.HashMap;
10+
import javax.ws.rs.BadRequestException;
1011

1112
/**
1213
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
@@ -113,7 +114,7 @@ public static MediaType parse(String type)
113114
}
114115
if (!MediaType.MEDIA_TYPE_WILDCARD.equals(major))
115116
{
116-
throw new IllegalArgumentException(Messages.MESSAGES.failureParsingMediaType(type));
117+
throw new BadRequestException(Messages.MESSAGES.failureParsingMediaType(type));
117118
}
118119
subtype = MediaType.MEDIA_TYPE_WILDCARD;
119120
}
@@ -131,11 +132,11 @@ public static MediaType parse(String type)
131132
}
132133
if (major.length() < 1 || subtype.length() < 1)
133134
{
134-
throw new IllegalArgumentException(Messages.MESSAGES.failureParsingMediaType(type));
135+
throw new BadRequestException(Messages.MESSAGES.failureParsingMediaType(type));
135136
}
136137
if (!isValid(major) || !isValid(subtype))
137138
{
138-
throw new IllegalArgumentException(Messages.MESSAGES.failureParsingMediaType(type));
139+
throw new BadRequestException(Messages.MESSAGES.failureParsingMediaType(type));
139140
}
140141
String params = null;
141142
if (paramIndex > -1) params = type.substring(paramIndex + 1);

testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/client/ClientBuilderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import javax.ws.rs.core.Response;
1717
import javax.ws.rs.ext.ContextResolver;
1818
import javax.ws.rs.ext.RuntimeDelegate;
19+
import javax.ws.rs.BadRequestException;
1920

2021
import static org.jboss.resteasy.test.TestPortProvider.generateURL;
2122

@@ -32,7 +33,7 @@ public class ClientBuilderTest {
3233
* @tpPassCrit IllegalArgumentException is raised
3334
* @tpSince RESTEasy 3.0.16
3435
*/
35-
@Test(expected = IllegalArgumentException.class)
36+
@Test(expected = BadRequestException.class)
3637
public void entityStringThrowsExceptionWhenUnparsableTest() throws Exception {
3738
Entity.entity("entity", "\\//\\");
3839
Assert.fail();

testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/mediatype/MediaTypeHeaderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate;
44
import org.junit.Test;
5+
import javax.ws.rs.BadRequestException;
56

67
public class MediaTypeHeaderTest {
78

8-
@Test(expected = IllegalArgumentException.class)
9+
@Test(expected = BadRequestException.class)
910
public void testNewLineInHeaderValueIsRejected() {
1011
MediaTypeHeaderDelegate delegate = new MediaTypeHeaderDelegate();
1112

0 commit comments

Comments
 (0)
0