Skip to content

Commit

Permalink
replaced SocketReceiver host property with remoteHost
Browse files Browse the repository at this point in the history
For consistency with SocketAppender...
  • Loading branch information
ceharris committed Apr 15, 2013
1 parent e7740af commit 9ae04e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
Expand Up @@ -46,7 +46,7 @@ public class SocketReceiver extends ReceiverBase

private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000;

private String host;
private String remoteHost;
private InetAddress address;
private int port;
private int reconnectionDelay;
Expand All @@ -66,7 +66,7 @@ protected boolean shouldStart() {
+ "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_port");
}

if (host == null) {
if (remoteHost == null) {
errorCount++;
addError("No host name or address was configured for remote. "
+ "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_host");
Expand All @@ -78,16 +78,16 @@ protected boolean shouldStart() {

if (errorCount == 0) {
try {
address = InetAddress.getByName(host);
address = InetAddress.getByName(remoteHost);
}
catch (UnknownHostException ex) {
addError("unknown host: " + host);
addError("unknown host: " + remoteHost);
errorCount++;
}
}

if (errorCount == 0) {
remoteId = "remote " + host + ":" + port + ": ";
remoteId = "remote " + remoteHost + ":" + port + ": ";
}

return errorCount == 0;
Expand Down Expand Up @@ -206,12 +206,8 @@ protected ExecutorService createExecutorService() {
return Executors.newCachedThreadPool();
}

public void setHost(String host) {
this.host = host;
}

public void setRemoteHost(String host) {
setHost(host);
public void setRemoteHost(String remoteHost) {
this.remoteHost = remoteHost;
}

public void setPort(int port) {
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void setUp() throws Exception {
@Test
public void testUsingDefaultConfig() throws Exception {
// should be able to start successfully with no SSL configuration at all
remote.setHost(InetAddress.getLocalHost().getHostAddress());
remote.setRemoteHost(InetAddress.getLocalHost().getHostAddress());
remote.setPort(6000);
remote.start();
assertNotNull(remote.getSocketFactory());
Expand Down
Expand Up @@ -109,7 +109,7 @@ public void testStartNoRemoteAddress() throws Exception {

@Test
public void testStartNoPort() throws Exception {
remote.setHost(TEST_HOST_NAME);
remote.setRemoteHost(TEST_HOST_NAME);
remote.start();
assertFalse(remote.isStarted());
int count = lc.getStatusManager().getCount();
Expand All @@ -120,7 +120,7 @@ public void testStartNoPort() throws Exception {
@Test
public void testStartUnknownHost() throws Exception {
remote.setPort(6000);
remote.setHost(TEST_HOST_NAME);
remote.setRemoteHost(TEST_HOST_NAME);
remote.start();
assertFalse(remote.isStarted());
int count = lc.getStatusManager().getCount();
Expand All @@ -130,7 +130,7 @@ public void testStartUnknownHost() throws Exception {

@Test
public void testStartStop() throws Exception {
remote.setHost(InetAddress.getLocalHost().getHostName());
remote.setRemoteHost(InetAddress.getLocalHost().getHostName());
remote.setPort(6000);
remote.setAcceptConnectionTimeout(DELAY / 2);
remote.start();
Expand All @@ -142,7 +142,7 @@ public void testStartStop() throws Exception {

@Test
public void testServerSlowToAcceptConnection() throws Exception {
remote.setHost(InetAddress.getLocalHost().getHostName());
remote.setRemoteHost(InetAddress.getLocalHost().getHostName());
remote.setPort(6000);
remote.setAcceptConnectionTimeout(DELAY / 4);
remote.start();
Expand All @@ -153,7 +153,7 @@ public void testServerSlowToAcceptConnection() throws Exception {

@Test
public void testServerDropsConnection() throws Exception {
remote.setHost(InetAddress.getLocalHost().getHostName());
remote.setRemoteHost(InetAddress.getLocalHost().getHostName());
remote.setPort(6000);
remote.start();
assertTrue(remote.awaitConnectorCreated(DELAY));
Expand All @@ -163,7 +163,7 @@ public void testServerDropsConnection() throws Exception {

@Test
public void testDispatchEventForEnabledLevel() throws Exception {
remote.setHost(InetAddress.getLocalHost().getHostName());
remote.setRemoteHost(InetAddress.getLocalHost().getHostName());
remote.setPort(6000);
remote.start();
assertTrue(remote.awaitConnectorCreated(DELAY));
Expand All @@ -188,7 +188,7 @@ public void testDispatchEventForEnabledLevel() throws Exception {

@Test
public void testNoDispatchEventForDisabledLevel() throws Exception {
remote.setHost(InetAddress.getLocalHost().getHostName());
remote.setRemoteHost(InetAddress.getLocalHost().getHostName());
remote.setPort(6000);
remote.start();
assertTrue(remote.awaitConnectorCreated(DELAY));
Expand Down

0 comments on commit 9ae04e1

Please sign in to comment.