From 4d573932573d6410065fbb5ca250d08309e65072 Mon Sep 17 00:00:00 2001
From: "Nicolas NESMON (@NicoNes)"
* This example uses some basic external JSSE configuration: - *
- **
* This example uses some basic external JSSE configuration: - *
- **
* Following is the list of recognized commands: *
+ * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container + * environments is undefined. + *
+ * + * @param application The application to start up. + * @return {@code CompletionStage} (possibly asynchronously) producing handle of the running application + * {@link SeBootstrap.Instance instance}. + * @see Configuration + * @since 3.1 + */ + static CompletionStage+ * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container + * environments is undefined. + *
+ * + * @param clazz The application class. + * @param configuration Provides information needed for bootstrapping the application. + * @return {@code CompletionStage} (possibly asynchronously) producing handle of the running application + * {@link SeBootstrap.Instance instance}. + * @see Configuration + * @since 3.1 + */ + static CompletionStage+ * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container + * environments is undefined. + *
+ * + * @param clazz The application class. + * @return {@code CompletionStage} (possibly asynchronously) producing handle of the running application + * {@link SeBootstrap.Instance instance}. + * @see Configuration + * @since 3.1 + */ + static CompletionStage
@@ -150,7 +213,7 @@ static CompletionStage
+ * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
+ * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public default boolean containsHeaderString(String name, Predicate
+ * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
+ * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public default boolean containsHeaderString(String name, Predicate
- * A completion callback is invoked when the whole request processing is over, i.e. once a response for the request has
- * been processed and sent back to the client or in when an unmapped exception or error is being propagated to the
- * container.
+ * A completion callback is always invoked when the whole request processing is over, i.e. once a response for the request has
+ * been processed and sent back to the client (including processing by a custom exception mapper) or when an unmapped
+ * exception or error is being propagated to the default exception mapper.
*
- * An unmapped throwable is propagated to the hosting I/O container in case no {@link jakarta.ws.rs.ext.ExceptionMapper
- * exception mapper} has been found for a throwable indicating a request processing failure. In this case a
- * non-{@code null} unmapped throwable instance is passed to the method. Note that the throwable instance represents the
- * actual unmapped exception thrown during the request processing, before it has been wrapped into an I/O
- * container-specific exception that was used to propagate the throwable to the hosting I/O container.
- *
+ * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
+ * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public default boolean containsHeaderString(String name, Predicate
+ * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
+ * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
+ * @see #getHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public default boolean containsHeaderString(String name, Predicate
+ * Cookie builder provides methods that let you conveniently configure and subsequently build a new
+ * {@code Cookie} instance.
+ *
+ * Multipart entities may be received in a resource method as a collection of
+ * parts (e.g. {@code List
+ * Likewise, a client may receive a multipart response by reading the returned
+ * entity as a collection of EntityParts (ex: {@code response.readEntity(new
+ * GenericType
+ * In order to send a multipart entity either as a client request or a response
+ * from a resource method, you may create the Lists using
+ * {@code EntityPart.Builder}. For example:
+ *
+ * Logically, this is the same as {@code EntityPart.withName(x).fileName(x)}.
+ *
+ * The {@code InputStream} will be closed by the implementation code after
+ * sending the multipart data. Closing the stream before it is sent could result
+ * in unexpected behavior.
+ *
+ * If the content is specified using this method, then the {@link #build()}
+ * method is responsible for finding a registered
+ * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
+ * object type specified here using the default {@link MediaType} or the
+ * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
+ * {@link #mediaType(String)} methods and using any headers specified via the
+ * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
+ * methods.
+ *
+ * If the content is specified using this method, then the {@link #build()}
+ * method is responsible for finding a registered
+ * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
+ * object's class type specified here using the default {@link MediaType} or the
+ * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
+ * {@link #mediaType(String)} methods and using any headers specified via the
+ * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
+ * methods.
+ *
+ * This is the equivalent of calling
+ * {@code content(content, content.getClass())}.
+ *
+ * If the content is specified using this method, then the {@link #build()}
+ * method is responsible for finding a registered
+ * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
+ * object type specified here using the default {@link MediaType} or the
+ * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
+ * {@link #mediaType(String)} methods and using any headers specified via the
+ * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
+ * methods.
+ *
* Get a HTTP header as a single string value.
*
+ * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
+ * @see #getRequestHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
+ * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
+ * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
+ * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
+ * (missing comma), or the value {@code no - store} (whitespace within value).
+ *
+ * @param name the message header.
+ * @param valuePredicate value must fulfil this predicate.
+ * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
+ * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
+ * @see #getRequestHeaders()
+ * @see #getHeaderString(String)
+ * @since 4.0
+ */
+ public default boolean containsHeaderString(String name, Predicate
+ * New Cookie builder provides methods that let you conveniently configure and subsequently build a new
+ * {@code NewCookie} instance.
+ *
+ * Note that it is recommended to use {@link #maxAge(int) Max-Age} to control cookie expiration, however some browsers
+ * do not understand {@code Max-Age}, in which case setting {@code Expires} parameter may be necessary.
+ *
*
* @return the path segment
*/
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
index 82e85d704..39c44e104 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
@@ -463,6 +463,22 @@ public MultivaluedMap
@@ -1173,6 +1189,13 @@ public enum Status implements StatusType {
* @since 2.0
*/
PARTIAL_CONTENT(206, "Partial Content"),
+ /**
+ * 300 Multiple Choices, see HTTP/1.1:
+ * Semantics and Content.
+ *
+ * @since 3.1
+ */
+ MULTIPLE_CHOICES(300, "Multiple Choices"),
/**
* 301 Moved Permanently, see HTTP/1.1
* documentation.
@@ -1206,6 +1229,13 @@ public enum Status implements StatusType {
* documentation.
*/
TEMPORARY_REDIRECT(307, "Temporary Redirect"),
+ /**
+ * 308 Permanent Redirect, see RFC 7538:
+ * The Hypertext Transfer Protocol Status Code 308 (Permanent Redirect).
+ *
+ * @since 3.1
+ */
+ PERMANENT_REDIRECT(308, "Permanent Redirect"),
/**
* 400 Bad Request, see HTTP/1.1
* documentation.
@@ -1334,6 +1364,13 @@ public enum Status implements StatusType {
* @since 2.1
*/
REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"),
+ /**
+ * 451 Unavailable For Legal Reasons, see RFC 7725:
+ * An HTTP Status Code to Report Legal Obstacles.
+ *
+ * @since 3.1
+ */
+ UNAVAILABLE_FOR_LEGAL_REASONS(451, "Unavailable For Legal Reasons"),
/**
* 500 Internal Server Error, see HTTP/1.1
* documentation.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
index d7b98c39d..b48bc6b10 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
@@ -19,6 +19,7 @@
import java.io.StringWriter;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
@@ -198,11 +199,7 @@ public static VariantListBuilder encodings(final String... encodings) {
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 29 * hash + (this.language != null ? this.language.hashCode() : 0);
- hash = 29 * hash + (this.mediaType != null ? this.mediaType.hashCode() : 0);
- hash = 29 * hash + (this.encoding != null ? this.encoding.hashCode() : 0);
- return hash;
+ return Objects.hash(this.language, this.mediaType, this.encoding);
}
/**
@@ -220,14 +217,13 @@ public boolean equals(final Object obj) {
return false;
}
final Variant other = (Variant) obj;
- if (this.language != other.language && (this.language == null || !this.language.equals(other.language))) {
+ if (!Objects.equals(this.language, other.language)) {
return false;
}
- if (this.mediaType != other.mediaType && (this.mediaType == null || !this.mediaType.equals(other.mediaType))) {
+ if (!Objects.equals(this.mediaType, other.mediaType)) {
return false;
}
- // noinspection StringEquality
- return this.encoding == other.encoding || (this.encoding != null && this.encoding.equals(other.encoding));
+ return Objects.equals(this.encoding, other.encoding);
}
@Override
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/ext/FactoryFinder.java b/jaxrs-api/src/main/java/jakarta/ws/rs/ext/FactoryFinder.java
index d3a91c8f6..bbd5afd96 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/ext/FactoryFinder.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/ext/FactoryFinder.java
@@ -21,9 +21,7 @@
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.Iterator;
import java.util.Properties;
-import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -45,6 +43,11 @@ private FactoryFinder() {
}
private static ClassLoader getContextClassLoader() {
+ // For performance reasons, check if a security manager is installed. If not there is no need to use a
+ // privileged action.
+ if (System.getSecurityManager() == null) {
+ return Thread.currentThread().getContextClassLoader();
+ }
return AccessController.doPrivileged((PrivilegedAction
- * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Application, Configuration)}
- * instead.
+ * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Application,
+ * SeBootstrap.Configuration)} instead.
*
+ * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Class,
+ * SeBootstrap.Configuration)} instead.
+ *
+ * This method is not intended to be invoked by applications. Call {@link EntityPart#withName(String)} instead.
+ *
* Subsequent calls have no effect and are ignored. Once the {@link SseEventSink} is closed, invoking any method other
* than this one and {@link #isClosed()} would result in an {@link IllegalStateException} being thrown.
+ * @throws IOException if an I/O error occurs.
*/
@Override
- void close();
+ void close() throws IOException;
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
index bc5f06d54..7df3f1fc5 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -72,6 +72,11 @@
*
* In the case of an error condition response, the
+ * Note that if, for any of the registered event consumers, an invocation of {@link Consumer#accept(Object)
+ * Consumer<InboundSseEvent>#accept(InboundSseEvent)} method throws an exception, this is not an error condition.
+ * Thus
* This example uses some basic external JSSE configuration:
+ *
*
* This example uses some basic external JSSE configuration:
+ *
*
+ * Cookie cookie = new Cookie.Builder("name")
+ * .path("/")
+ * .domain("domain.com")
+ * .build();
+ *
+ *
+ * @since 3.1
+ */
+ public static class Builder extends AbstractCookieBuilder>() {})}).
+ *
+ * Client c = ClientBuilder.newClient();
+ *WebTarget target = c.target(someURL);
+ *List<EntityPart> parts = Arrays.asList(
+ * EntityPart.withName("name1").fileName("file1.doc").content(stream1).build(),
+ * EntityPart.withName("name2").fileName("file2.doc").content(stream2).build(),
+ * EntityPart.withName("name3").fileName("file3.xml").content(myObject, MyClass.class).mediaType("application/xml").build());
+ *GenericEntity<List<EntityPart>> genericEntity = new GenericEntity<>(parts){};
+ *Entity entity = Entity.entity(genericEntity, MediaType.MULTIPART_FORM_DATA);
+ *Response r = target.request().post(entity);
+ *
+ *
+ * Note that when building a EntityPart, the name and content are required.
+ * Other properties such as headers, file name, and media type are optional.
+ *
+ * It is the responsibility of the implementation code to close the content
+ * input streams when sending the multipart content. Closing the stream before
+ * the implementation has sent it could result in unexpected exceptions. It is
+ * the responsibility of the calling code to close the stream when receiving the
+ * multipart content.
+ *
+ * @since 3.1
+ */
+public interface EntityPart {
+
+ /**
+ * Creates a new {@code EntityPart.Builder} instance.
+ *
+ * @param partName name of the part to create within the multipart entity
+ * @return {@link Builder} for building new {@link EntityPart} instances
+ */
+ static Builder withName(String partName) {
+ return RuntimeDelegate.getInstance().createEntityPartBuilder(partName);
+ }
+
+ /**
+ * Creates a new {@code EntityPart.Builder} instance that sets the part
+ * {@code name} and {@code fileName} to the passed in {@code partAndFileName}
+ * value.
+ *
+ * NewCookie cookie = new NewCookie.Builder("name")
+ * .path("/")
+ * .domain("domain.com")
+ * .sameSite(SameSite.LAX)
+ * .build();
+ *
+ *
+ * @since 3.1
+ */
+ public static class Builder extends AbstractNewCookieBuilderThrowable
passed to the onError
consumer
* should be a WebApplicationException containing the invalid Response
object.
+ * onError
is not invoked and event processing is not stopped.
+ * Users are encouraged to handle exceptions on their own as part of the event processing logic.
*
* @author Marek Potociar
* @since 2.1
@@ -136,6 +141,13 @@ static Builder newBuilder() {
}
}
+ /**
+ * Set the SSE streaming endpoint.
+ *
+ * @param endpoint SSE streaming endpoint. Must not be {@code null}.
+ * @return updated event source builder instance.
+ * @throws NullPointerException in case the supplied web target is {@code null}.
+ */
protected abstract Builder target(WebTarget endpoint);
/**
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
index ba3c14132..bc09f2e97 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
@@ -1,26 +1,30 @@
package jakarta.ws.rs;
-import javax.net.ssl.SSLContext;
-import java.util.concurrent.CompletionStage;
-
-import jakarta.ws.rs.SeBootstrap;
-import jakarta.ws.rs.SeBootstrap.Configuration;
-import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.ext.RuntimeDelegate;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import java.net.URI;
+import java.util.concurrent.CompletionStage;
+
+import javax.net.ssl.SSLContext;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import jakarta.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.SeBootstrap.Configuration;
+import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.ext.RuntimeDelegate;
+
/**
* Unit tests for {@link SeBootstrap}
*
@@ -34,7 +38,7 @@ public final class SeBootstrapTest {
* installed RuntimeDelegate.
*/
@BeforeEach
- public final void setUp() {
+ public void setUp() {
RuntimeDelegate.setInstance(mock(RuntimeDelegate.class));
}
@@ -43,7 +47,7 @@ public final void setUp() {
* use a possibly cluttered instance.
*/
@AfterEach
- public final void tearDown() {
+ public void tearDown() {
RuntimeDelegate.setInstance(null);
}
@@ -54,7 +58,7 @@ public final void tearDown() {
* @since 3.1
*/
@Test
- public final void shouldDelegateApplicationStartupToRuntimeDelegate() {
+ public void shouldDelegateApplicationStartupToRuntimeDelegate() {
// given
final Application application = mock(Application.class);
final Configuration configuration = mock(Configuration.class);
@@ -69,6 +73,30 @@ public final void shouldDelegateApplicationStartupToRuntimeDelegate() {
assertThat(actualCompletionStage, is(sameInstance(nativeCompletionStage)));
}
+ /**
+ * Assert that {@link SeBootstrap#start(Class, Configuration)} will delegate to
+ * {@link RuntimeDelegate#bootstrap(Class, Configuration)}.
+ *
+ * @since 3.1
+ */
+ @Test
+ public void shouldDelegateClassApplicationStartupToRuntimeDelegate() {
+ // given
+ final Application application = mock(Application.class);
+ final Class extends Application> clazz = application.getClass();
+ final Configuration configuration = mock(Configuration.class);
+ @SuppressWarnings("unchecked")
+ final CompletionStage
*
+ *
*
+ *
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/Client.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/Client.java
index a03fe84da..cf7481773 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/Client.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/Client.java
@@ -16,10 +16,9 @@
package jakarta.ws.rs.client;
-import java.net.URI;
-
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
+import java.net.URI;
import jakarta.ws.rs.core.Configurable;
import jakarta.ws.rs.core.Link;
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/SerializationTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/SerializationTest.java
index ff64f6e22..1048504af 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/SerializationTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/SerializationTest.java
@@ -1,12 +1,5 @@
package jakarta.ws.rs;
-import jakarta.ws.rs.core.EntityTag;
-import jakarta.ws.rs.core.GenericType;
-import jakarta.ws.rs.core.Link;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.core.NewCookie;
-import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
@@ -16,6 +9,14 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+
+import jakarta.ws.rs.core.EntityTag;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Link;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.NewCookie;
+import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
public class SerializationTest {
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericEntityTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericEntityTest.java
index 387332ac5..619c9aa1d 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericEntityTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericEntityTest.java
@@ -16,10 +16,6 @@
package jakarta.ws.rs.core;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
@@ -33,6 +29,10 @@
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class GenericEntityTest {
@Test
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericTypeTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericTypeTest.java
index 8459a77f1..0111211f5 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericTypeTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/core/GenericTypeTest.java
@@ -16,9 +16,6 @@
package jakarta.ws.rs.core;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -27,6 +24,9 @@
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Type literal construction unit tests.
*
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/core/MediaTypeTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/core/MediaTypeTest.java
index b042cae2f..2c3f3a32a 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/core/MediaTypeTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/core/MediaTypeTest.java
@@ -16,16 +16,16 @@
package jakarta.ws.rs.core;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import java.util.Map;
import org.hamcrest.Description;
import org.hamcrest.DiagnosingMatcher;
import org.hamcrest.Matcher;
import org.junit.jupiter.api.Test;
-import java.util.Map;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link MediaType} unit test.
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/core/VariantTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/core/VariantTest.java
index d1434cf98..19d0e7c6d 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/core/VariantTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/core/VariantTest.java
@@ -16,10 +16,10 @@
package jakarta.ws.rs.core;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
/**
* Variant regression unit tests.
*
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/ext/RuntimeDelegateTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/ext/RuntimeDelegateTest.java
index 381141add..fd61ddc3c 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/ext/RuntimeDelegateTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/ext/RuntimeDelegateTest.java
@@ -1,10 +1,10 @@
package jakarta.ws.rs.ext;
+import org.junit.jupiter.api.Test;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-
/**
* {@link jakarta.ws.rs.ext.RuntimeDelegate} unit tests.
*