Search in sources :

Example 41 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class HgCommandTest method shouldThrowExceptionForBadConnection.

@Test(expected = RuntimeException.class)
public void shouldThrowExceptionForBadConnection() throws Exception {
    String url = "http://not-exists";
    HgCommand hgCommand = new HgCommand(null, null, null, null, null);
    hgCommand.checkConnection(new UrlArgument(url));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) Test(org.junit.Test)

Example 42 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class HgCommandTest method shouldCloneOnlyTheSpecifiedBranchAndPointToIt.

@Test
public void shouldCloneOnlyTheSpecifiedBranchAndPointToIt() {
    String branchName = "second";
    HgCommand hg = new HgCommand(null, secondBranchWorkingCopy, branchName, serverRepo.getAbsolutePath(), null);
    hg.clone(outputStreamConsumer, new UrlArgument(serverRepo.getAbsolutePath() + "#" + branchName));
    String currentBranch = hg(secondBranchWorkingCopy, "branch").runOrBomb(null).outputAsString();
    assertThat(currentBranch, is(branchName));
    List<String> branches = hg(secondBranchWorkingCopy, "branches").runOrBomb(null).output();
    ArrayList<String> branchNames = new ArrayList<>();
    for (String branchDetails : branches) {
        branchNames.add(StringUtils.split(branchDetails, " ")[0]);
    }
    assertThat(branchNames.size(), is(2));
    assertThat(branchNames.contains(branchName), is(true));
    assertThat(branchNames.contains("default"), is(true));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 43 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class SvnMaterialTest method setUp.

@Before
public void setUp() throws IOException {
    temporaryFolder.create();
    subversion = context.mock(Subversion.class);
    context.checking(new Expectations() {

        {
            allowing(subversion).getUrl();
            will(returnValue(new UrlArgument(URL)));
            allowing(subversion).getPassword();
            will(returnValue(""));
            allowing(subversion).getUserName();
            will(returnValue(""));
            allowing(subversion).isCheckExternals();
            will(returnValue(false));
        }
    });
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(subversion);
    svnMaterial.setUrl(URL);
}
Also used : Expectations(org.jmock.Expectations) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) Before(org.junit.Before)

Example 44 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsSDKCommandBuilderTest method shouldLoadTheCorrectImplementationOfSDKCommandViaTheNestedClassLoader.

@Test
public void shouldLoadTheCorrectImplementationOfSDKCommandViaTheNestedClassLoader() throws Exception {
    when(mockSdkLoader.loadClass("com.thoughtworks.go.tfssdk.TfsSDKCommandTCLAdapter")).thenThrow(new RuntimeException());
    try {
        builder.buildTFSSDKCommand(null, new UrlArgument("url"), DOMAIN, USERNAME, PASSWORD, computedWorkspaceName, "$/project");
        fail("should have failed to load class as we are not wiring any dependencies");
    } catch (Exception e) {
    // Do not worry about load class failing. We're only asserting that load class is invoked with the right FQN for TFSSDKCommand
    }
    verify(mockSdkLoader, times(1)).loadClass("com.thoughtworks.go.tfssdk.TfsSDKCommandTCLAdapter");
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) Test(org.junit.Test)

Example 45 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialConfigUpdateTest method validate_shouldEnsureMaterialNameIsValid.

@Test
public void validate_shouldEnsureMaterialNameIsValid() {
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "passwd", "walk_this_path");
    tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.MATERIAL_NAME), is(nullValue()));
    tfsMaterialConfig.setName(new CaseInsensitiveString(".bad-name-with-dot"));
    tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.MATERIAL_NAME), is("Invalid material name '.bad-name-with-dot'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

UrlArgument (com.thoughtworks.go.util.command.UrlArgument)63 Test (org.junit.Test)47 GoCipher (com.thoughtworks.go.security.GoCipher)37 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)7 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 Material (com.thoughtworks.go.domain.materials.Material)5 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)5 File (java.io.File)5 Map (java.util.Map)5 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)4 InvalidCipherTextException (org.bouncycastle.crypto.InvalidCipherTextException)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3