You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2012/05/24 09:26:12 UTC
git commit: TestFileUploadError was not picked up by maven due to
missing trailing 'Test' suffix
Updated Branches:
refs/heads/master 7d82e5cb2 -> 153631d08
TestFileUploadError was not picked up by maven due to missing trailing 'Test' suffix
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/153631d0
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/153631d0
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/153631d0
Branch: refs/heads/master
Commit: 153631d083b6b53a5d5605c94b117f0b9f4c3e10
Parents: 7d82e5c
Author: Sven Meier <sv...@apache.org>
Authored: Thu May 24 09:23:54 2012 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Thu May 24 09:23:54 2012 +0200
----------------------------------------------------------------------
.../html/form/upload/FileUploadErrorTest.java | 164 +++++++++++++++
.../html/form/upload/TestFileUploadError.java | 161 --------------
2 files changed, 164 insertions(+), 161 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/153631d0/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadErrorTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadErrorTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadErrorTest.java
new file mode 100644
index 0000000..541f4b4
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadErrorTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.form.upload;
+
+import java.util.Locale;
+
+import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.util.file.File;
+import org.apache.wicket.util.tester.FormTester;
+import org.junit.Before;
+
+/**
+ * see WICKET-2015
+ */
+public class FileUploadErrorTest extends WicketTestCase
+{
+ private FormTester formTester;
+ private final String textFieldId = "textField";
+ private final String fileUploadId = "fileUpload";
+ private final String testUploadFilePath = "src/test/java/org/apache/wicket/markup/html/form/upload/testfile.txt";
+
+ /**
+ *
+ */
+ @Before
+ public void before()
+ {
+ // Start and render the test page
+ tester.startPage(FileUploadError.class);
+ tester.assertRenderedPage(FileUploadError.class);
+ // Set locale to fix error messages on this test.
+ tester.getSession().setLocale(Locale.ENGLISH);
+ //
+ formTester = tester.newFormTester("form");
+ tester.getRequest().setUseMultiPartContentType(true);
+ }
+
+ /**
+ * FileUpload is empty on submit: Validation fails to see that TextField is also required.
+ */
+ public void testSubmit_NoInput()
+ {
+ formTester.submit();
+ tester.assertErrorMessages("Field 'textField' is required.");
+ }
+
+ /**
+ * FileUpload is filled on submit: TexttField is required.
+ */
+ public void testSubmit_NoInput_FileUploaded()
+ {
+ formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
+ formTester.submit();
+
+ tester.assertErrorMessages("Field 'textField' is required.");
+ }
+
+ /**
+ * FileUpload is empty on submit: Validation fails to report too short TextField input.
+ */
+ public void testSubmit_NotValidTextFieldValue()
+ {
+ formTester.setValue(textFieldId, "te");
+ formTester.submit();
+
+ tester.assertErrorMessages(String.format("'%1$s' is not between 3 and 10 characters long.",
+ textFieldId));
+ }
+
+ /**
+ * FileUpload is empty on submit: Validation fails to report too short TextField input.
+ */
+ public void testSubmit_NotValidTextFieldValue2()
+ {
+ formTester.setValue(textFieldId, "12345678901");
+ formTester.submit();
+
+ tester.assertErrorMessages(String.format("'%1$s' is not between 3 and 10 characters long.",
+ textFieldId));
+ }
+
+ /**
+ * FileUpload is filled on submit: Validation reports too short TextField input.
+ */
+ public void testSubmit_NotValidTextFieldValue_FileUploaded()
+ {
+ formTester.setValue(textFieldId, "te");
+ formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
+ formTester.submit();
+
+ tester.assertErrorMessages(String.format("'%1$s' is not between 3 and 10 characters long.",
+ textFieldId));
+ }
+
+ /**
+ * Throwing exception confirms that value is received.
+ */
+ public void testSubmit_ValidTextField_NoFile()
+ {
+ formTester.setValue(textFieldId, FileUploadError.THIS_VALUE_SHOULD_THROW_EXCEPTION);
+ try
+ {
+ formTester.submit();
+ fail("Value not succesfully submitted.");
+ }
+ catch (WicketRuntimeException rex)
+ {
+ Throwable ex = rex.getCause().getCause();
+ assertEquals("Special value: " + FileUploadError.THIS_VALUE_SHOULD_THROW_EXCEPTION,
+ ex.getMessage());
+ }
+ }
+
+ /**
+ */
+ public void testSubmit_ValidTextField_WithFile()
+ {
+ formTester.setValue(textFieldId, "test value");
+ formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
+
+ formTester.submit();
+ tester.assertNoErrorMessage();
+ }
+
+ /**
+ */
+ public void testSubmit_RequiredFileUpload_Ok()
+ {
+ ((FileUploadField)tester.getLastRenderedPage().get("form:" + fileUploadId)).setRequired(true);
+
+ formTester.setValue(textFieldId, "test value");
+ formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
+
+ formTester.submit();
+ tester.assertNoErrorMessage();
+ }
+
+ /**
+ */
+ public void testSubmit_RequiredFileUpload_ShouldFailWithValidationError()
+ {
+ ((FileUploadField)tester.getLastRenderedPage().get("form:" + fileUploadId)).setRequired(true);
+
+ formTester.setValue(textFieldId, "test value");
+
+ formTester.submit();
+ tester.assertErrorMessages("Field 'fileUpload' is required.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/153631d0/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/TestFileUploadError.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/TestFileUploadError.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/TestFileUploadError.java
deleted file mode 100644
index 01162a4..0000000
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/TestFileUploadError.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.markup.html.form.upload;
-
-import java.util.Locale;
-
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.WicketTestCase;
-import org.apache.wicket.util.file.File;
-import org.apache.wicket.util.tester.FormTester;
-import org.junit.Before;
-
-/**
- * see WICKET-2015
- */
-public class TestFileUploadError extends WicketTestCase
-{
- private FormTester formTester;
- private final String textFieldId = "textField";
- private final String fileUploadId = "fileUpload";
- private final String testUploadFilePath = "src/test/java/org/apache/wicket/markup/html/form/upload/testfile.txt";
-
- /**
- *
- */
- @Before
- public void before()
- {
- // Start and render the test page
- tester.startPage(FileUploadError.class);
- tester.assertRenderedPage(FileUploadError.class);
- // Set locale to fix error messages on this test.
- tester.getSession().setLocale(Locale.ENGLISH);
- //
- formTester = tester.newFormTester("form");
- tester.getRequest().setUseMultiPartContentType(true);
- }
-
- /**
- * FileUpload is empty on submit: Validation fails to see that TextField is also required.
- */
- public void testSubmit_NoInput()
- {
- formTester.submit();
- tester.assertErrorMessages("Field 'textField' is required.");
- }
-
- /**
- * FileUpload is filled on submit: TexttField is required.
- */
- public void testSubmit_NoInput_FileUploaded()
- {
- formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
- formTester.submit();
-
- tester.assertErrorMessages("Field 'textField' is required.");
- }
-
- /**
- * FileUpload is empty on submit: Validation fails to report too short TextField input.
- */
- public void testSubmit_NotValidTextFieldValue()
- {
- formTester.setValue(textFieldId, "te");
- formTester.submit();
-
- tester.assertErrorMessages("'te' is not between 3 and 10 characters long.");
- }
-
- /**
- * FileUpload is empty on submit: Validation fails to report too short TextField input.
- */
- public void testSubmit_NotValidTextFieldValue2()
- {
- formTester.setValue(textFieldId, "12345678901");
- formTester.submit();
-
- tester.assertErrorMessages("'12345678901' is not between 3 and 10 characters long.");
- }
-
- /**
- * FileUpload is filled on submit: Validation reports too short TextField input.
- */
- public void testSubmit_NotValidTextFieldValue_FileUploaded()
- {
- formTester.setValue(textFieldId, "te");
- formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
- formTester.submit();
-
- tester.assertErrorMessages("'te' is not between 3 and 10 characters long.");
- }
-
- /**
- * Throwing exception confirms that value is received.
- */
- public void testSubmit_ValidTextField_NoFile()
- {
- formTester.setValue(textFieldId, FileUploadError.THIS_VALUE_SHOULD_THROW_EXCEPTION);
- try
- {
- formTester.submit();
- fail("Value not succesfully submitted.");
- }
- catch (WicketRuntimeException rex)
- {
- Throwable ex = rex.getCause().getCause();
- assertEquals("Special value: " + FileUploadError.THIS_VALUE_SHOULD_THROW_EXCEPTION,
- ex.getMessage());
- }
- }
-
- /**
- */
- public void testSubmit_ValidTextField_WithFile()
- {
- formTester.setValue(textFieldId, "test value");
- formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
-
- formTester.submit();
- tester.assertNoErrorMessage();
- }
-
- /**
- */
- public void testSubmit_RequiredFileUpload_Ok()
- {
- ((FileUploadField)tester.getLastRenderedPage().get("form:" + fileUploadId)).setRequired(true);
-
- formTester.setValue(textFieldId, "test value");
- formTester.setFile(fileUploadId, new File(testUploadFilePath), "UTF-8");
-
- formTester.submit();
- tester.assertNoErrorMessage();
- }
-
- /**
- */
- public void testSubmit_RequiredFileUpload_ShouldFailWithValidationError()
- {
- ((FileUploadField)tester.getLastRenderedPage().get("form:" + fileUploadId)).setRequired(true);
-
- formTester.setValue(textFieldId, "test value");
-
- formTester.submit();
- tester.assertErrorMessages("Field 'fileUpload' is required.");
- }
-}