Search in sources :

Example 1 with P4Client

use of com.thoughtworks.go.domain.materials.perforce.P4Client in project gocd by gocd.

the class P4TestRepo method createClientWith.

public P4Client createClientWith(String clientName, String view) throws Exception {
    String p4view = view == null ? "\n\t//depot/... //" + clientName + "/..." : "\n\t" + view;
    P4Client p4Client = P4Client.fromServerAndPort(null, serverAndPort(), user, password, clientName, useTickets, clientFolder, p4view, inMemoryConsumer(), true);
    return p4Client;
}
Also used : P4Client(com.thoughtworks.go.domain.materials.perforce.P4Client)

Example 2 with P4Client

use of com.thoughtworks.go.domain.materials.perforce.P4Client in project gocd by gocd.

the class P4TestRepo method checkInOneFile.

private List<Modification> checkInOneFile(P4Material p4Material1, String fileName, String comment) throws Exception {
    File workingDir = TestFileUtil.createTempFolder("p4-working-dir-" + UUID.randomUUID());
    P4Client client = createClient();
    client.client(clientConfig(clientName, workingDir), inMemoryConsumer(), true);
    File dir = new File(workingDir, p4Material1.getFolder());
    dir.mkdirs();
    checkout(dir);
    File newFile = new File(new File(workingDir, p4Material1.getFolder()), fileName);
    newFile.createNewFile();
    add(workingDir, newFile.getAbsolutePath());
    commit(comment, workingDir);
    client.removeClient();
    List<Modification> modifications = p4Material1.latestModification(workingDir, new TestSubprocessExecutionContext());
    return modifications;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) P4Client(com.thoughtworks.go.domain.materials.perforce.P4Client) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) File(java.io.File)

Example 3 with P4Client

use of com.thoughtworks.go.domain.materials.perforce.P4Client in project gocd by gocd.

the class P4Material method getP4.

protected P4Client getP4(File baseDir) {
    InMemoryStreamConsumer outputConsumer = inMemoryConsumer();
    P4Client p4 = null;
    try {
        p4 = p4(baseDir, outputConsumer);
    } catch (Exception e) {
        bomb(e.getMessage() + " " + outputConsumer.getStdError(), e);
    }
    return p4;
}
Also used : P4Client(com.thoughtworks.go.domain.materials.perforce.P4Client) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) IOException(java.io.IOException)

Example 4 with P4Client

use of com.thoughtworks.go.domain.materials.perforce.P4Client in project gocd by gocd.

the class P4MaterialTest method shouldGenerateTheSameP4ClientValueForCommandAndEnvironment.

@Test
public void shouldGenerateTheSameP4ClientValueForCommandAndEnvironment() throws Exception {
    P4Material p4Material = new P4Material("server:10", "out-of-the-window");
    ReflectionUtil.setField(p4Material, "folder", "crapy_dir");
    P4Client p4Client = p4Material._p4(tempDir, new InMemoryStreamConsumer(), false);
    assertThat(p4Client, is(not(nullValue())));
    String client = (String) ReflectionUtil.getField(p4Client, "p4ClientName");
    assertThat(client, is(p4Material.clientName(tempDir)));
}
Also used : P4Client(com.thoughtworks.go.domain.materials.perforce.P4Client) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

P4Client (com.thoughtworks.go.domain.materials.perforce.P4Client)4 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)2 Modification (com.thoughtworks.go.domain.materials.Modification)1 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)1 File (java.io.File)1 IOException (java.io.IOException)1 InvalidCipherTextException (org.bouncycastle.crypto.InvalidCipherTextException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1