Fixed test isolation

This commit is contained in:
xis 2023-10-30 19:58:53 +01:00
parent 91ae96516c
commit fa5443d0dc
No known key found for this signature in database
GPG key ID: 803DF32037A66D02

View file

@ -2,12 +2,12 @@ package support.beans.dlna.upnp
import org.jupnp.DefaultUpnpServiceConfiguration
import org.jupnp.model.message.OutgoingDatagramMessage
import org.jupnp.transport.Router
import org.jupnp.transport.impl.DatagramIOConfigurationImpl
import org.jupnp.transport.impl.DatagramIOImpl
import org.jupnp.transport.spi.DatagramIO
import org.jupnp.transport.spi.NetworkAddressFactory
import org.jupnp.transport.spi.StreamClient
import org.jupnp.transport.spi.StreamServer
import org.jupnp.transport.impl.MulticastReceiverConfigurationImpl
import org.jupnp.transport.impl.MulticastReceiverImpl
import org.jupnp.transport.spi.*
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component
@ -31,10 +31,33 @@ class UpnpServiceConfigurationInt extends DefaultUpnpServiceConfiguration {
return new MockDatagramIO(this, new DatagramIOConfigurationImpl())
}
@Override
public MulticastReceiver createMulticastReceiver(NetworkAddressFactory networkAddressFactory) {
return new MockMulticastReceiver(
new MulticastReceiverConfigurationImpl(
networkAddressFactory.getMulticastGroup(),
networkAddressFactory.getMulticastPort()
)
);
}
private void onOutgoingDatagramMessage(OutgoingDatagramMessage message) {
outgoingDatagramMessages.add(message)
}
class MockMulticastReceiver extends MulticastReceiverImpl {
MockMulticastReceiver(MulticastReceiverConfigurationImpl configuration) {
super(configuration)
}
@Override
void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException {
}
@Override
public void run() {}
}
class MockDatagramIO extends DatagramIOImpl {
private final UpnpServiceConfigurationInt upnpServiceConfiguration