title: How do I set up a second remote database for integration testing?
body: <p>I need advice on what method will suit better for my case.</p>
  
  <p>I have a Java application with Spring Boot, and right now, for the testing part, I use a localhost PostgreSQL database. The setup is quite simple; I just have the datasource.url/username/password and port setup in the application.properties file.</p>
  
  <p>Now, I need to use a remote PostgreSQL database for a particular integration test class. So, as far as I know, I can do this in at least two ways:</p>
  
  <ul>
  <li><p>I can set up in application.properties another configuration for the remote database, and use it in the test class with <code>environment.getProperty()</code>.</p></li>
  <li><p>Or, I can make a bean to use those properties:</p>
  
  <pre><code>@Bean
  public DataSource dataSource() {
      DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
          dataSourceBuilder.url(dbUrl);
          dataSourceBuilder.username(username);
          dataSourceBuilder.password(password);
          return dataSourceBuilder.build();   
  }
  </code></pre></li>
  </ul>
  
  <p>And the things are not as simple as they may seem.
  I have a class for tests configuration, <strong>ClassA</strong>.</p>
  
  <p>I have a second class with actual tests, let's call it <strong>ClassB</strong>.</p>
  
  <p>ClassB extends Class A, and ClassA starts a JAR file, which is another Java application which exposes some rest APIs, which will be tested with the tests from ClassB.</p>
  
  <p>Now I use a local database, but I will want to use the remote one, in the future.</p>
  
  <p>I managed to download the JAR file from Artifactory with a Maven dependency, and in the configuration class I search for the JAR file, I get the directory of it, and use an array of commands to run it: <code>{"java", "-jar", "directory.getCanonicalPath()}</code>, and <code>ProcessStreamer</code> to process it.</p>
  
  <p>After I check the JAR file is up and running, the tests from ClassB are triggered, and they do CRUD operations against the recently opened application making REST calls to the APIs.</p>
  
  <p>Any suggestions on how I can set up the second remote database?</p>
  
  <p>Thank you!</p>