1
0
Fork 0
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:
Florian Schmaus 2018-03-28 19:37:26 +02:00
parent 702b9a5139
commit bd08f11c4a

View file

@ -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