本文整理汇总了Java中org.apache.maven.settings.Server.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Server.setId方法的具体用法?Java Server.setId怎么用?Java Server.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Server
的用法示例。
在下文中一共展示了Server.setId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test003UsernamePasswordLookup
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public void test003UsernamePasswordLookup()
throws MojoExecutionException
{
Settings settings = new Settings();
Server server = new Server();
server.setId( "somekey" );
server.setUsername( "username" );
server.setPassword( "password" );
settings.addServer( server );
mojo.setSettings( settings );
// force a lookup of username
mojo.setSettingsKey( "somekey" );
mojo.setUsername( null );
mojo.setPassword( null );
mojo.execute();
assertEquals( "username", mojo.getUsername() );
assertEquals( "password", mojo.getPassword() );
}
示例2: addServers
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Adds a list of server configurations to the maven settings object
*
* @param settings Maven Settings to append to
* @param servers Servers to add to the settings
*/
private void addServers(Settings settings, List<MavenSettingsServer> servers) {
for (MavenSettingsServer server : servers) {
Server serverToAdd = new Server();
serverToAdd.setId(server.getId());
String username = server.getUsername();
String password = server.getPassword();
if (StringUtils.isNotBlank(username)) {
serverToAdd.setUsername(username);
}
if (StringUtils.isNotBlank(password)) {
serverToAdd.setPassword(password);
}
settings.addServer(serverToAdd);
}
}
示例3: testAuthenticationHandling
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public void testAuthenticationHandling()
throws Exception
{
Server server = new Server();
server.setId( "repository" );
server.setUsername( "jason" );
server.setPassword( "abc123" );
ArtifactRepository repository =
repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null );
repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) );
Authentication authentication = repository.getAuthentication();
assertNotNull( authentication );
assertEquals( "jason", authentication.getUsername() );
assertEquals( "abc123", authentication.getPassword() );
}
示例4: testValidateUniqueServerId
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public void testValidateUniqueServerId()
throws Exception
{
Settings settings = new Settings();
Server server1 = new Server();
server1.setId( "test" );
settings.addServer( server1 );
Server server2 = new Server();
server2.setId( "test" );
settings.addServer( server2 );
SimpleProblemCollector problems = new SimpleProblemCollector();
validator.validate( settings, problems );
assertEquals( 1, problems.messages.size() );
assertContains( problems.messages.get( 0 ),
"'servers.server.id' must be unique but found duplicate server with id test" );
}
示例5: fetchesCredentialsFromMavenSettings
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* ServerCredentials can fetch credentials from Maven settings.
* @throws Exception If something is wrong
*/
@Test
public void fetchesCredentialsFromMavenSettings() throws Exception {
final String key = "AAAABBBBCCCCDDDDZ9Y1";
final String secret = "AbCdEfGhAbCdEfG/AbCdE7GhAbCdE9Gh+bCdEfGh";
final Server server = new Server();
server.setUsername(key);
server.setPassword(secret);
final String name = "srv1";
server.setId(name);
final Settings settings = new Settings();
settings.addServer(server);
final AWSCredentials creds = new ServerCredentials(settings, name);
MatcherAssert.assertThat(
creds.getAWSAccessKeyId(),
Matchers.equalTo(key)
);
MatcherAssert.assertThat(
creds.getAWSSecretKey(),
Matchers.equalTo(secret)
);
}