mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-24 23:32:05 +01:00
Add DataValidationTest.testNamespacePrefix()
This commit is contained in:
parent
702b9a5139
commit
bd08f11c4a
1 changed files with 39 additions and 1 deletions
|
@ -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 =
|
||||
"<x xmlns='jabber:x:data'" +
|
||||
" xmlns:xdv='http://jabber.org/protocol/xdata-validate'" +
|
||||
" type='form'>" +
|
||||
" <title>Sample Form</title>" +
|
||||
" <instructions>" +
|
||||
" Please provide information for the following fields..." +
|
||||
" </instructions>" +
|
||||
" <field type='text-single' var='name' label='Event Name'/>" +
|
||||
" <field type='text-single' var='date/start' label='Starting Date'>" +
|
||||
" <xdv:validate datatype='xs:date'>" +
|
||||
" <basic/>" +
|
||||
" </xdv:validate>" +
|
||||
" </field>" +
|
||||
" <field type='text-single' var='date/end' label='Ending Date'>" +
|
||||
" <xdv:validate datatype='xs:date'>" +
|
||||
" <basic/>" +
|
||||
" </xdv:validate>" +
|
||||
" </field>" +
|
||||
"</x>";
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue