Search in sources :

Example 26 with MockResponse

use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.

the class TestACLFeatures method testRemoveAclEntriesWithOnlyUsers.

@Test(expected = AccessControlException.class)
public void testRemoveAclEntriesWithOnlyUsers() throws URISyntaxException, IOException {
    getMockServer().enqueue(new MockResponse().setResponseCode(200));
    List<AclEntry> entries = new ArrayList<AclEntry>();
    AclEntry.Builder aclEntryBuilder = new AclEntry.Builder();
    aclEntryBuilder.setName("hadoop");
    aclEntryBuilder.setType(AclEntryType.USER);
    entries.add(aclEntryBuilder.build());
    getMockAdlFileSystem().removeAclEntries(new Path("/test1/test2"), entries);
    getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
    getMockAdlFileSystem().removeAclEntries(new Path("/test1/test2"), entries);
}
Also used : Path(org.apache.hadoop.fs.Path) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) ArrayList(java.util.ArrayList) AclEntry(org.apache.hadoop.fs.permission.AclEntry) Test(org.junit.Test)

Example 27 with MockResponse

use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.

the class TestACLFeatures method testRemoveDefaultAclEntries.

@Test(expected = AccessControlException.class)
public void testRemoveDefaultAclEntries() throws URISyntaxException, IOException {
    getMockServer().enqueue(new MockResponse().setResponseCode(200));
    getMockAdlFileSystem().removeDefaultAcl(new Path("/test1/test2"));
    getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
    getMockAdlFileSystem().removeDefaultAcl(new Path("/test1/test2"));
}
Also used : Path(org.apache.hadoop.fs.Path) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) Test(org.junit.Test)

Example 28 with MockResponse

use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.

the class TestACLFeatures method testSetPermission.

@Test(expected = AccessControlException.class)
public void testSetPermission() throws URISyntaxException, IOException {
    getMockServer().enqueue(new MockResponse().setResponseCode(200));
    getMockAdlFileSystem().setPermission(new Path("/test1/test2"), FsPermission.getDefault());
    getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
    getMockAdlFileSystem().setPermission(new Path("/test1/test2"), FsPermission.getDefault());
}
Also used : Path(org.apache.hadoop.fs.Path) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) Test(org.junit.Test)

Example 29 with MockResponse

use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.

the class TestACLFeatures method testAclStatusDenied.

@Test(expected = AccessControlException.class)
public void testAclStatusDenied() throws URISyntaxException, IOException {
    getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
    getMockAdlFileSystem().getAclStatus(new Path("/test1/test2"));
}
Also used : Path(org.apache.hadoop.fs.Path) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) Test(org.junit.Test)

Example 30 with MockResponse

use of com.squareup.okhttp.mockwebserver.MockResponse in project data-transfer-project by google.

the class MicrosoftCalendarExportTest method testExport.

@Test
public void testExport() throws Exception {
    server.enqueue(new MockResponse().setBody(CALENDARS_RESPONSE));
    server.enqueue(new MockResponse().setBody(CALENDAR1_EVENTS_RESPONSE));
    server.enqueue(new MockResponse().setBody(CALENDAR2_EVENTS_RESPONSE));
    server.start();
    HttpUrl baseUrl = server.url("");
    MicrosoftCalendarExporter exporter = new MicrosoftCalendarExporter(baseUrl.toString(), client, mapper, transformerService);
    ExportResult<CalendarContainerResource> resource = exporter.export(UUID.randomUUID(), token);
    CalendarContainerResource calendarResource = resource.getExportedData();
    Assert.assertEquals(2, calendarResource.getCalendars().size());
    Assert.assertFalse(calendarResource.getCalendars().stream().anyMatch(c -> "Calendar1".equals(c.getId()) && "Calendar2".equals(c.getId())));
    Assert.assertEquals(2, calendarResource.getEvents().size());
    Assert.assertFalse(calendarResource.getEvents().stream().anyMatch(e -> "Test Appointment 1".equals(e.getTitle()) && "Test Appointment 2".equals(e.getTitle())));
}
Also used : MicrosoftCalendarExporter(org.dataportabilityproject.transfer.microsoft.calendar.MicrosoftCalendarExporter) MockWebServer(com.squareup.okhttp.mockwebserver.MockWebServer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) ExportResult(org.dataportabilityproject.spi.transfer.provider.ExportResult) TokenAuthData(org.dataportabilityproject.types.transfer.auth.TokenAuthData) Test(org.junit.Test) UUID(java.util.UUID) MicrosoftCalendarExporter(org.dataportabilityproject.transfer.microsoft.calendar.MicrosoftCalendarExporter) HttpUrl(com.squareup.okhttp.HttpUrl) CalendarContainerResource(org.dataportabilityproject.types.transfer.models.calendar.CalendarContainerResource) TransformerServiceImpl(org.dataportabilityproject.transfer.microsoft.transformer.TransformerServiceImpl) OkHttpClient(okhttp3.OkHttpClient) After(org.junit.After) Assert(org.junit.Assert) Before(org.junit.Before) MockResponse(com.squareup.okhttp.mockwebserver.MockResponse) CalendarContainerResource(org.dataportabilityproject.types.transfer.models.calendar.CalendarContainerResource) HttpUrl(com.squareup.okhttp.HttpUrl) Test(org.junit.Test)

Aggregations

MockResponse (com.squareup.okhttp.mockwebserver.MockResponse)39 Test (org.junit.Test)34 Path (org.apache.hadoop.fs.Path)18 MockWebServer (com.squareup.okhttp.mockwebserver.MockWebServer)10 FileStatus (org.apache.hadoop.fs.FileStatus)6 AclEntry (org.apache.hadoop.fs.permission.AclEntry)5 RecordedRequest (com.squareup.okhttp.mockwebserver.RecordedRequest)4 AbstractMockServerTest (com.stanfy.enroscar.net.test.AbstractMockServerTest)4 ArrayList (java.util.ArrayList)4 Buffer (okio.Buffer)4 HttpUrl (com.squareup.okhttp.HttpUrl)3 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3 Request (com.squareup.okhttp.Request)2 Response (com.squareup.okhttp.Response)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 URI (java.net.URI)2