-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#186: Refactoring - move next http calls to the new architecture
- Loading branch information
Showing
4 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
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
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
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,7 @@ | ||
package com.ecwid.consul; | ||
|
||
public class ConsulTestConstants { | ||
|
||
public static final String CONSUL_VERSION = "1.6.0"; | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/com/ecwid/consul/v1/catalog/CatalogConsulClientTest.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,52 @@ | ||
package com.ecwid.consul.v1.catalog; | ||
|
||
import com.ecwid.consul.ConsulTestConstants; | ||
import com.ecwid.consul.v1.Response; | ||
import com.ecwid.consul.v1.catalog.model.Node; | ||
import com.ecwid.consul.v1.kv.KeyValueConsulClient; | ||
import com.pszymczyk.consul.ConsulProcess; | ||
import com.pszymczyk.consul.ConsulStarterBuilder; | ||
import com.pszymczyk.consul.infrastructure.Ports; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.Random; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class CatalogConsulClientTest { | ||
|
||
private static final Random rnd = new Random(); | ||
|
||
private ConsulProcess consul; | ||
private int port = Ports.nextAvailable(); | ||
|
||
private CatalogConsulClient consulClient = new CatalogConsulClient("localhost", port); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
consul = ConsulStarterBuilder.consulStarter() | ||
.withConsulVersion(ConsulTestConstants.CONSUL_VERSION) | ||
.withHttpPort(port) | ||
.build() | ||
.start(); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
consul.close(); | ||
} | ||
|
||
@Test | ||
void testGetCatalogNodes() { | ||
CatalogNodesRequest request = CatalogNodesRequest.newBuilder().build(); | ||
Response<List<Node>> response = consulClient.getCatalogNodes(request); | ||
|
||
// We should find only one node – this | ||
assertEquals(1, response.getValue().size()); | ||
} | ||
|
||
|
||
} |