From bd08f11c4a403c13583af8da53fd87ebc9b9e11a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 28 Mar 2018 19:37:26 +0200 Subject: [PATCH] Add DataValidationTest.testNamespacePrefix() --- .../provider/DataValidationTest.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/provider/DataValidationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/provider/DataValidationTest.java index 781e64994..641f417f3 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/provider/DataValidationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/provider/DataValidationTest.java @@ -1,6 +1,6 @@ /** * - * Copyright 2014 Anno van Vliet + * Copyright 2014 Anno van Vliet, 2018 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import java.io.IOException; import org.jivesoftware.smack.test.util.TestUtils; +import org.jivesoftware.smackx.xdata.FormField; +import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement; import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.BasicValidateElement; import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.ListRange; @@ -130,6 +132,42 @@ public class DataValidationTest { DataValidationProvider.parse(parser); } + @Test + public void testNamespacePrefix() throws Exception { + String formFieldUsingNamespacePrefix = + "" + + " Sample Form" + + " " + + " Please provide information for the following fields..." + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + DataForm dataForm = TestUtils.parseExtensionElement(formFieldUsingNamespacePrefix); + + assertEquals("Sample Form", dataForm.getTitle()); + + FormField nameField = dataForm.getField("name"); + assertEquals("Event Name", nameField.getLabel()); + + FormField dataStartField = dataForm.getField("date/start"); + ValidateElement dataStartValidateElement = dataStartField.getValidateElement(); + assertEquals("xs:date", dataStartValidateElement.getDatatype()); + assertTrue(dataStartValidateElement instanceof BasicValidateElement); + } + /** * @param output * @return