Search in sources :

Example 1 with IceServerList

use of com.faforever.server.ice.IceServerList in project faf-java-server by FAForever.

the class V2ServerMessageTransformerTest method iceServers.

@Test
public void iceServers() {
    Instant createdAt = Instant.parse("2007-12-03T10:15:30.00Z");
    String response = instance.transform(new IceServersResponse(Collections.singletonList(new IceServerList(3600, createdAt, Collections.singletonList(new IceServer(URI.create("http://localhost"), "anonymous", "123", "token"))))));
    assertThat(response, is("{\"data\":{\"iceServerLists\":[{\"ttlSeconds\":3600,\"createdAt\":1196676930000,\"servers\":[{\"url\":\"http://localhost\",\"username\":\"anonymous\",\"credential\":\"123\",\"credentialType\":\"token\"}]}]},\"type\":\"iceServers\"}"));
}
Also used : IceServersResponse(com.faforever.server.client.IceServersResponse) Instant(java.time.Instant) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Example 2 with IceServerList

use of com.faforever.server.ice.IceServerList in project faf-java-server by FAForever.

the class ClientServiceTest method sendIceServers.

@Test
public void sendIceServers() throws Exception {
    List<IceServerList> iceServers = Collections.singletonList(new IceServerList(60, Instant.now(), Arrays.asList(new IceServer(URI.create("turn:test1"), null, null, null), new IceServer(URI.create("turn:test2"), "username", "credential", "credentialType"))));
    ConnectionAware connectionAware = new Player().setClientConnection(clientConnection);
    instance.sendIceServers(iceServers, connectionAware);
    verify(clientGateway).send(new IceServersResponse(iceServers), clientConnection);
}
Also used : Player(com.faforever.server.entity.Player) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Example 3 with IceServerList

use of com.faforever.server.ice.IceServerList in project faf-java-server by FAForever.

the class ServersResponseTransformerTest method transform.

@Test
@SuppressWarnings("unchecked")
public void transform() throws Exception {
    Instant now = Instant.now();
    List<IceServerList> iceServersLists = Collections.singletonList(new IceServerList(60, now, Arrays.asList(new IceServer(URI.create("http://localhost:1234"), "junit1", "test1", "token"), new IceServer(URI.create("http://localhost:2345"), "junit2", "test2", "token"))));
    Map<String, Serializable> result = IceServersResponseTransformer.INSTANCE.transform(new IceServersResponse(iceServersLists));
    assertThat(result.get("command"), is("ice_servers"));
    assertThat(result.get("date_created"), is(DateTimeFormatter.ISO_INSTANT.format(now)));
    assertThat(result.get("ttl"), is(60));
    List<Map<String, Object>> iceServers = (List<Map<String, Object>>) result.get("ice_servers");
    assertThat(iceServers, hasSize(2));
    assertThat(iceServers.get(0).get("url"), is("http://localhost:1234"));
    assertThat(iceServers.get(0).get("username"), is("junit1"));
    assertThat(iceServers.get(0).get("credential"), is("test1"));
    assertThat(iceServers.get(1).get("url"), is("http://localhost:2345"));
    assertThat(iceServers.get(1).get("username"), is("junit2"));
    assertThat(iceServers.get(1).get("credential"), is("test2"));
}
Also used : Serializable(java.io.Serializable) IceServersResponse(com.faforever.server.client.IceServersResponse) Instant(java.time.Instant) IceServer(com.faforever.server.ice.IceServer) IceServerList(com.faforever.server.ice.IceServerList) List(java.util.List) Map(java.util.Map) IceServerList(com.faforever.server.ice.IceServerList) Test(org.junit.Test)

Aggregations

IceServer (com.faforever.server.ice.IceServer)3 IceServerList (com.faforever.server.ice.IceServerList)3 Test (org.junit.Test)3 IceServersResponse (com.faforever.server.client.IceServersResponse)2 Instant (java.time.Instant)2 Player (com.faforever.server.entity.Player)1 Serializable (java.io.Serializable)1 List (java.util.List)1 Map (java.util.Map)1