Skip to content

Commit

Permalink
Add JUPNPTest regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
norohind authored and paroj committed May 8, 2024
1 parent 05c1a97 commit e30c60a
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package github.daneren2005.dsub.domain;

import java.text.ParseException;

import org.jupnp.model.action.ActionInvocation;
import org.jupnp.model.message.control.ActionResponseMessage;
import org.jupnp.model.meta.Action;
import org.jupnp.transport.impl.SOAPActionProcessorImpl;

import junit.framework.TestCase;

public class JUPNPTest extends TestCase {
public void testParseWithPooledParsers() throws ParseException {
// for context see: https://github.com/jupnp/jupnp/issues/232
SOAPActionProcessorImpl p = new SOAPActionProcessorImpl();
ActionResponseMessage arg1 = new ActionResponseMessage() {
final String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><u:GetPositionInfoResponse xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><Track>1</Track><TrackDuration>0</TrackDuration><TrackMetaData>doesn't really matter</TrackMetaData><TrackURI>doesn't really matter</TrackURI><RelTime>0:00:00</RelTime><AbsTime>0:00:00</AbsTime><RelCount>2147483647</RelCount><AbsCount>2147483647</AbsCount></u:GetPositionInfoResponse></s:Body></s:Envelope>";

@Override
public String getActionNamespace() {
System.out.println("GetActionNamespace");
return "GetActionNamespace";
}

@Override
public boolean isBodyNonEmptyString() {
System.out.println("IsBodyNonEmptyString");
return true;
}

@Override
public String getBodyString() {
System.out.println("getBodyString");
return body;
}

@Override
public void setBody(String string) {
System.out.println("setBody");
}
};
ActionInvocation arg2 = new ActionInvocation(new Action("GetPositionInfo", null));
for (int i = 0; i < 20; i++) { // 20 is default pool size
p.readBody(arg1, arg2);
}
System.out.println("--- Crash after this line ---");
p.readBody(arg1, arg2);

}
}

0 comments on commit e30c60a

Please sign in to comment.