Browse Source

Fix small formatting issues (#10960)

tags/8.5.0.alpha2
Ilia Motornyi 6 years ago
parent
commit
0528aaafa3
No account linked to committer's email address

+ 2
- 2
server/src/main/java/com/vaadin/data/Binder.java View File

@@ -2189,8 +2189,8 @@ public class Binder<BEAN> implements Serializable {
* <p>
* Added listener is notified every time whenever any bound field value is
* changed, i.e. the UI component value was changed, passed all the
* conversions and validations then propagated to the bound bean field. The same
* functionality can be achieved by adding a
* conversions and validations then propagated to the bound bean field. The
* same functionality can be achieved by adding a
* {@link ValueChangeListener} to all fields in the {@link Binder}.
* <p>
* The listener is added to all fields regardless of whether the method is

+ 0
- 1
server/src/main/java/com/vaadin/server/GlobalResourceHandler.java View File

@@ -122,7 +122,6 @@ public class GlobalResourceHandler implements RequestHandler {
return true;
}


private String urlEncodedKey(String key) {
// getPathInfo return path decoded but without decoding plus as spaces
return ResourceReference.encodeFileName(key.replace("+", " "));

+ 2
- 2
server/src/main/java/com/vaadin/server/VaadinServlet.java View File

@@ -777,7 +777,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
* otherwise.
* @throws IOException
* @throws ServletException
*
*
* @since
*/
protected boolean serveStaticResources(HttpServletRequest request,
@@ -801,7 +801,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @param response
* @throws IOException
* @throws ServletException
*
*
* @since
*/
protected void serveStaticResourcesInVAADIN(String filename,

+ 16
- 8
server/src/test/java/com/vaadin/server/GlobalResourceHandlerTest.java View File

@@ -18,20 +18,26 @@ import static org.mockito.Mockito.when;
public class GlobalResourceHandlerTest {

@Test
public void globalResourceHandlerShouldWorkWithEncodedFilename() throws IOException {
public void globalResourceHandlerShouldWorkWithEncodedFilename()
throws IOException {
assertEncodedFilenameIsHandled("simple.txt", "simple.txt");
assertEncodedFilenameIsHandled("with spaces.txt", "with+spaces.txt");
assertEncodedFilenameIsHandled("with # hash.txt", "with+%23+hash.txt");
assertEncodedFilenameIsHandled("with ; semicolon.txt", "with+%3B+semicolon.txt");
assertEncodedFilenameIsHandled("with , comma.txt", "with+%2C+comma.txt");
assertEncodedFilenameIsHandled("with ; semicolon.txt",
"with+%3B+semicolon.txt");
assertEncodedFilenameIsHandled("with , comma.txt",
"with+%2C+comma.txt");

// ResourceReference.encodeFileName does not encode slashes and backslashes
// ResourceReference.encodeFileName does not encode slashes and
// backslashes
// See comment inside2 method for more details
assertEncodedFilenameIsHandled("with \\ backslash.txt", "with+\\+backslash.txt");
assertEncodedFilenameIsHandled("with \\ backslash.txt",
"with+\\+backslash.txt");
assertEncodedFilenameIsHandled("with / slash.txt", "with+/+slash.txt");
}

private void assertEncodedFilenameIsHandled(String filename, String expectedFilename) throws IOException {
private void assertEncodedFilenameIsHandled(String filename,
String expectedFilename) throws IOException {
DownloadStream stream = mock(DownloadStream.class);
ConnectorResource resource = mock(ConnectorResource.class);
when(resource.getFilename()).thenReturn(filename);
@@ -58,11 +64,13 @@ public class GlobalResourceHandlerTest {
VaadinResponse response = mock(VaadinResponse.class);

// getPathInfo return path decoded but without decoding plus as spaces
when(request.getPathInfo()).thenReturn("APP/global/0/legacy/0/"+ filename.replace(" ", "+"));
when(request.getPathInfo()).thenReturn(
"APP/global/0/legacy/0/" + filename.replace(" ", "+"));
when(session.getUIById(anyInt())).thenReturn(ui);

// Verify that decoded path info is correctly handled
assertTrue("Request not handled", handler.handleRequest(session, request, response));
assertTrue("Request not handled",
handler.handleRequest(session, request, response));
verify(stream).writeResponse(request, response);
}
}

+ 2
- 3
testbench-api/src/main/java/com/vaadin/testbench/elements/ColorPickerPreviewElement.java View File

@@ -36,9 +36,8 @@ public class ColorPickerPreviewElement extends CssLayoutElement {
public boolean getColorFieldContainsErrors() {
List<WebElement> caption = findElements(
By.className("v-caption-v-colorpicker-preview-textfield"));
return !caption.isEmpty() &&
!caption.get(0).findElements(By.className("v-errorindicator"))
.isEmpty();
return !caption.isEmpty() && !caption.get(0)
.findElements(By.className("v-errorindicator")).isEmpty();
}

/**

Loading…
Cancel
Save