@Test public void testOverflow() { final AtomicReference<SrvRply> srvRply = new AtomicReference<SrvRply>(); UDPSrvRplyPerformer performer = new UDPSrvRplyPerformer(null, null) { @Override protected void send(InetSocketAddress localAddress, InetSocketAddress remoteAddress, byte[] bytes) { srvRply.set((SrvRply)Message.deserialize(bytes)); } }; String language = Locale.ENGLISH.getLanguage(); ServiceAgentInfo serviceAgent = ServiceAgentInfo.from(UUID.randomUUID().toString(), NetUtils.getLocalhost().getHostAddress(), Scopes.DEFAULT, Attributes.NONE, language); SrvRqst srvRqst = new SrvRqst(); srvRqst.setXID(Message.newXID()); srvRqst.setLanguage(language); srvRqst.addExtension(new LanguageExtension()); srvRqst.addExtension(new ScopeListExtension()); srvRqst.addExtension(new AttributeListExtension()); ServiceURL serviceURL = new ServiceURL("service:jmx:rmi: ServiceInfo service = new ServiceInfo(serviceURL, language, Scopes.DEFAULT, Attributes.from("(a=1,2),(b=true),(c=string),(d=\\FF\\00),e")); List<ServiceInfo> services = new ArrayList<ServiceInfo>(); int count = 50; for (int i = 0; i < count; ++i) services.add(service); performer.perform(null, null, serviceAgent, srvRqst, services); assert srvRply.get() != null; assert srvRply.get().isOverflow(); assert srvRply.get().getURLEntries().size() < count; }
public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services) { IdentifierExtension identifierExtension = null; if (serviceAgent.getIdentifier() != null) identifierExtension = new IdentifierExtension(serviceAgent.getHostAddress(), serviceAgent.getIdentifier()); int maxLength = maxTransmissionUnit - (identifierExtension != null ? identifierExtension.serialize().length : 0); SrvRply srvRply = newSrvRply(message, services, maxLength); if (identifierExtension != null) srvRply.addExtension(identifierExtension); byte[] bytes = srvRply.serialize(); send(localAddress, remoteAddress, bytes); }
UDPSrvRplyPerformer extends SrvRplyPerformer { public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services) { IdentifierExtension identifierExtension = null; if (serviceAgent.getIdentifier() != null) identifierExtension = new IdentifierExtension(serviceAgent.getHostAddress(), serviceAgent.getIdentifier()); int maxLength = maxTransmissionUnit - (identifierExtension != null ? identifierExtension.serialize().length : 0); SrvRply srvRply = newSrvRply(message, services, maxLength); if (identifierExtension != null) srvRply.addExtension(identifierExtension); byte[] bytes = srvRply.serialize(); send(localAddress, remoteAddress, bytes); } }
UDPSrvRplyPerformer extends SrvRplyPerformer { public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services) { IdentifierExtension identifierExtension = null; if (serviceAgent.getIdentifier() != null) identifierExtension = new IdentifierExtension(serviceAgent.getHostAddress(), serviceAgent.getIdentifier()); int maxLength = maxTransmissionUnit - (identifierExtension != null ? identifierExtension.serialize().length : 0); SrvRply srvRply = newSrvRply(message, services, maxLength); if (identifierExtension != null) srvRply.addExtension(identifierExtension); byte[] bytes = srvRply.serialize(); send(localAddress, remoteAddress, bytes); } UDPSrvRplyPerformer(UDPConnector udpConnector, Settings settings); }
UDPSrvRplyPerformer extends SrvRplyPerformer { public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services) { IdentifierExtension identifierExtension = null; if (serviceAgent.getIdentifier() != null) identifierExtension = new IdentifierExtension(serviceAgent.getHostAddress(), serviceAgent.getIdentifier()); int maxLength = maxTransmissionUnit - (identifierExtension != null ? identifierExtension.serialize().length : 0); SrvRply srvRply = newSrvRply(message, services, maxLength); if (identifierExtension != null) srvRply.addExtension(identifierExtension); byte[] bytes = srvRply.serialize(); send(localAddress, remoteAddress, bytes); } UDPSrvRplyPerformer(UDPConnector udpConnector, Settings settings); void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services); }
UDPSrvRplyPerformer extends SrvRplyPerformer { public void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services) { IdentifierExtension identifierExtension = null; if (serviceAgent.getIdentifier() != null) identifierExtension = new IdentifierExtension(serviceAgent.getHostAddress(), serviceAgent.getIdentifier()); int maxLength = maxTransmissionUnit - (identifierExtension != null ? identifierExtension.serialize().length : 0); SrvRply srvRply = newSrvRply(message, services, maxLength); if (identifierExtension != null) srvRply.addExtension(identifierExtension); byte[] bytes = srvRply.serialize(); send(localAddress, remoteAddress, bytes); } UDPSrvRplyPerformer(UDPConnector udpConnector, Settings settings); void perform(InetSocketAddress localAddress, InetSocketAddress remoteAddress, ServiceAgentInfo serviceAgent, Message message, List<? extends ServiceInfo> services);  }