This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
forked from SpigotMC/BungeeCord
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
2 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
81 changes: 81 additions & 0 deletions
81
api/src/test/java/net/md_5/bungee/api/ServerConnectRequestTest.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,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(); | ||
} | ||
} |