public ExternalSessionFactory(String host, Port port, Monitor monitor, String shabang) { this(new InetSocketAddress(host, port.getValue()), monitor, shabang); }
@Test public void toIntShouldReturnedDesiredPort() { int expectedPort = 452; assertThat(new FixedPortSupplier(expectedPort).get().getValue()).isEqualTo(expectedPort); }
@Test public void toIntShouldReturnedDesiredPort() { int expectedPort = 452; assertThat(new FixedPortSupplier(expectedPort).get().getValue()).isEqualTo(expectedPort); }
@Before public void setUp() throws Exception { protocol = new DiscardProtocol(); protocol.start(); socket = SocketFactory.getDefault().createSocket("127.0.0.1", protocol.getPort().getValue()); record = protocol.recordNext(); }
@Override public void configure(HierarchicalConfiguration config) throws ConfigurationException { if (configuration.isEnabled()) { service.port(configuration.getPort().get().getValue()); configureExceptionHanding(); configureHTTPS(); configureCORS(); configureMetrics(); service.before((request, response) -> response.type(Constants.JSON_CONTENT_TYPE)); configureMDC(); routesList.forEach(routes -> { service.before(routes.getBasePath(), authenticationFilter); service.before(routes.getBasePath() + "/*", authenticationFilter); routes.define(service); }); publicRoutes.forEach(routes -> routes.define(service)); service.awaitInitialization(); port = new Port(service.port()); LOGGER.info("Web admin server started"); } }
public static RequestSpecBuilder buildRequestSpecification(Port port) { return new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(port.getValue()); } }
public static RequestSpecBuilder buildRequestSpecification(Port port) { return new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(port.getValue()); } }
@Test public void downloadingAMailShouldFailWhenUnknown() throws Exception { mailRepositoryStore.create(URL_MY_REPO); RestAssured.requestSpecification = new RequestSpecBuilder().setPort(webAdminServer.getPort().getValue()) .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES) .build(); RestAssured.registerParser(Constants.RFC822_CONTENT_TYPE, Parser.TEXT); String name = "name"; given() .accept(Constants.RFC822_CONTENT_TYPE) .when() .get(PATH_ESCAPED_MY_REPO + "/mails/" + name) .then() .statusCode(HttpStatus.NOT_FOUND_404) .body("statusCode", is(404)) .body("type", is(ErrorResponder.ErrorType.NOT_FOUND.getType())) .body("message", is("Could not retrieve " + name)); }
private static void configureRequestSpecification(GuiceJamesServer server) { WebAdminGuiceProbe webAdminGuiceProbe = server.getProbe(WebAdminGuiceProbe.class); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(webAdminGuiceProbe.getWebAdminPort().getValue()) .build(); }
@Test public void downloadingAMailShouldReturnTheEml() throws Exception { RestAssured.requestSpecification = new RequestSpecBuilder().setPort(webAdminServer.getPort().getValue()) .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES) .build(); RestAssured.registerParser(Constants.RFC822_CONTENT_TYPE, Parser.TEXT); MailRepository mailRepository = mailRepositoryStore.create(URL_MY_REPO); String name = NAME_1; FakeMail mail = FakeMail.builder() .name(name) .fileName("mail.eml") .build(); mailRepository.store(mail); String expectedContent = ClassLoaderUtils.getSystemResourceAsString("mail.eml", StandardCharsets.UTF_8); String actualContent = given() .accept(Constants.RFC822_CONTENT_TYPE) .when() .get(PATH_ESCAPED_MY_REPO + "/mails/" + name) .then() .statusCode(HttpStatus.OK_200) .header("Content-Length", "471") .contentType(Constants.RFC822_CONTENT_TYPE) .extract() .body() .asString(); assertThat(actualContent).isEqualToNormalizingNewlines(expectedContent); }