Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jun 7, 2021
1 parent f854803 commit f0f450a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void flattenedMapIsSameAsPropertiesButOrdered() {
}

@Test
@SuppressWarnings("unchecked")
void standardTypesSupportedByDefault() throws Exception {
setYaml("value: !!set\n ? first\n ? second");
this.processor.process((properties, map) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ private MessageProducer getCachedProducer(@Nullable Destination dest) throws JMS
return new CachedMessageProducer(producer);
}

@SuppressWarnings("resource")
private MessageConsumer getCachedConsumer(Destination dest, @Nullable String selector,
@Nullable Boolean noLocal, @Nullable String subscription, boolean durable) throws JMSException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
@WebSocket
public class Jetty10WebSocketHandlerAdapter {

private static final ByteBuffer EMPTY_PAYLOAD = ByteBuffer.wrap(new byte[0]);


private final WebSocketHandler delegateHandler;

private final Function<Session, JettyWebSocketSession> sessionFactory;
Expand Down Expand Up @@ -97,7 +94,9 @@ public void onWebSocketBinary(byte[] message, int offset, int length) {
// TODO: onWebSocketFrame can't be declared without compiling against Jetty 10
// Jetty 10: org.eclipse.jetty.websocket.api.Frame
// Jetty 9: org.eclipse.jetty.websocket.api.extensions.Frame

//
// private static final ByteBuffer EMPTY_PAYLOAD = ByteBuffer.wrap(new byte[0]);
//
// @OnWebSocketFrame
// public void onWebSocketFrame(Frame frame) {
// if (this.delegateSession != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,8 +90,7 @@ void sendObject() throws Exception {
}

@Test
public void builder() throws Exception {
String body = "foo bar";
void builder() throws Exception {
ServerResponse response = ServerResponse.sse(sse -> {
try {
sse.id("id")
Expand Down Expand Up @@ -132,14 +131,15 @@ public Person(String name, int age) {
this.age = age;
}

@SuppressWarnings("unused")
public String getName() {
return this.name;
}

@SuppressWarnings("unused")
public int getAge() {
return this.age;
}
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,6 @@

import org.springframework.core.MethodParameter;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;

Expand All @@ -41,32 +40,25 @@
*
* @author Rossen Stoyanchev
*/
public class PrincipalMethodArgumentResolverTests {
class PrincipalMethodArgumentResolverTests {

private PrincipalMethodArgumentResolver resolver;
private PrincipalMethodArgumentResolver resolver = new PrincipalMethodArgumentResolver();

private ModelAndViewContainer mavContainer;
private MockHttpServletRequest servletRequest = new MockHttpServletRequest("GET", "");

private MockHttpServletRequest servletRequest;

private ServletWebRequest webRequest;
private ServletWebRequest webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

private Method method;


@BeforeEach
public void setup() throws Exception {
resolver = new PrincipalMethodArgumentResolver();
mavContainer = new ModelAndViewContainer();
servletRequest = new MockHttpServletRequest("GET", "");
webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());

void setup() throws Exception {
method = getClass().getMethod("supportedParams", ServletRequest.class, Principal.class);
}


@Test
public void principal() throws Exception {
void principal() throws Exception {
Principal principal = () -> "Foo";
servletRequest.setUserPrincipal(principal);

Expand All @@ -78,7 +70,7 @@ public void principal() throws Exception {
}

@Test
public void principalAsNull() throws Exception {
void principalAsNull() throws Exception {
MethodParameter principalParameter = new MethodParameter(method, 1);
assertThat(resolver.supportsParameter(principalParameter)).as("Principal not supported").isTrue();

Expand All @@ -87,7 +79,7 @@ public void principalAsNull() throws Exception {
}

@Test // gh-25780
public void annotatedPrincipal() throws Exception {
void annotatedPrincipal() throws Exception {
Principal principal = () -> "Foo";
servletRequest.setUserPrincipal(principal);
Method principalMethod = getClass().getMethod("supportedParamsWithAnnotatedPrincipal", Principal.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void initializeOnce() throws Exception {
}

@Test
@SuppressWarnings("resource")
void initializeOnCurrentContext() {
AnnotationConfigWebApplicationContext parentContext = new AnnotationConfigWebApplicationContext();
parentContext.setServletContext(new MockServletContext());
Expand Down

0 comments on commit f0f450a

Please sign in to comment.