/**
*
* Copyright © 2017 Grigory Fedorov
*
* Licensed 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.jivesoftware.smackx.httpfileupload.provider;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
import org.junit.jupiter.api.Test;
public class FileTooLargeErrorProviderTest {
/**
* Example 7. Alternative response by the upload service if the file size was too large
* @see XEP-0363: HTTP File Upload 5. Error conditions
*/
private static final String slotErrorFileToLarge
= ""
+ ""
+ "my_juliet.png"
+ "23456"
+ ""
+ ""
+ ""
+ "File too large. The maximum file size is 20000 bytes"
+ ""
+ "20000"
+ ""
+ ""
+ "";
@Test
public void checkSlotErrorFileToLarge() throws Exception {
IQ fileTooLargeErrorIQ = PacketParserUtils.parseStanza(slotErrorFileToLarge);
assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
FileTooLargeError fileTooLargeError = FileTooLargeError.from(fileTooLargeErrorIQ);
assertEquals(20000, fileTooLargeError.getMaxFileSize());
}
}