LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 13 matching lines...) Expand all Loading... |
24 import com.google.enterprise.adaptor.Acl; | 24 import com.google.enterprise.adaptor.Acl; |
25 import com.google.enterprise.adaptor.Config; | 25 import com.google.enterprise.adaptor.Config; |
26 import com.google.enterprise.adaptor.DocId; | 26 import com.google.enterprise.adaptor.DocId; |
27 import com.google.enterprise.adaptor.DocIdPusher; | 27 import com.google.enterprise.adaptor.DocIdPusher; |
28 import com.google.enterprise.adaptor.GroupPrincipal; | 28 import com.google.enterprise.adaptor.GroupPrincipal; |
29 import com.google.enterprise.adaptor.IOHelper; | 29 import com.google.enterprise.adaptor.IOHelper; |
30 import com.google.enterprise.adaptor.Metadata; | 30 import com.google.enterprise.adaptor.Metadata; |
31 import com.google.enterprise.adaptor.UserPrincipal; | 31 import com.google.enterprise.adaptor.UserPrincipal; |
32 import com.google.enterprise.adaptor.sharepoint.SharePointAdaptor.SiteUserIdMapp
ingCallable; | 32 import com.google.enterprise.adaptor.sharepoint.SharePointAdaptor.SiteUserIdMapp
ingCallable; |
33 import com.google.enterprise.adaptor.sharepoint.SharePointAdaptor.SoapFactory; | 33 import com.google.enterprise.adaptor.sharepoint.SharePointAdaptor.SoapFactory; |
34 import com.microsoft.schemas.sharepoint.soap.Authentication.AuthenticationMode; | 34 import com.microsoft.schemas.sharepoint.soap.authentication.AuthenticationMode; |
35 import com.microsoft.schemas.sharepoint.soap.Authentication.AuthenticationSoap; | 35 import com.microsoft.schemas.sharepoint.soap.authentication.AuthenticationSoap; |
36 import com.microsoft.schemas.sharepoint.soap.Authentication.LoginErrorCode; | 36 import com.microsoft.schemas.sharepoint.soap.authentication.LoginErrorCode; |
37 import com.microsoft.schemas.sharepoint.soap.Authentication.LoginResult; | 37 import com.microsoft.schemas.sharepoint.soap.authentication.LoginResult; |
38 | 38 |
39 import com.microsoft.schemas.sharepoint.soap.ObjectType; | 39 import com.microsoft.schemas.sharepoint.soap.ObjectType; |
40 import com.microsoft.schemas.sharepoint.soap.SPContentDatabase; | 40 import com.microsoft.schemas.sharepoint.soap.SPContentDatabase; |
41 import com.microsoft.schemas.sharepoint.soap.SiteDataSoap; | 41 import com.microsoft.schemas.sharepoint.soap.SiteDataSoap; |
42 import com.microsoft.schemas.sharepoint.soap.directory.AddUserCollectionToGroup; | 42 import com.microsoft.schemas.sharepoint.soap.directory.AddUserCollectionToGroup; |
43 import com.microsoft.schemas.sharepoint.soap.directory.AddUserCollectionToRole; | 43 import com.microsoft.schemas.sharepoint.soap.directory.AddUserCollectionToRole; |
44 import com.microsoft.schemas.sharepoint.soap.directory.EmailsInputType; | 44 import com.microsoft.schemas.sharepoint.soap.directory.EmailsInputType; |
45 import com.microsoft.schemas.sharepoint.soap.directory.GetAllUserCollectionFromW
ebResponse; | 45 import com.microsoft.schemas.sharepoint.soap.directory.GetAllUserCollectionFromW
ebResponse; |
46 import com.microsoft.schemas.sharepoint.soap.directory.GetCurrentUserInfoRespons
e; | 46 import com.microsoft.schemas.sharepoint.soap.directory.GetCurrentUserInfoRespons
e; |
47 import com.microsoft.schemas.sharepoint.soap.directory.GetGroupCollectionFromRol
eResponse; | 47 import com.microsoft.schemas.sharepoint.soap.directory.GetGroupCollectionFromRol
eResponse; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 import java.util.concurrent.*; | 88 import java.util.concurrent.*; |
89 import java.util.concurrent.atomic.AtomicLong; | 89 import java.util.concurrent.atomic.AtomicLong; |
90 | 90 |
91 import javax.xml.ws.Holder; | 91 import javax.xml.ws.Holder; |
92 import javax.xml.ws.WebServiceException; | 92 import javax.xml.ws.WebServiceException; |
93 | 93 |
94 /** | 94 /** |
95 * Test cases for {@link SharePointAdaptor}. | 95 * Test cases for {@link SharePointAdaptor}. |
96 */ | 96 */ |
97 public class SharePointAdaptorTest { | 97 public class SharePointAdaptorTest { |
| 98 private static final String AUTH_ENDPOINT |
| 99 = "http://localhost:1/_vti_bin/Authentication.asmx"; |
98 private static final String VS_ENDPOINT | 100 private static final String VS_ENDPOINT |
99 = "http://localhost:1/_vti_bin/SiteData.asmx"; | 101 = "http://localhost:1/_vti_bin/SiteData.asmx"; |
100 private static final ContentExchange VS_CONTENT_EXCHANGE | 102 private static final ContentExchange VS_CONTENT_EXCHANGE |
101 = new ContentExchange(ObjectType.VIRTUAL_SERVER, null, null, null, | 103 = new ContentExchange(ObjectType.VIRTUAL_SERVER, null, null, null, |
102 true, false, null, loadTestString("vs.xml")); | 104 true, false, null, loadTestString("vs.xml")); |
103 private static final ContentExchange CD_CONTENT_EXCHANGE | 105 private static final ContentExchange CD_CONTENT_EXCHANGE |
104 = new ContentExchange(ObjectType.CONTENT_DATABASE, | 106 = new ContentExchange(ObjectType.CONTENT_DATABASE, |
105 "{4fb7dea1-2912-4927-9eda-1ea2f0977cf8}", null, null, true, false, | 107 "{4fb7dea1-2912-4927-9eda-1ea2f0977cf8}", null, null, true, false, |
106 null, loadTestString("cd.xml")); | 108 null, loadTestString("cd.xml")); |
107 private static final String SITES_SITECOLLECTION_ENDPOINT | 109 private static final String SITES_SITECOLLECTION_ENDPOINT |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 private DocIdPusher pusher = new UnsupportedDocIdPusher(); | 180 private DocIdPusher pusher = new UnsupportedDocIdPusher(); |
179 private Callable<ExecutorService> executorFactory | 181 private Callable<ExecutorService> executorFactory |
180 = new Callable<ExecutorService>() { | 182 = new Callable<ExecutorService>() { |
181 @Override | 183 @Override |
182 public ExecutorService call() { | 184 public ExecutorService call() { |
183 return new CallerRunsExecutor(); | 185 return new CallerRunsExecutor(); |
184 } | 186 } |
185 }; | 187 }; |
186 private final MockSoapFactory initableSoapFactory | 188 private final MockSoapFactory initableSoapFactory |
187 = MockSoapFactory.blank() | 189 = MockSoapFactory.blank() |
| 190 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
188 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 191 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
189 .register(VS_CONTENT_EXCHANGE)); | 192 .register(VS_CONTENT_EXCHANGE)); |
190 | 193 |
191 @Rule | 194 @Rule |
192 public ExpectedException thrown = ExpectedException.none(); | 195 public ExpectedException thrown = ExpectedException.none(); |
193 | 196 |
194 /** | 197 /** |
195 * JAXBContext is expensive to create and is created as part of the class' | 198 * JAXBContext is expensive to create and is created as part of the class' |
196 * initialization. Do this in a separately so that the timing for this | 199 * initialization. Do this in a separately so that the timing for this |
197 * initalization does not count toward the first real test run. It looks like | 200 * initalization does not count toward the first real test run. It looks like |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 315 } |
313 | 316 |
314 @Test(expected = IllegalArgumentException.class) | 317 @Test(expected = IllegalArgumentException.class) |
315 public void testSpUrlToUriNoSceme() throws Exception { | 318 public void testSpUrlToUriNoSceme() throws Exception { |
316 SharePointAdaptor.spUrlToUri("http:/"); | 319 SharePointAdaptor.spUrlToUri("http:/"); |
317 } | 320 } |
318 | 321 |
319 @Test | 322 @Test |
320 public void testGetDocContentWrongServer() throws Exception { | 323 public void testGetDocContentWrongServer() throws Exception { |
321 SoapFactory siteDataFactory = MockSoapFactory.blank() | 324 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 325 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
322 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 326 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
323 .register(VS_CONTENT_EXCHANGE) | 327 .register(VS_CONTENT_EXCHANGE) |
324 .register(new SiteAndWebExchange( | 328 .register(new SiteAndWebExchange( |
325 "http://wronghost:1/", 1, null, null))); | 329 "http://wronghost:1/", 1, null, null))); |
326 | 330 |
327 adaptor = new SharePointAdaptor(siteDataFactory, | 331 adaptor = new SharePointAdaptor(siteDataFactory, |
328 new UnsupportedHttpClient(), executorFactory); | 332 new UnsupportedHttpClient(), executorFactory); |
329 adaptor.init(new MockAdaptorContext(config, pusher)); | 333 adaptor.init(new MockAdaptorContext(config, pusher)); |
330 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 334 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
331 GetContentsRequest request = new GetContentsRequest( | 335 GetContentsRequest request = new GetContentsRequest( |
332 new DocId("http://wronghost:1/")); | 336 new DocId("http://wronghost:1/")); |
333 GetContentsResponse response = new GetContentsResponse(baos); | 337 GetContentsResponse response = new GetContentsResponse(baos); |
334 adaptor.getDocContent(request, response); | 338 adaptor.getDocContent(request, response); |
335 assertTrue(response.isNotFound()); | 339 assertTrue(response.isNotFound()); |
336 } | 340 } |
337 | 341 |
338 @Test | 342 @Test |
339 public void testGetDocContentWrongPage() throws Exception { | 343 public void testGetDocContentWrongPage() throws Exception { |
340 final String wrongPage = "http://localhost:1/wrongPage"; | 344 final String wrongPage = "http://localhost:1/wrongPage"; |
341 SoapFactory siteDataFactory = MockSoapFactory.blank() | 345 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 346 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
342 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 347 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
343 .register(VS_CONTENT_EXCHANGE) | 348 .register(VS_CONTENT_EXCHANGE) |
344 .register(new SiteAndWebExchange( | 349 .register(new SiteAndWebExchange( |
345 wrongPage, 0, "http://localhost:1", "http://localhost:1")) | 350 wrongPage, 0, "http://localhost:1", "http://localhost:1")) |
346 .register(new URLSegmentsExchange( | 351 .register(new URLSegmentsExchange( |
347 wrongPage, false, null, null, null, null))); | 352 wrongPage, false, null, null, null, null))); |
348 | 353 |
349 adaptor = new SharePointAdaptor(siteDataFactory, | 354 adaptor = new SharePointAdaptor(siteDataFactory, |
350 new UnsupportedHttpClient(), executorFactory); | 355 new UnsupportedHttpClient(), executorFactory); |
351 adaptor.init(new MockAdaptorContext(config, pusher)); | 356 adaptor.init(new MockAdaptorContext(config, pusher)); |
352 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 357 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
353 GetContentsRequest request = new GetContentsRequest(new DocId(wrongPage)); | 358 GetContentsRequest request = new GetContentsRequest(new DocId(wrongPage)); |
354 GetContentsResponse response = new GetContentsResponse(baos); | 359 GetContentsResponse response = new GetContentsResponse(baos); |
355 adaptor.getDocContent(request, response); | 360 adaptor.getDocContent(request, response); |
356 assertTrue(response.isNotFound()); | 361 assertTrue(response.isNotFound()); |
357 } | 362 } |
358 | 363 |
359 @Test | 364 @Test |
360 public void testGetDocContentVirtualServer() throws Exception { | 365 public void testGetDocContentVirtualServer() throws Exception { |
361 SoapFactory siteDataFactory = MockSoapFactory.blank() | 366 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 367 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
362 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 368 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
363 .register(VS_CONTENT_EXCHANGE) | 369 .register(VS_CONTENT_EXCHANGE) |
364 .register(CD_CONTENT_EXCHANGE)); | 370 .register(CD_CONTENT_EXCHANGE)); |
365 | 371 |
366 adaptor = new SharePointAdaptor(siteDataFactory, | 372 adaptor = new SharePointAdaptor(siteDataFactory, |
367 new UnsupportedHttpClient(), executorFactory); | 373 new UnsupportedHttpClient(), executorFactory); |
368 adaptor.init(new MockAdaptorContext(config, pusher)); | 374 adaptor.init(new MockAdaptorContext(config, pusher)); |
369 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 375 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
370 GetContentsResponse response = new GetContentsResponse(baos); | 376 GetContentsResponse response = new GetContentsResponse(baos); |
371 adaptor.getDocContent(new GetContentsRequest(new DocId("")), response); | 377 adaptor.getDocContent(new GetContentsRequest(new DocId("")), response); |
(...skipping 15 matching lines...) Expand all Loading... |
387 .setEverythingCaseInsensitive() | 393 .setEverythingCaseInsensitive() |
388 .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES) | 394 .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES) |
389 .setPermitUsers(users(permit)).setPermitGroups(groups(permit)).build(), | 395 .setPermitUsers(users(permit)).setPermitGroups(groups(permit)).build(), |
390 response.getAcl()); | 396 response.getAcl()); |
391 assertNull(response.getDisplayUrl()); | 397 assertNull(response.getDisplayUrl()); |
392 } | 398 } |
393 | 399 |
394 @Test | 400 @Test |
395 public void testGetDocContentSiteCollection() throws Exception { | 401 public void testGetDocContentSiteCollection() throws Exception { |
396 SoapFactory siteDataFactory = MockSoapFactory.blank() | 402 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 403 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
397 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 404 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
398 .register(VS_CONTENT_EXCHANGE) | 405 .register(VS_CONTENT_EXCHANGE) |
399 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) | 406 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) |
400 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() | 407 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() |
401 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) | 408 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) |
402 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE) | 409 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE) |
403 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE)); | 410 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE)); |
404 | 411 |
405 adaptor = new SharePointAdaptor(siteDataFactory, | 412 adaptor = new SharePointAdaptor(siteDataFactory, |
406 new UnsupportedHttpClient(), executorFactory); | 413 new UnsupportedHttpClient(), executorFactory); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 "chinese1 Visitors")) | 447 "chinese1 Visitors")) |
441 .setPermitUsers(users("GDC-PSL\\spuser1")).build(), | 448 .setPermitUsers(users("GDC-PSL\\spuser1")).build(), |
442 response.getAcl()); | 449 response.getAcl()); |
443 assertEquals(URI.create("http://localhost:1/sites/SiteCollection"), | 450 assertEquals(URI.create("http://localhost:1/sites/SiteCollection"), |
444 response.getDisplayUrl()); | 451 response.getDisplayUrl()); |
445 } | 452 } |
446 | 453 |
447 @Test | 454 @Test |
448 public void testGetDocContentSiteCollectionWithAdGroup() throws Exception { | 455 public void testGetDocContentSiteCollectionWithAdGroup() throws Exception { |
449 SoapFactory siteDataFactory = MockSoapFactory.blank() | 456 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 457 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
450 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 458 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
451 .register(VS_CONTENT_EXCHANGE) | 459 .register(VS_CONTENT_EXCHANGE) |
452 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) | 460 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) |
453 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() | 461 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() |
454 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) | 462 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) |
455 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE | 463 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE |
456 .replaceInContent("Name=\"spuser1\"", "Name=\"GDC-PSL\\group\"") | 464 .replaceInContent("Name=\"spuser1\"", "Name=\"GDC-PSL\\group\"") |
457 .replaceInContent("IsDomainGroup=\"False\"", | 465 .replaceInContent("IsDomainGroup=\"False\"", |
458 "IsDomainGroup=\"True\"")) | 466 "IsDomainGroup=\"True\"")) |
459 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE | 467 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE |
(...skipping 18 matching lines...) Expand all Loading... |
478 response.getAcl()); | 486 response.getAcl()); |
479 } | 487 } |
480 | 488 |
481 @Test | 489 @Test |
482 public void testGetDocContentSiteCollectionWithClaims() throws Exception { | 490 public void testGetDocContentSiteCollectionWithClaims() throws Exception { |
483 String permissions = "<permission memberid='11' mask='756052856929' />" | 491 String permissions = "<permission memberid='11' mask='756052856929' />" |
484 + "<permission memberid='12' mask='756052856929' />" | 492 + "<permission memberid='12' mask='756052856929' />" |
485 + "<permission memberid='13' mask='756052856929' />" | 493 + "<permission memberid='13' mask='756052856929' />" |
486 + "<permission memberid='14' mask='756052856929' /></permissions>"; | 494 + "<permission memberid='14' mask='756052856929' /></permissions>"; |
487 SoapFactory siteDataFactory = MockSoapFactory.blank() | 495 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 496 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
488 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 497 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
489 .register(VS_CONTENT_EXCHANGE) | 498 .register(VS_CONTENT_EXCHANGE) |
490 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) | 499 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) |
491 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() | 500 .endpoint(SITES_SITECOLLECTION_ENDPOINT, MockSiteData.blank() |
492 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) | 501 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) |
493 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE | 502 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE |
494 .replaceInContent("</permissions>", permissions)) | 503 .replaceInContent("</permissions>", permissions)) |
495 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE | 504 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE |
496 .replaceInContent("</permissions>", permissions))); | 505 .replaceInContent("</permissions>", permissions))); |
497 | 506 |
(...skipping 15 matching lines...) Expand all Loading... |
513 "chinese1 Visitors", "GSA-CONNECTORS\\domain users", | 522 "chinese1 Visitors", "GSA-CONNECTORS\\domain users", |
514 "Everyone", "NT AUTHORITY\\authenticated users")).build(), | 523 "Everyone", "NT AUTHORITY\\authenticated users")).build(), |
515 response.getAcl()); | 524 response.getAcl()); |
516 } | 525 } |
517 | 526 |
518 @Test | 527 @Test |
519 public void testGetDocContentSiteCollectionWithOutOfDateMemberCache() | 528 public void testGetDocContentSiteCollectionWithOutOfDateMemberCache() |
520 throws Exception { | 529 throws Exception { |
521 ReferenceSiteData siteData = new ReferenceSiteData(); | 530 ReferenceSiteData siteData = new ReferenceSiteData(); |
522 SoapFactory siteDataFactory = MockSoapFactory.blank() | 531 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 532 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
523 .endpoint(VS_ENDPOINT, MockSiteData.blank() | 533 .endpoint(VS_ENDPOINT, MockSiteData.blank() |
524 .register(VS_CONTENT_EXCHANGE) | 534 .register(VS_CONTENT_EXCHANGE) |
525 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) | 535 .register(SITES_SITECOLLECTION_SAW_EXCHANGE)) |
526 .endpoint(SITES_SITECOLLECTION_ENDPOINT, siteData); | 536 .endpoint(SITES_SITECOLLECTION_ENDPOINT, siteData); |
527 SiteDataSoap siteDataState1 = MockSiteData.blank() | 537 SiteDataSoap siteDataState1 = MockSiteData.blank() |
528 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) | 538 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) |
529 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE) | 539 .register(SITES_SITECOLLECTION_S_CONTENT_EXCHANGE) |
530 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE); | 540 .register(SITES_SITECOLLECTION_SC_CONTENT_EXCHANGE); |
531 SiteDataSoap siteDataState2 = MockSiteData.blank() | 541 SiteDataSoap siteDataState2 = MockSiteData.blank() |
532 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) | 542 .register(SITES_SITECOLLECTION_URLSEG_EXCHANGE) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 .register(SITES_SITECOLLECTION_LISTS_CUSTOMLIST_2_LI_CONTENT_EXCHANGE); | 689 .register(SITES_SITECOLLECTION_LISTS_CUSTOMLIST_2_LI_CONTENT_EXCHANGE); |
680 final String site = "http://localhost:1/sites/SiteCollection"; | 690 final String site = "http://localhost:1/sites/SiteCollection"; |
681 final String attachmentId = site + "/Lists/Custom List/Attachments/2/104600" | 691 final String attachmentId = site + "/Lists/Custom List/Attachments/2/104600" |
682 + "0.pdf"; | 692 + "0.pdf"; |
683 | 693 |
684 final String goldenContents = "attachment contents"; | 694 final String goldenContents = "attachment contents"; |
685 final String goldenContentType = "fake/type"; | 695 final String goldenContentType = "fake/type"; |
686 adaptor = new SharePointAdaptor(initableSoapFactory, | 696 adaptor = new SharePointAdaptor(initableSoapFactory, |
687 new HttpClient() { | 697 new HttpClient() { |
688 @Override | 698 @Override |
689 public FileInfo issueGetRequest(URL url) { | 699 public FileInfo issueGetRequest(URL url, |
| 700 List<String> authenticationCookies) { |
690 assertEquals( | 701 assertEquals( |
691 "http://localhost:1/sites/SiteCollection/Lists/Custom%20List/" | 702 "http://localhost:1/sites/SiteCollection/Lists/Custom%20List/" |
692 + "Attachments/2/1046000.pdf", | 703 + "Attachments/2/1046000.pdf", |
693 url.toString()); | 704 url.toString()); |
694 InputStream contents = new ByteArrayInputStream( | 705 InputStream contents = new ByteArrayInputStream( |
695 goldenContents.getBytes(charset)); | 706 goldenContents.getBytes(charset)); |
696 List<String> headers = Arrays.asList("not-the-Content-Type", "early", | 707 List<String> headers = Arrays.asList("not-the-Content-Type", "early", |
697 "conTent-TypE", goldenContentType, "Content-Type", "late"); | 708 "conTent-TypE", goldenContentType, "Content-Type", "late"); |
698 return new FileInfo.Builder(contents).setHeaders(headers).build(); | 709 return new FileInfo.Builder(contents).setHeaders(headers).build(); |
699 } | 710 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 public void getChanges(ObjectType objectType, | 1200 public void getChanges(ObjectType objectType, |
1190 String contentDatabaseId, Holder<String> lastChangeId, | 1201 String contentDatabaseId, Holder<String> lastChangeId, |
1191 Holder<String> currentChangeId, Integer timeout, | 1202 Holder<String> currentChangeId, Integer timeout, |
1192 Holder<String> getChangesResult, Holder<Boolean> moreChanges) { | 1203 Holder<String> getChangesResult, Holder<Boolean> moreChanges) { |
1193 atomicNumberGetChangesCalls.getAndIncrement(); | 1204 atomicNumberGetChangesCalls.getAndIncrement(); |
1194 super.getChanges(objectType, contentDatabaseId, lastChangeId, | 1205 super.getChanges(objectType, contentDatabaseId, lastChangeId, |
1195 currentChangeId, timeout, getChangesResult, moreChanges); | 1206 currentChangeId, timeout, getChangesResult, moreChanges); |
1196 } | 1207 } |
1197 }; | 1208 }; |
1198 SoapFactory siteDataFactory = MockSoapFactory.blank() | 1209 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 1210 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
1199 .endpoint(VS_ENDPOINT, countingSiteData); | 1211 .endpoint(VS_ENDPOINT, countingSiteData); |
1200 adaptor = new SharePointAdaptor(siteDataFactory, | 1212 adaptor = new SharePointAdaptor(siteDataFactory, |
1201 new UnsupportedHttpClient(), executorFactory); | 1213 new UnsupportedHttpClient(), executorFactory); |
1202 AccumulatingDocIdPusher pusher = new AccumulatingDocIdPusher(); | 1214 AccumulatingDocIdPusher pusher = new AccumulatingDocIdPusher(); |
1203 siteData.setSiteDataSoap(state0); | 1215 siteData.setSiteDataSoap(state0); |
1204 adaptor.init(new MockAdaptorContext(config, pusher)); | 1216 adaptor.init(new MockAdaptorContext(config, pusher)); |
1205 | 1217 |
1206 // Error getting content databases, so content databases remains unchanged | 1218 // Error getting content databases, so content databases remains unchanged |
1207 // (empty). | 1219 // (empty). |
1208 siteData.setSiteDataSoap(state1); | 1220 siteData.setSiteDataSoap(state1); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 public void getChanges(ObjectType objectType, | 1289 public void getChanges(ObjectType objectType, |
1278 String contentDatabaseId, Holder<String> lastChangeId, | 1290 String contentDatabaseId, Holder<String> lastChangeId, |
1279 Holder<String> currentChangeId, Integer timeout, | 1291 Holder<String> currentChangeId, Integer timeout, |
1280 Holder<String> getChangesResult, Holder<Boolean> moreChanges) { | 1292 Holder<String> getChangesResult, Holder<Boolean> moreChanges) { |
1281 atomicNumberGetChangesCalls.getAndIncrement(); | 1293 atomicNumberGetChangesCalls.getAndIncrement(); |
1282 super.getChanges(objectType, contentDatabaseId, lastChangeId, | 1294 super.getChanges(objectType, contentDatabaseId, lastChangeId, |
1283 currentChangeId, timeout, getChangesResult, moreChanges); | 1295 currentChangeId, timeout, getChangesResult, moreChanges); |
1284 } | 1296 } |
1285 }; | 1297 }; |
1286 SoapFactory siteDataFactory = MockSoapFactory.blank() | 1298 SoapFactory siteDataFactory = MockSoapFactory.blank() |
| 1299 .endpoint(AUTH_ENDPOINT, new MockAuthenticationSoap()) |
1287 .endpoint(VS_ENDPOINT, countingSiteData); | 1300 .endpoint(VS_ENDPOINT, countingSiteData); |
1288 adaptor = new SharePointAdaptor(siteDataFactory, | 1301 adaptor = new SharePointAdaptor(siteDataFactory, |
1289 new UnsupportedHttpClient(), executorFactory); | 1302 new UnsupportedHttpClient(), executorFactory); |
1290 AccumulatingDocIdPusher pusher = new AccumulatingDocIdPusher(); | 1303 AccumulatingDocIdPusher pusher = new AccumulatingDocIdPusher(); |
1291 adaptor.init(new MockAdaptorContext(config, pusher)); | 1304 adaptor.init(new MockAdaptorContext(config, pusher)); |
1292 | 1305 |
1293 // Initialize changeIds. | 1306 // Initialize changeIds. |
1294 adaptor.getModifiedDocIds(pusher); | 1307 adaptor.getModifiedDocIds(pusher); |
1295 assertEquals(0, atomicNumberGetChangesCalls.get()); | 1308 assertEquals(0, atomicNumberGetChangesCalls.get()); |
1296 | 1309 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 } | 1428 } |
1416 | 1429 |
1417 private static String loadResourceAsString(String resource) | 1430 private static String loadResourceAsString(String resource) |
1418 throws IOException { | 1431 throws IOException { |
1419 return IOHelper.readInputStreamToString(SharePointAdaptorTest.class | 1432 return IOHelper.readInputStreamToString(SharePointAdaptorTest.class |
1420 .getResourceAsStream(resource), Charset.forName("UTF-8")); | 1433 .getResourceAsStream(resource), Charset.forName("UTF-8")); |
1421 } | 1434 } |
1422 | 1435 |
1423 private static class UnsupportedHttpClient implements HttpClient { | 1436 private static class UnsupportedHttpClient implements HttpClient { |
1424 @Override | 1437 @Override |
1425 public FileInfo issueGetRequest(URL url) { | 1438 public FileInfo issueGetRequest(URL url, |
| 1439 List<String> authenticationCookies) { |
1426 throw new UnsupportedOperationException(); | 1440 throw new UnsupportedOperationException(); |
1427 } | 1441 } |
1428 } | 1442 } |
1429 | 1443 |
1430 private static class MockUserGroupSoap extends UnsupportedUserGroupSoap { | 1444 private static class MockUserGroupSoap extends UnsupportedUserGroupSoap { |
1431 final Users users;···· | 1445 final Users users;···· |
1432 public MockUserGroupSoap(Users users) { | 1446 public MockUserGroupSoap(Users users) { |
1433 this.users = users;······ | 1447 this.users = users;······ |
1434 } | 1448 } |
1435 ···· | 1449 ···· |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 return delegate().getRolesAndPermissionsForCurrentUser(); | 1735 return delegate().getRolesAndPermissionsForCurrentUser(); |
1722 } | 1736 } |
1723 | 1737 |
1724 @Override | 1738 @Override |
1725 public GetRolesAndPermissionsForSiteResponse | 1739 public GetRolesAndPermissionsForSiteResponse |
1726 .GetRolesAndPermissionsForSiteResult getRolesAndPermissionsForSite() { | 1740 .GetRolesAndPermissionsForSiteResult getRolesAndPermissionsForSite() { |
1727 return delegate().getRolesAndPermissionsForSite(); | 1741 return delegate().getRolesAndPermissionsForSite(); |
1728 } | 1742 } |
1729 } | 1743 } |
1730 ·· | 1744 ·· |
1731 private static class MockAuthenticationSoap implements AuthenticationSoap { | 1745 private static class MockAuthenticationSoap extends· |
| 1746 UnsupportedAuthenticationSoap { |
1732 @Override | 1747 @Override |
1733 public LoginResult login(String string, String string1) { | 1748 public LoginResult login(String string, String string1) { |
1734 throw new UnsupportedOperationException(); | 1749 throw new UnsupportedOperationException(); |
1735 } | 1750 } |
1736 | 1751 |
1737 @Override | 1752 @Override |
1738 public AuthenticationMode mode() { | 1753 public AuthenticationMode mode() { |
1739 return AuthenticationMode.WINDOWS; | 1754 return AuthenticationMode.WINDOWS; |
1740 } | 1755 } |
| 1756 } |
| 1757 ·· |
| 1758 private static class UnsupportedAuthenticationSoap· |
| 1759 extends DelegatingAuthenticationSoap { |
| 1760 private final String endpoint; |
| 1761 |
| 1762 public UnsupportedAuthenticationSoap() { |
| 1763 this(null); |
| 1764 } |
| 1765 |
| 1766 public UnsupportedAuthenticationSoap(String endpoint) { |
| 1767 this.endpoint = endpoint; |
| 1768 } |
| 1769 |
| 1770 @Override |
| 1771 protected AuthenticationSoap delegate() { |
| 1772 if (endpoint == null) { |
| 1773 throw new UnsupportedOperationException(); |
| 1774 } else { |
| 1775 throw new UnsupportedOperationException("Endpoint: " + endpoint); |
| 1776 } |
| 1777 } |
| 1778 } |
| 1779 |
| 1780 |
| 1781 private abstract static class DelegatingAuthenticationSoap· |
| 1782 implements AuthenticationSoap { |
| 1783 protected abstract AuthenticationSoap delegate(); |
| 1784 |
| 1785 @Override |
| 1786 public LoginResult login(String username, String password) { |
| 1787 return delegate().login(username, password); |
| 1788 } |
| 1789 |
| 1790 @Override |
| 1791 public AuthenticationMode mode() { |
| 1792 return delegate().mode(); |
| 1793 }···· |
1741 } | 1794 } |
1742 | 1795 |
1743 /** | 1796 /** |
1744 * Throw UnsupportedOperationException for all calls. | 1797 * Throw UnsupportedOperationException for all calls. |
1745 */ | 1798 */ |
1746 private static class UnsupportedSiteData extends DelegatingSiteData { | 1799 private static class UnsupportedSiteData extends DelegatingSiteData { |
1747 @Override | 1800 @Override |
1748 protected SiteDataSoap delegate() { | 1801 protected SiteDataSoap delegate() { |
1749 throw new UnsupportedOperationException(); | 1802 throw new UnsupportedOperationException(); |
1750 } | 1803 } |
1751 } | 1804 } |
1752 | 1805 |
1753 private static class UnsupportedCallable<V> implements Callable<V> { | 1806 private static class UnsupportedCallable<V> implements Callable<V> { |
1754 @Override | 1807 @Override |
1755 public V call() { | 1808 public V call() { |
1756 throw new UnsupportedOperationException(); | 1809 throw new UnsupportedOperationException(); |
1757 } | 1810 } |
1758 } | 1811 } |
1759 | 1812 |
1760 private static class MockSoapFactory implements SoapFactory { | 1813 private static class MockSoapFactory implements SoapFactory { |
1761 private final String expectedEndpoint; | 1814 private final String expectedEndpoint; |
1762 private final SiteDataSoap siteData; | 1815 private final SiteDataSoap siteData; |
1763 private final UserGroupSoap userGroup; | 1816 private final UserGroupSoap userGroup; |
1764 private final AuthenticationSoap authentication; | 1817 private final AuthenticationSoap authentication; |
1765 private final MockSoapFactory chain; | 1818 private final MockSoapFactory chain; |
1766 | 1819 |
1767 private MockSoapFactory(String expectedEndpoint, SiteDataSoap siteData, | 1820 private MockSoapFactory(String expectedEndpoint, SiteDataSoap siteData, |
1768 UserGroupSoap userGroup, MockSoapFactory chain) { | 1821 UserGroupSoap userGroup, AuthenticationSoap authentication, |
| 1822 MockSoapFactory chain) { |
1769 this.expectedEndpoint = expectedEndpoint; | 1823 this.expectedEndpoint = expectedEndpoint; |
1770 this.siteData = siteData; | 1824 this.siteData = siteData; |
1771 this.userGroup = userGroup; | 1825 this.userGroup = userGroup; |
1772 // Tests will always use windows authentication. | 1826 // Tests will always use windows authentication. |
1773 this.authentication = new MockAuthenticationSoap(); | 1827 this.authentication = authentication; |
1774 this.chain = chain; | 1828 this.chain = chain; |
1775 } | 1829 } |
1776 | 1830 |
1777 public static MockSoapFactory blank() { | 1831 public static MockSoapFactory blank() { |
1778 return new MockSoapFactory(null, null, null, null); | 1832 return new MockSoapFactory(null, null, null, null, null); |
1779 } | 1833 } |
1780 | 1834 |
1781 public MockSoapFactory endpoint(String expectedEndpoint, | 1835 public MockSoapFactory endpoint(String expectedEndpoint, |
1782 SiteDataSoap siteData) { | 1836 SiteDataSoap siteData) { |
1783 return new MockSoapFactory(expectedEndpoint, siteData, null, this); | 1837 return new MockSoapFactory(expectedEndpoint, siteData, null, null, this); |
1784 } | 1838 } |
1785 | 1839 |
1786 public MockSoapFactory endpoint(String expectedEndpoint, | 1840 public MockSoapFactory endpoint(String expectedEndpoint, |
1787 UserGroupSoap userGroup) { | 1841 UserGroupSoap userGroup) { |
1788 return new MockSoapFactory(expectedEndpoint, null, userGroup, this); | 1842 return new MockSoapFactory(expectedEndpoint, null, userGroup, null, this); |
| 1843 } |
| 1844 ···· |
| 1845 public MockSoapFactory endpoint(String expectedEndpoint, |
| 1846 AuthenticationSoap authentication) { |
| 1847 return new MockSoapFactory( |
| 1848 expectedEndpoint, null, null, authentication, this); |
1789 } | 1849 } |
1790 | 1850 |
1791 @Override | 1851 @Override |
1792 public SiteDataSoap newSiteData(String endpoint) { | 1852 public SiteDataSoap newSiteData(String endpoint) { |
1793 if (chain == null) { | 1853 if (chain == null) { |
1794 fail("Could not find endpoint " + endpoint); | 1854 fail("Could not find endpoint " + endpoint); |
1795 } | 1855 } |
1796 if (expectedEndpoint.equals(endpoint) && siteData != null) { | 1856 if (expectedEndpoint.equals(endpoint) && siteData != null) { |
1797 return siteData; | 1857 return siteData; |
1798 } | 1858 } |
1799 return chain.newSiteData(endpoint); | 1859 return chain.newSiteData(endpoint); |
1800 } | 1860 } |
1801 ···· | 1861 ···· |
1802 @Override· | 1862 @Override· |
1803 public AuthenticationSoap newAuthentication (String endpoint) { | 1863 public AuthenticationSoap newAuthentication(String endpoint) { |
1804 return authentication;······ | 1864 if (chain == null) { |
| 1865 fail("Could not find endpoint " + endpoint); |
| 1866 } |
| 1867 if (expectedEndpoint.equals(endpoint) && authentication != null) { |
| 1868 return authentication; |
| 1869 } |
| 1870 return chain.newAuthentication(endpoint); |
1805 } | 1871 } |
1806 | 1872 |
1807 @Override | 1873 @Override |
1808 public UserGroupSoap newUserGroup(String endpoint) { | 1874 public UserGroupSoap newUserGroup(String endpoint) { |
1809 if (chain == null) { | 1875 if (chain == null) { |
1810 // UserGroupSoaps are commonly created but rarely used, so we go ahead | 1876 // UserGroupSoaps are commonly created but rarely used, so we go ahead |
1811 // and just provide an instance instead of forcing all users of the mock | 1877 // and just provide an instance instead of forcing all users of the mock |
1812 // to populate trash instances. | 1878 // to populate trash instances. |
1813 return new UnsupportedUserGroupSoap(endpoint); | 1879 return new UnsupportedUserGroupSoap(endpoint); |
1814 } | 1880 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 | 2120 |
2055 public SiteAndWebExchange(String strUrl, long getSiteAndWebResult, | 2121 public SiteAndWebExchange(String strUrl, long getSiteAndWebResult, |
2056 String strSite, String strWeb) { | 2122 String strSite, String strWeb) { |
2057 this.strUrl = strUrl; | 2123 this.strUrl = strUrl; |
2058 this.getSiteAndWebResult = getSiteAndWebResult; | 2124 this.getSiteAndWebResult = getSiteAndWebResult; |
2059 this.strSite = strSite; | 2125 this.strSite = strSite; |
2060 this.strWeb = strWeb; | 2126 this.strWeb = strWeb; |
2061 } | 2127 } |
2062 } | 2128 } |
2063 } | 2129 } |
LEFT | RIGHT |