@@ -82,11 +82,13 @@ public void testCreateDefaultSession() throws OpenTokException {
82
82
assertEquals (this .apiKey , session .getApiKey ());
83
83
assertEquals (sessionId , session .getSessionId ());
84
84
assertEquals (MediaMode .RELAYED , session .getProperties ().mediaMode ());
85
+ assertEquals (ArchiveMode .MANUAL , session .getProperties ().archiveMode ());
85
86
assertNull (session .getProperties ().getLocation ());
86
87
87
88
verify (postRequestedFor (urlMatching ("/session/create" ))
88
89
.withRequestBody (matching (".*p2p.preference=enabled.*" ))
89
- .withHeader ("X-TB-PARTNER-AUTH" , matching (this .apiKey +":" +this .apiSecret ))
90
+ .withRequestBody (matching (".*archiveMode=manual.*" ))
91
+ .withHeader ("X-TB-PARTNER-AUTH" , matching (this .apiKey + ":" + this .apiSecret ))
90
92
.withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION +".*" )));
91
93
}
92
94
@@ -149,13 +151,52 @@ public void testCreateLocationHintSession() throws OpenTokException {
149
151
.withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION +".*" )));
150
152
}
151
153
154
+ @ Test
155
+ public void testCreateAlwaysArchivedSession () throws OpenTokException {
156
+ String sessionId = "SESSIONID" ;
157
+ String locationHint = "12.34.56.78" ;
158
+ stubFor (post (urlEqualTo ("/session/create" ))
159
+ .willReturn (aResponse ()
160
+ .withStatus (200 )
161
+ .withHeader ("Content-Type" , "text/xml" )
162
+ .withBody ("<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" yes\" ?><sessions><Session><" +
163
+ "session_id>" + sessionId + "</session_id><partner_id>123456</partner_id><create_dt>" +
164
+ "Mon Mar 17 00:41:31 PDT 2014</create_dt></Session></sessions>" )));
165
+
166
+ SessionProperties properties = new SessionProperties .Builder ()
167
+ .archiveMode (ArchiveMode .ALWAYS )
168
+ .build ();
169
+ Session session = sdk .createSession (properties );
170
+
171
+ assertNotNull (session );
172
+ assertEquals (this .apiKey , session .getApiKey ());
173
+ assertEquals (sessionId , session .getSessionId ());
174
+ assertEquals (ArchiveMode .ALWAYS , session .getProperties ().archiveMode ());
175
+
176
+
177
+ verify (postRequestedFor (urlMatching ("/session/create" ))
178
+ // TODO: this is a pretty bad way to verify, ideally we can decode the body and then query the object
179
+ .withRequestBody (matching (".*archiveMode=always.*" ))
180
+ .withHeader ("X-TB-PARTNER-AUTH" , matching (this .apiKey + ":" + this .apiSecret ))
181
+ .withHeader ("User-Agent" , matching (".*Opentok-Java-SDK/" + Version .VERSION + ".*" )));
182
+ }
183
+
152
184
@ Test (expected = InvalidArgumentException .class )
153
185
public void testCreateBadSession () throws OpenTokException {
154
- SessionProperties properties = new SessionProperties .Builder ()
155
- .location ("NOT A VALID IP" )
156
- .build ();
186
+ SessionProperties properties = new SessionProperties .Builder ()
187
+ .location ("NOT A VALID IP" )
188
+ .build ();
157
189
}
158
190
191
+ // This is not part of the API because it would introduce a backwards incompatible change.
192
+ // @Test(expected = InvalidArgumentException.class)
193
+ // public void testCreateInvalidAlwaysArchivedAndRelayedSession() throws OpenTokException {
194
+ // SessionProperties properties = new SessionProperties.Builder()
195
+ // .mediaMode(MediaMode.RELAYED)
196
+ // .archiveMode(ArchiveMode.ALWAYS)
197
+ // .build();
198
+ // }
199
+
159
200
// TODO: test session creation conditions that result in errors
160
201
161
202
@ Test
0 commit comments