Fixed system test and added some fixes for Java backwards compatibility

This commit is contained in:
2017-06-27 17:22:48 +02:00
parent 322bddcc4f
commit aee5debdd2
21 changed files with 89 additions and 94 deletions

View File

@ -75,7 +75,7 @@ class Connection(
fun send(payload: MessagePayload) = io.send(payload)
protected fun handleMessage(payload: MessagePayload) {
private fun handleMessage(payload: MessagePayload) {
when (state) {
State.CONNECTING -> initializer!!.handleCommand(payload)
State.ACTIVE -> receiveMessage(payload)
@ -108,7 +108,7 @@ class Connection(
private fun receiveMessage(objectMessage: ObjectMessage) {
requestedObjects.remove(objectMessage.inventoryVector)
if (ctx.inventory.contains(objectMessage)) {
LOG.trace("Received object " + objectMessage.inventoryVector + " - already in inventory")
LOG.trace("Received object ${objectMessage.inventoryVector} - already in inventory")
return
}
try {
@ -122,7 +122,7 @@ class Connection(
LOG.warn(e.message)
// DebugUtils.saveToFile(objectMessage); // this line must not be committed active
} catch (e: IOException) {
LOG.error("Stream " + objectMessage.stream + ", object type " + objectMessage.type + ": " + e.message, e)
LOG.error("Stream ${objectMessage.stream}, object type ${objectMessage.type}: ${e.message}", e)
} finally {
if (commonRequestedObjects.remove(objectMessage.inventoryVector) == null) {
LOG.debug("Received object that wasn't requested.")
@ -131,7 +131,7 @@ class Connection(
}
private fun receiveMessage(addr: Addr) {
LOG.trace("Received " + addr.addresses.size + " addresses.")
LOG.trace("Received ${addr.addresses.size} addresses.")
ctx.nodeRegistry.offerAddresses(addr.addresses)
}

View File

@ -431,7 +431,7 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
}
return Property("network",
Property("connectionManager", if (isRunning) "running" else "stopped"),
Property("connections", *streamProperties.toTypedArray()),
Property("connections", streamProperties),
Property("requestedObjects", requestedObjects.size)
)
}

View File

@ -1,49 +0,0 @@
/*
* Copyright 2015 Christian Basler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.dissem.bitmessage.networking;
import ch.dissem.bitmessage.entity.valueobject.NetworkAddress;
import ch.dissem.bitmessage.ports.NodeRegistry;
import java.util.Arrays;
import java.util.List;
/**
* Empty {@link NodeRegistry} that doesn't do anything, but shouldn't break things either.
*/
class TestNodeRegistry implements NodeRegistry {
private List<NetworkAddress> nodes;
public TestNodeRegistry(NetworkAddress... nodes) {
this.nodes = Arrays.asList(nodes);
}
@Override
public void clear() {
// no op
}
@Override
public List<NetworkAddress> getKnownAddresses(int limit, long... streams) {
return nodes;
}
@Override
public void offerAddresses(List<NetworkAddress> addresses) {
// Ignore
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2015 Christian Basler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.dissem.bitmessage.networking
import ch.dissem.bitmessage.entity.valueobject.NetworkAddress
import ch.dissem.bitmessage.ports.NodeRegistry
import java.util.Arrays
/**
* Empty [NodeRegistry] that doesn't do anything, but shouldn't break things either.
*/
internal class TestNodeRegistry(vararg nodes: NetworkAddress) : NodeRegistry {
private val nodes: List<NetworkAddress> = listOf(*nodes)
override fun clear() {
// no op
}
override fun getKnownAddresses(limit: Int, vararg streams: Long): List<NetworkAddress> {
return nodes
}
override fun offerAddresses(addresses: List<NetworkAddress>) {
// Ignore
}
}