Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added test case
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
project-model-maven-tests/src/test/java/org/jboss/forge/maven/RepositoryUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.jboss.forge.maven; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.apache.maven.settings.Proxy; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test case for {@link RepositoryUtils} class | ||
* | ||
* @author George Gastaldi <gegastaldi@gmail.com> | ||
* | ||
*/ | ||
public class RepositoryUtilsTest { | ||
|
||
@Test | ||
public void testConvertFromMavenProxyExpectNull() { | ||
assertNull(RepositoryUtils.convertFromMavenProxy(null)); | ||
} | ||
|
||
@Test | ||
public void testConvertFromMavenProxyWithoutAuth() { | ||
Proxy proxySettings = new Proxy(); | ||
proxySettings.setHost("foo.com"); | ||
proxySettings.setPort(3128); | ||
org.sonatype.aether.repository.Proxy proxyObj = RepositoryUtils.convertFromMavenProxy(proxySettings); | ||
assertNotNull(proxyObj); | ||
assertEquals(proxySettings.getHost(), proxyObj.getHost()); | ||
assertEquals(proxySettings.getPort(), proxyObj.getPort()); | ||
assertNull(proxyObj.getAuthentication().getUsername()); | ||
assertNull(proxyObj.getAuthentication().getPassword()); | ||
} | ||
|
||
@Test | ||
public void testConvertFromMavenProxyWithAuth() { | ||
Proxy proxySettings = new Proxy(); | ||
proxySettings.setHost("foo.com"); | ||
proxySettings.setPort(3128); | ||
proxySettings.setUsername("john"); | ||
proxySettings.setPassword("doe"); | ||
org.sonatype.aether.repository.Proxy proxyObj = RepositoryUtils.convertFromMavenProxy(proxySettings); | ||
assertNotNull(proxyObj); | ||
assertEquals(proxySettings.getHost(), proxyObj.getHost()); | ||
assertEquals(proxySettings.getPort(), proxyObj.getPort()); | ||
assertEquals(proxySettings.getUsername(),proxyObj.getAuthentication().getUsername()); | ||
assertEquals(proxySettings.getPassword(),proxyObj.getAuthentication().getPassword()); | ||
} | ||
} |