/**
 * 
 */
package com.github.podd.resources.test;

import org.junit.Assert;
import org.junit.Test;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Status;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;

import com.github.ansell.restletutils.test.RestletTestUtils;
import com.github.podd.utils.PoddWebConstants;

/**
 * @author Peter Ansell p_ansell@yahoo.com
 */
public class ListDataRepositoriesResourceImplTest extends AbstractResourceImplTest
{
    
    /**
     * Test requesting data repositories as administrator.
     */
    @Test
    public void testHtmlAuthenticatedAdmin() throws Exception
    {
        final ClientResource dataRepositoriesClientResource =
                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));
        
        Representation result =
                RestletTestUtils.doTestAuthenticatedRequest(dataRepositoriesClientResource, Method.GET, null,
                        MediaType.TEXT_HTML, Status.SUCCESS_OK, this.testWithAdminPrivileges);
    }
    
    /**
     * Test requesting data repositories as administrator.
     */
    @Test
    public void testHtmlAuthenticatedNonAdmin() throws Exception
    {
        final ClientResource dataRepositoriesClientResource =
                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));
        
        try
        {
            RestletTestUtils.doTestAuthenticatedRequest(dataRepositoriesClientResource, Method.GET, null,
                    MediaType.TEXT_HTML, Status.SUCCESS_OK, this.testNoAdminPrivileges);
            Assert.fail("Did not find expected exception");
        }
        catch(ResourceException e)
        {
            Assert.assertEquals("Not the expected HTTP status code", Status.CLIENT_ERROR_UNAUTHORIZED, e.getStatus());
        }
    }
    
    /**
     * Test requesting data repositories as administrator.
     */
    @Test
    public void testHtmlUnauthenticated() throws Exception
    {
        final ClientResource dataRepositoriesClientResource =
                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));
        
        try
        {
            dataRepositoriesClientResource.get();
            Assert.fail("Did not find expected exception");
        }
        catch(ResourceException e)
        {
            Assert.assertEquals("Not the expected HTTP status code", Status.CLIENT_ERROR_UNAUTHORIZED, e.getStatus());
        }
    }
    
}

@@ -2325,16 +2325,35 @@
 rce.get(
+MediaType.TEXT_HTML
 );%0A     
@@ -2602,10 +2602,2058 @@
  %7D%0A    %0A
+    /**%0A     * Test requesting data repositories as administrator.%0A     */%0A    @Test%0A    public void testRdfXmlAuthenticatedAdmin() throws Exception%0A    %7B%0A        final ClientResource dataRepositoriesClientResource =%0A                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));%0A        %0A        Representation result =%0A                RestletTestUtils.doTestAuthenticatedRequest(dataRepositoriesClientResource, Method.GET, null,%0A                        MediaType.APPLICATION_RDF_XML, Status.SUCCESS_OK, this.testWithAdminPrivileges);%0A    %7D%0A    %0A    /**%0A     * Test requesting data repositories as administrator.%0A     */%0A    @Test%0A    public void testRdfXmlAuthenticatedNonAdmin() throws Exception%0A    %7B%0A        final ClientResource dataRepositoriesClientResource =%0A                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));%0A        %0A        try%0A        %7B%0A            RestletTestUtils.doTestAuthenticatedRequest(dataRepositoriesClientResource, Method.GET, null,%0A                    MediaType.APPLICATION_RDF_XML, Status.SUCCESS_OK, this.testNoAdminPrivileges);%0A            Assert.fail(%22Did not find expected exception%22);%0A        %7D%0A        catch(ResourceException e)%0A        %7B%0A            Assert.assertEquals(%22Not the expected HTTP status code%22, Status.CLIENT_ERROR_UNAUTHORIZED, e.getStatus());%0A        %7D%0A    %7D%0A    %0A    /**%0A     * Test requesting data repositories as administrator.%0A     */%0A    @Test%0A    public void testRdfXmlUnauthenticated() throws Exception%0A    %7B%0A        final ClientResource dataRepositoriesClientResource =%0A                new ClientResource(this.getUrl(PoddWebConstants.PATH_DATA_REPOSITORY_LIST));%0A        %0A        try%0A        %7B%0A            dataRepositoriesClientResource.get(MediaType.APPLICATION_RDF_XML);%0A            Assert.fail(%22Did not find expected exception%22);%0A        %7D%0A        catch(ResourceException e)%0A        %7B%0A            Assert.assertEquals(%22Not the expected HTTP status code%22, Status.CLIENT_ERROR_UNAUTHORIZED, e.getStatus());%0A        %7D%0A    %7D%0A
 %7D%0A

Add RDF/XML tests