本文整理汇总了Java中org.apache.maven.settings.Server.setUsername方法的典型用法代码示例。如果您正苦于以下问题:Java Server.setUsername方法的具体用法?Java Server.setUsername怎么用?Java Server.setUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Server
的用法示例。
在下文中一共展示了Server.setUsername方法的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: 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)
);
}
示例5: velocityTemplateCorrectlyBuildsSettingsXml
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* DeployMojo can generate correct settings.xml file.
* @throws Exception If something is wrong
*/
@Test
public void velocityTemplateCorrectlyBuildsSettingsXml() throws Exception {
final Server server = new Server();
server.setUsername("john");
server.setPassword("xxx");
final Settings settings = new Settings();
settings.addServer(server);
final String nspace = "http://maven.apache.org/SETTINGS/1.0.0";
MatcherAssert.assertThat(
new VelocityPage(
"com/jcabi/heroku/maven/plugin/settings.xml.vm"
).set("settings", settings).toString(),
Matchers.allOf(
XhtmlMatchers.hasXPath(
"//ns1:server[ns1:username='john' and ns1:password='xxx']",
nspace
),
XhtmlMatchers.hasXPath(
"//ns1:server[ns1:username='john' and not(ns1:privateKey)]",
nspace
)
)
);
}