1010import org .apache .http .impl .client .CloseableHttpClient ;
1111import org .apache .http .impl .client .HttpClients ;
1212import org .jfrog .artifactory .client .model .LocalRepository ;
13+ import org .jfrog .artifactory .client .model .RemoteRepository ;
1314import org .jfrog .artifactory .client .model .Repository ;
15+ import org .jfrog .artifactory .client .model .VirtualRepository ;
1416import org .jfrog .artifactory .client .model .repository .settings .impl .MavenRepositorySettingsImpl ;
1517import org .testng .annotations .AfterClass ;
1618import org .testng .annotations .BeforeClass ;
2022import java .io .InputStreamReader ;
2123import java .security .MessageDigest ;
2224import java .security .NoSuchAlgorithmException ;
25+ import java .util .ArrayList ;
2326import java .util .Arrays ;
27+ import java .util .Collection ;
2428import java .util .Properties ;
2529
2630import static org .apache .commons .codec .binary .Base64 .encodeBase64 ;
@@ -48,11 +52,15 @@ public abstract class ArtifactoryTestsBase {
4852 protected String fileMd5 ;
4953 protected String fileSha1 ;
5054 protected LocalRepository localRepository ;
55+ protected VirtualRepository virtualRepository ;
56+ protected RemoteRepository remoteRepository ;
5157 protected String federationUrl ;
5258
5359 @ BeforeClass
5460 public void init () throws IOException {
5561 String localRepositoryKey = "java-client-" + getClass ().getSimpleName ();
62+ String virtualRepositoryKey = "java-client-virtual-" + getClass ().getSimpleName ();
63+ String remoteRepositoryKey = "java-client-remote-" + getClass ().getSimpleName ();
5664 Properties props = new Properties ();
5765 // This file is not in GitHub. Create your own in src/test/resources.
5866 InputStream inputStream = this .getClass ().getResourceAsStream ("/artifactory-client.properties" );
@@ -76,6 +84,7 @@ public void init() throws IOException {
7684 .setPassword (password )
7785 .build ();
7886 deleteRepoIfExists (localRepositoryKey );
87+ deleteRepoIfExists (virtualRepositoryKey );
7988 deleteRepoIfExists (getJCenterRepoName ());
8089 localRepository = artifactory .repositories ().builders ().localRepositoryBuilder ()
8190 .key (localRepositoryKey )
@@ -84,10 +93,34 @@ public void init() throws IOException {
8493 .propertySets (Arrays .asList ("artifactory" ))
8594 .build ();
8695
96+ Collection <String > repositories = new ArrayList <>();
97+ repositories .add (localRepositoryKey );
98+ virtualRepository = artifactory .repositories ().builders ().virtualRepositoryBuilder ()
99+ .key (virtualRepositoryKey )
100+ .description ("new virtual repository" )
101+ .repositorySettings (new MavenRepositorySettingsImpl ())
102+ .repositories (repositories )
103+ .build ();
104+
87105 if (!artifactory .repository (localRepository .getKey ()).exists ()) {
88106 artifactory .repositories ().create (1 , localRepository );
89107 }
90108
109+ if (!artifactory .repository (virtualRepository .getKey ()).exists ()) {
110+ artifactory .repositories ().create (1 , virtualRepository );
111+ }
112+
113+ remoteRepository = artifactory .repositories ().builders ().remoteRepositoryBuilder ()
114+ .key (remoteRepositoryKey )
115+ .url ("https://repo1.maven.org/maven2/" )
116+ .description ("new maven remote repository" )
117+ .repositorySettings (new MavenRepositorySettingsImpl ())
118+ .build ();
119+
120+ if (!artifactory .repository (remoteRepository .getKey ()).exists ()) {
121+ artifactory .repositories ().create (1 , remoteRepository );
122+ }
123+
91124 String jcenterRepoName = getJCenterRepoName ();
92125 if (!artifactory .repository (jcenterRepoName ).exists ()) {
93126 Repository jcenter = artifactory .repositories ().builders ().remoteRepositoryBuilder ()
0 commit comments