Example usage for org.springframework.boot.cli.command.status ExitStatus OK

List of usage examples for org.springframework.boot.cli.command.status ExitStatus OK

Introduction

In this page you can find the example usage for org.springframework.boot.cli.command.status ExitStatus OK.

Prototype

ExitStatus OK

To view the source code for org.springframework.boot.cli.command.status ExitStatus OK.

Click Source Link

Document

Generic "OK" exit status with zero exit code and hangup=false .

Usage

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProject() throws Exception {
    String fileName = UUID.randomUUID().toString() + ".zip";
    File file = new File(fileName);
    assertThat(file.exists()).as("file should not exist").isFalse();
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            fileName);/*from ww w . j  a  va 2s.c o m*/
    mockSuccessfulProjectGeneration(request);
    try {
        assertThat(this.command.run()).isEqualTo(ExitStatus.OK);
        assertThat(file.exists()).as("file should have been created").isTrue();
    } finally {
        assertThat(file.delete()).as("failed to delete test file").isTrue();
    }
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectAndExtract() throws Exception {
    File folder = this.temporaryFolder.newFolder();
    byte[] archive = createFakeZipArchive("test.txt", "Fake content");
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            "demo.zip", archive);
    mockSuccessfulProjectGeneration(request);
    assertThat(this.command.run("--extract", folder.getAbsolutePath())).isEqualTo(ExitStatus.OK);
    File archiveFile = new File(folder, "test.txt");
    assertThat(archiveFile).exists();/* ww  w  . j  a  v a  2  s  . com*/
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectAndExtractWithConvention() throws Exception {
    File folder = this.temporaryFolder.newFolder();
    byte[] archive = createFakeZipArchive("test.txt", "Fake content");
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            "demo.zip", archive);
    mockSuccessfulProjectGeneration(request);
    assertThat(this.command.run(folder.getAbsolutePath() + "/")).isEqualTo(ExitStatus.OK);
    File archiveFile = new File(folder, "test.txt");
    assertThat(archiveFile).exists();//from   w ww  . ja  va 2 s  . c o m
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectArchiveExtractedByDefault() throws Exception {
    String fileName = UUID.randomUUID().toString();
    assertThat(fileName.contains(".")).as("No dot in filename").isFalse();
    byte[] archive = createFakeZipArchive("test.txt", "Fake content");
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            "demo.zip", archive);
    mockSuccessfulProjectGeneration(request);
    File file = new File(fileName);
    File archiveFile = new File(file, "test.txt");
    try {/*w w  w  .j  a v  a 2 s  .com*/
        assertThat(this.command.run(fileName)).isEqualTo(ExitStatus.OK);
        assertThat(archiveFile).exists();
    } finally {
        archiveFile.delete();
        file.delete();
    }
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectFileSavedAsFileByDefault() throws Exception {
    String fileName = UUID.randomUUID().toString();
    String content = "Fake Content";
    byte[] archive = content.getBytes();
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/octet-stream",
            "pom.xml", archive);
    mockSuccessfulProjectGeneration(request);
    File file = new File(fileName);
    try {//from w  w w.  ja  v a 2 s. com
        assertThat(this.command.run(fileName)).isEqualTo(ExitStatus.OK);
        assertThat(file.exists()).as("File not saved properly").isTrue();
        assertThat(file.isFile()).as("Should not be a directory").isTrue();
    } finally {
        file.delete();
    }
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectAndExtractUnsupportedArchive() throws Exception {
    File folder = this.temporaryFolder.newFolder();
    String fileName = UUID.randomUUID().toString() + ".zip";
    File file = new File(fileName);
    assertThat(file.exists()).as("file should not exist").isFalse();
    try {/* ww  w . j a  v  a 2 s .co  m*/
        byte[] archive = createFakeZipArchive("test.txt", "Fake content");
        MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/foobar",
                fileName, archive);
        mockSuccessfulProjectGeneration(request);
        assertThat(this.command.run("--extract", folder.getAbsolutePath())).isEqualTo(ExitStatus.OK);
        assertThat(file.exists()).as("file should have been saved instead").isTrue();
    } finally {
        assertThat(file.delete()).as("failed to delete test file").isTrue();
    }
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void generateProjectAndExtractUnknownContentType() throws Exception {
    File folder = this.temporaryFolder.newFolder();
    String fileName = UUID.randomUUID().toString() + ".zip";
    File file = new File(fileName);
    assertThat(file.exists()).as("file should not exist").isFalse();
    try {/*ww  w . j a va  2s . com*/
        byte[] archive = createFakeZipArchive("test.txt", "Fake content");
        MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest(null, fileName,
                archive);
        mockSuccessfulProjectGeneration(request);
        assertThat(this.command.run("--extract", folder.getAbsolutePath())).isEqualTo(ExitStatus.OK);
        assertThat(file.exists()).as("file should have been saved instead").isTrue();
    } finally {
        assertThat(file.delete()).as("failed to delete test file").isTrue();
    }
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void overwriteFile() throws Exception {
    File file = this.temporaryFolder.newFile();
    long fileLength = file.length();
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            file.getAbsolutePath());//from  ww  w .j a v  a  2  s  . com
    mockSuccessfulProjectGeneration(request);
    assertThat(this.command.run("--force")).isEqualTo(ExitStatus.OK);
    assertThat(fileLength != file.length()).as("File should have changed").isTrue();
}

From source file:org.springframework.boot.cli.command.init.InitCommandTests.java

@Test
public void overwriteFileInArchive() throws Exception {
    File folder = this.temporaryFolder.newFolder();
    File conflict = new File(folder, "test.txt");
    assertThat(conflict.createNewFile()).as("Should have been able to create file").isTrue();
    long fileLength = conflict.length();
    // also contains test.txt
    byte[] archive = createFakeZipArchive("test.txt", "Fake content");
    MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest("application/zip",
            "demo.zip", archive);
    mockSuccessfulProjectGeneration(request);
    assertThat(this.command.run("--force", "--extract", folder.getAbsolutePath())).isEqualTo(ExitStatus.OK);
    assertThat(fileLength != conflict.length()).as("File should have changed").isTrue();
}