use of com.facebook.buck.testutil.integration.HttpdForTests in project buck by facebook.
the class FetchCommandIntegrationTest method startHttpd.
@BeforeClass
public static void startHttpd() throws Exception {
httpd = new HttpdForTests();
httpd.addStaticContent("cheese");
httpd.start();
}
use of com.facebook.buck.testutil.integration.HttpdForTests in project buck by facebook.
the class DoctorCommandIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "report", tempFolder);
workspace.setUp();
objectMapper = ObjectMappers.newDefaultInstance();
rageResult = DefectSubmitResult.builder().setIsRequestSuccessful(true).setReportSubmitErrorMessage(Optional.empty()).setReportSubmitMessage("This is a json/string generated by the remote server.").setRequestProtocol(RageConfig.RageProtocolVersion.JSON).build();
doctorResponse = DoctorEndpointResponse.of(Optional.empty(), ImmutableList.of(DoctorSuggestion.of(DoctorSuggestion.StepStatus.ERROR, Optional.empty(), "Suggestion no1"), DoctorSuggestion.of(DoctorSuggestion.StepStatus.WARNING, Optional.of("Area"), "Suggestion no2")));
httpd = new HttpdForTests();
httpd.addHandler(createHttpdHandler("POST", "{\"buildId\":\"ac8bd626-6137-4747-84dd-5d4f215c876c\",\"logDirPath\":\"" + LOG_PATH + "\",\"machineReadableLog\""));
httpd.start();
}
use of com.facebook.buck.testutil.integration.HttpdForTests in project buck by facebook.
the class PublicAnnouncementManagerIntegrationTest method testAnnouncementsWork.
@Test
public void testAnnouncementsWork() throws Exception {
final AtomicReference<byte[]> requestBody = new AtomicReference<>();
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
httpServletResponse.setStatus(200);
request.setHandled(true);
if (request.getUri().getPath().equals("/status.php")) {
return;
}
requestBody.set(ByteStreams.toByteArray(httpServletRequest.getInputStream()));
FrontendRequest thriftRequest = new FrontendRequest();
ThriftUtil.deserialize(ThriftProtocol.BINARY, requestBody.get(), thriftRequest);
assertTrue("Request should contain the repository.", thriftRequest.getAnnouncementRequest().getRepository().equals(REPOSITORY));
try (DataOutputStream out = new DataOutputStream(httpServletResponse.getOutputStream())) {
Announcement announcement = new Announcement();
announcement.setErrorMessage(ERROR_MSG);
announcement.setSolutionMessage(SOLUTION_MSG);
AnnouncementResponse announcementResponse = new AnnouncementResponse();
announcementResponse.setAnnouncements(ImmutableList.of(announcement));
FrontendResponse frontendResponse = new FrontendResponse();
frontendResponse.setType(FrontendRequestType.ANNOUNCEMENT);
frontendResponse.setAnnouncementResponse(announcementResponse);
out.write(ThriftUtil.serialize(ThriftProtocol.BINARY, frontendResponse));
}
}
});
httpd.start();
Clock clock = new DefaultClock();
BuckEventBus eventBus = BuckEventBusFactory.newInstance(clock);
ExecutionEnvironment executionEnvironment = new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties());
BuckConfig buckConfig = new FakeBuckConfig.Builder().setSections(ImmutableMap.of("log", ImmutableMap.of("slb_server_pool", "http://localhost:" + httpd.getRootUri().getPort()))).build();
TestConsole console = new TestConsole();
SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(new SuperConsoleConfig(FakeBuckConfig.builder().build()), console, clock, /* verbosity */
TestResultSummaryVerbosity.of(false, false), executionEnvironment, Optional.empty(), Locale.US, logPath, TimeZone.getTimeZone("UTC"));
eventBus.register(listener);
PublicAnnouncementManager manager = new PublicAnnouncementManager(clock, eventBus, listener, REPOSITORY, new RemoteLogBuckConfig(buckConfig), MoreExecutors.newDirectExecutorService());
manager.getAndPostAnnouncements();
Optional<String> announcements = listener.getPublicAnnouncements();
assertEquals("The header and the message", announcements.get(), "**-------------------------------**\n" + "**- Sticky Public Announcements -**\n" + "**-------------------------------**\n" + "** This is the error message. This is the solution message.");
}
}
use of com.facebook.buck.testutil.integration.HttpdForTests in project buck by facebook.
the class ResolverIntegrationTest method setUpFakeMavenRepo.
@BeforeClass
public static void setUpFakeMavenRepo() throws Exception {
repo = TestDataHelper.getTestDataDirectory(ResolverIntegrationTest.class);
httpd = new HttpdForTests();
httpd.addHandler(new HttpdForTests.FileDispenserRequestHandler(repo));
httpd.start();
}
use of com.facebook.buck.testutil.integration.HttpdForTests in project buck by facebook.
the class TestPublisher method create.
/**
* @param pseudoLocalRepo typically {@link org.junit.rules.TemporaryFolder#newFolder}
*/
public static TestPublisher create(Path pseudoLocalRepo) throws Exception {
HttpdForTests.DummyPutRequestsHandler putRequestsHandler = new HttpdForTests.DummyPutRequestsHandler();
HttpdForTests httpd = new HttpdForTests();
httpd.addHandler(putRequestsHandler);
httpd.start();
return new TestPublisher(pseudoLocalRepo, httpd, putRequestsHandler);
}
Aggregations