Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'SpigotMC-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sleiss committed Aug 12, 2018
2 parents 5bb68bd + fa22848 commit 84ccde5
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 2 deletions.
13 changes: 11 additions & 2 deletions api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ public enum Result
/**
* Timeout in milliseconds for request.
*/
@Builder.Default
private final int connectTimeout = 5000; // TODO: Configurable
private final int connectTimeout;
/**
* Should the player be attempted to connect to the next server in their
* queue if the initial request fails.
*/
private final boolean retry;

/**
* Class that sets default properties/adds methods to the lombok builder
* generated class.
*/
public static class Builder
{

private int connectTimeout = 5000; // TODO: Configurable
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package net.md_5.bungee.api;

import java.net.InetSocketAddress;
import java.util.Collection;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ServerConnectEvent;
import org.junit.Assert;
import org.junit.Test;

public class ServerConnectRequestTest
{

private static final ServerInfo DUMMY_INFO = new ServerInfo()
{
@Override
public String getName()
{
return null;
}

@Override
public InetSocketAddress getAddress()
{
return null;
}

@Override
public Collection<ProxiedPlayer> getPlayers()
{
return null;
}

@Override
public String getMotd()
{
return null;
}

@Override
public boolean canAccess(CommandSender sender)
{
return false;
}

@Override
public void sendData(String channel, byte[] data)
{
}

@Override
public boolean sendData(String channel, byte[] data, boolean queue)
{
return false;
}

@Override
public void ping(Callback<ServerPing> callback)
{
}
};

@Test
public void testDefaultConnectTimeout()
{
ServerConnectRequest request = ServerConnectRequest.builder().target( DUMMY_INFO ).reason( ServerConnectEvent.Reason.JOIN_PROXY ).build();
Assert.assertEquals( 5000, request.getConnectTimeout() );
}

@Test(expected = NullPointerException.class)
public void testNullTarget()
{
ServerConnectRequest.builder().target( null ).reason( ServerConnectEvent.Reason.JOIN_PROXY ).build();
}

@Test(expected = NullPointerException.class)
public void testNullReason()
{
ServerConnectRequest.builder().target( DUMMY_INFO ).reason( null ).build();
}
}

0 comments on commit 84ccde5

Please sign in to comment.