source: josm/trunk/test/unit/org/openstreetmap/josm/gui/io/UploadTextComponentValidatorTest.java@ 18037

Last change on this file since 18037 was 18037, checked in by Don-vip, 3 years ago

fix #21064 - Add JUnit 5 extension for preferences (patch by taylor.smock)

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.io;
3
4import static org.hamcrest.CoreMatchers.containsString;
5import static org.hamcrest.MatcherAssert.assertThat;
6
7import javax.swing.JLabel;
8import javax.swing.JTextField;
9
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
12
13@BasicPreferences
14class UploadTextComponentValidatorTest {
15 /**
16 * Unit test of {@link UploadTextComponentValidator.UploadCommentValidator}
17 */
18 @Test
19 void testUploadCommentValidator() {
20 JTextField textField = new JTextField();
21 JLabel feedback = new JLabel();
22 new UploadTextComponentValidator.UploadCommentValidator(textField, feedback);
23 assertThat(feedback.getText(), containsString("Your upload comment is <i>empty</i>, or <i>very short</i>"));
24 textField.setText("a comment long enough");
25 assertThat(feedback.getText(), containsString("Thank you for providing a changeset comment"));
26 textField.setText("a");
27 assertThat(feedback.getText(), containsString("Your upload comment is <i>empty</i>, or <i>very short</i>"));
28 }
29
30 /**
31 * Unit test of {@link UploadTextComponentValidator.UploadSourceValidator}
32 */
33 @Test
34 void testUploadSourceValidator() {
35 JTextField textField = new JTextField();
36 JLabel feedback = new JLabel();
37 new UploadTextComponentValidator.UploadSourceValidator(textField, feedback);
38 assertThat(feedback.getText(), containsString("You did not specify a source for your changes"));
39 textField.setText("a comment long enough");
40 assertThat(feedback.getText(), containsString("Thank you for providing the data source"));
41 }
42}
Note: See TracBrowser for help on using the repository browser.