/**
 *
 * 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;

import org.jivesoftware.smackx.httpfileupload.element.SlotRequest;

import org.junit.Assert;
import org.junit.Test;
import org.jxmpp.jid.JidTestUtil;
import org.jxmpp.stringprep.XmppStringprepException;


public class SlotRequestCreateTest {

    String testRequest
            = "<request xmlns='urn:xmpp:http:upload:0'"
            +   " filename='my_juliet.png'"
            +   " size='23456'"
            +   " content-type='image/jpeg'"
            + "/>";

    String testRequestWithoutContentType
            = "<request xmlns='urn:xmpp:http:upload:0'"
            +   " filename='my_romeo.png'"
            +   " size='52523'"
            + "/>";

    @Test
    public void checkSlotRequestCreation() throws XmppStringprepException {
        SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 23456, "image/jpeg");

        Assert.assertEquals("my_juliet.png", slotRequest.getFilename());
        Assert.assertEquals(23456, slotRequest.getSize());
        Assert.assertEquals("image/jpeg", slotRequest.getContentType());

        Assert.assertEquals(testRequest, slotRequest.getChildElementXML().toString());
    }

    @Test
    public void checkSlotRequestCreationWithoutContentType() throws XmppStringprepException {
        SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_romeo.png", 52523);

        Assert.assertEquals("my_romeo.png", slotRequest.getFilename());
        Assert.assertEquals(52523, slotRequest.getSize());
        Assert.assertEquals(null, slotRequest.getContentType());

        Assert.assertEquals(testRequestWithoutContentType, slotRequest.getChildElementXML().toString());
    }

    @Test(expected = IllegalArgumentException.class)
    public void checkSlotRequestCreationNegativeSize() {
        new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", -23456, "image/jpeg");
    }

    @Test(expected = IllegalArgumentException.class)
    public void checkSlotRequestCreationZeroSize() {
        new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 0, "image/jpeg");
    }
}

@@ -647,16 +647,111 @@
 pload;%0A%0A
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;%0A%0Aimport java.io.IOException;%0A%0A
 import o
@@ -907,39 +907,19 @@
 org.
-j
 xm
-pp.stringprep.XmppStringprep
+l.sax.SAX
 Exce
@@ -926,17 +926,16 @@
 ption;%0A%0A
-%0A
 public c
@@ -1434,38 +1434,40 @@
 on() throws 
-XmppStringprep
+SAXException, IO
 Exception %7B%0A
@@ -1801,35 +1801,30 @@
         
-Assert.
 assert
+XML
 Equal
-s
 (testReq
@@ -1964,22 +1964,24 @@
 ows 
-XmppStringprep
+SAXException, IO
 Exce
@@ -2299,35 +2299,30 @@
         
-Assert.
 assert
+XML
 Equal
-s
 (testReq

Use assertXMLEqual() in SlotRequestCreateTest