package org.kohsuke.github;

import junit.framework.TestCase;

import java.util.List;

/**
 * Unit test for {@link GHContent}.
 */
public class GHContentIntegrationTest extends TestCase {

    private GitHub gitHub;
    private GHRepository repo;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        // we just read at the moment
        gitHub = GitHub.connectAnonymously();
        repo = gitHub.getUser("acollign").getRepository("github-api-test");
    }

    public void testGetFileContent() throws Exception {
        GHContent content = repo.getFileContent("ghcontent-ro/a-file-with-content");

        assertTrue(content.isFile());
        assertEquals("thanks for reading me\n", content.getContent());
    }

    public void testGetEmptyFileContent() throws Exception {
        GHContent content = repo.getFileContent("ghcontent-ro/an-empty-file");

        assertTrue(content.isFile());
        assertEquals("", content.getContent());
    }

    public void testGetDirectoryContent() throws Exception {
        List<GHContent> entries = repo.getDirectoryContent("ghcontent-ro/a-dir-with-3-entries");

        assertTrue(entries.size() == 3);
    }
}

@@ -83,20 +83,50 @@
 st;%0A
-%0A/**%0A * Unit
+import java.util.UUID;%0A%0A/**%0A * Integration
  tes
@@ -269,16 +269,52 @@
 ry repo;
+%0A    private String createdFilename;
 %0A%0A    @O
@@ -391,45 +391,8 @@
 ();%0A
-        // we just read at the moment
 %0A   
@@ -423,19 +423,8 @@
 nect
-Anonymously
 ();%0A
@@ -449,28 +449,8 @@
 Hub.
-getUser(%22acollign%22).
 getR
@@ -460,16 +460,25 @@
 sitory(%22
+acollign/
 github-a
@@ -486,16 +486,79 @@
 i-test%22)
+.fork();%0A        createdFilename = UUID.randomUUID().toString()
 ;%0A    %7D%0A
@@ -1255,11 +1255,1148 @@
 );%0A    %7D
+%0A%0A    public void testCRUDContent() throws Exception %7B%0A        GHContentUpdateResponse created = repo.createContent(%22this is an awesome file I created%5Cn%22, %22Creating a file for integration tests.%22, createdFilename);%0A        GHContent createdContent = created.getContent();%0A%0A        assertNotNull(created.getCommit());%0A        assertNotNull(created.getContent());%0A        assertNotNull(createdContent.getContent());%0A        assertEquals(%22this is an awesome file I created%5Cn%22, createdContent.getContent());%0A%0A        GHContentUpdateResponse updatedContentResponse = createdContent.update(%22this is some new content%5Cn%22, %22Updated file for integration tests.%22);%0A        GHContent updatedContent = updatedContentResponse.getContent();%0A%0A        assertNotNull(updatedContentResponse.getCommit());%0A        assertNotNull(updatedContentResponse.getContent());%0A        assertEquals(%22this is some new content%5Cn%22, updatedContent.getContent());%0A%0A        GHContentUpdateResponse deleteResponse = updatedContent.delete(%22Enough of this foolishness!%22);%0A%0A        assertNotNull(deleteResponse.getCommit());%0A        assertNull(deleteResponse.getContent());%0A    %7D
 %0A%7D%0A

Implement a CRUD integration test for the content api.