01: package test.tck.msgflow.callflows;
02:
03: import java.util.LinkedList;
04: import java.util.ListIterator;
05: import java.util.StringTokenizer;
06:
07: import javax.sip.SipException;
08: import javax.sip.SipStack;
09: import javax.sip.address.Hop;
10: import javax.sip.address.Router;
11: import javax.sip.address.URI;
12: import javax.sip.message.Request;
13:
14: import junit.framework.TestCase;
15:
16: /**
17: * This is a Router for NON-SIP URI requests.
18: * @author M. Ranganathan
19: *
20: */
21: public class NonSipUriRouter implements Router {
22:
23: int myPort = 5070;
24:
25: public static boolean routerWasConsulted = false;
26:
27: class HopImpl implements Hop {
28:
29: public String getHost() {
30:
31: return "127.0.0.1";
32: }
33:
34: public int getPort() {
35:
36: return myPort;
37: }
38:
39: public String getTransport() {
40:
41: return "udp";
42: }
43:
44: }
45:
46: public NonSipUriRouter(SipStack sipStack, String outboundProxy) {
47:
48: }
49:
50: public void setMyPort(int myPort) {
51: this .myPort = myPort;
52: }
53:
54: public Hop getOutboundProxy() {
55:
56: return new HopImpl();
57: }
58:
59: public ListIterator getNextHops(Request request) {
60: URI uri = request.getRequestURI();
61: ScenarioHarness.assertTrue(
62: "Expected to be consulted only for tel uri", uri
63: .getScheme().equals("tel"));
64: LinkedList llist = new LinkedList();
65: llist.add(new HopImpl());
66: return llist.listIterator();
67: }
68:
69: public Hop getNextHop(Request request) throws SipException {
70: routerWasConsulted = true;
71: URI uri = request.getRequestURI();
72: ScenarioHarness.assertTrue(
73: "expected to be consulted only for tel uri", uri
74: .getScheme().equals("tel"));
75: return new HopImpl();
76: }
77:
78: }
|