Package org.apache.xindice.webadmin

Source Code of org.apache.xindice.webadmin.MkcolTest

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.xindice.webadmin;

import org.apache.xindice.webadmin.webdav.components.Mkcol;
import org.apache.xindice.webadmin.webdav.WebdavStatus;

public class MkcolTest extends MethodSetup {

    public void setUp() throws Exception {
        super.setUp();
        method = new Mkcol();
    }

    public void testMkcolNullCollection() throws Exception {
        // collection was not found: one or more intermediate collections do not exist
        method.execute(request, response, new Location("/unknown"));
        assertEquals(WebdavStatus.SC_CONFLICT, httpResponse.getStatus());
    }

    public void testMkcolExistingCollection() throws Exception {
        // collection already exists
        method.execute(request, response, new Location(collection.getCanonicalName()));
        assertEquals(WebdavStatus.SC_METHOD_NOT_ALLOWED, httpResponse.getStatus());
    }

    public void testMkcolCollection() throws Exception {
        String name = "new";

        method.execute(request, response, new Location(collection.getCanonicalDocumentName(name)));
        assertEquals(WebdavStatus.SC_CREATED, httpResponse.getStatus());
        assertNotNull(collection.getCollection(name));
    }

    public void testMkcolCollectionRequestBody() throws Exception {
        httpRequest.setInput("<test/>");
        method.execute(request, response, new Location(collection.getCanonicalDocumentName("new")));
        assertEquals(WebdavStatus.SC_UNSUPPORTED_MEDIA_TYPE, httpResponse.getStatus());
    }

    //TODO: test SC_FORBIDDEN
}
TOP

Related Classes of org.apache.xindice.webadmin.MkcolTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.