小编Sel*_*wyn的帖子

如何使用browsermob-proxy和selenium捕获http POST请求

您好,尝试使用browsermob proxy + selenium测试框架捕获HTTP POST请求中的实际POST数据.所以基本上我正在运行使用selenium的自动化测试,我想在测试期间捕获键/值对和HTTP POST请求的实际POST数据.使用以下逻辑,我只能捕获POST标头的键/值对,但不能捕获实际的POST数据(也就是表单字段id值).有没有办法实际捕获POSTDATA(如嗅探应用程序,如在Firefox中篡改/实时标题)?

ProxyServer proxyServer = null;
proxyServer = new ProxyServer(9101);
proxyServer.start();

proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);

Proxy proxy = proxyServer.seleniumProxy();
proxy.setHttpProxy("localhost:9101");

//selenium test config code, omitted for brevity

proxyServer.addRequestInterceptor(new HttpRequestInterceptor() {
public void process(HttpRequest request, HttpContext context) throws  HttpException,  IOException {
   Header[] headers = request.getAllHeaders();
   System.out.println("\nRequest Headers\n\n");
       for(Header h : headers) {
           System.out.println("Key: " + h.getName() + " | Value: " + h.getValue());
       }

   }
});
Run Code Online (Sandbox Code Playgroud)

我读到但无法开始工作的另一种方法是将browsermob代理服务器中的以下标志配置为true:

proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);
Run Code Online (Sandbox Code Playgroud)

然后输出实际的HAR文件:

Har har = proxyServer.getHar();
Date date = new Date(); …
Run Code Online (Sandbox Code Playgroud)

proxy post selenium

6
推荐指数
1
解决办法
8298
查看次数

我们如何使用@RabbitListener来处理消息之前/之后

问题:我正在从MessageListener接口impl迁移到@RabbitListener。我有这样的逻辑,我在被多个类继承的MessageListener上进行“前置”和“后置”消息处理

例:

public AbstractMessageListener implements MessageListener {

     @Override
     public void onMessage(Message message) {

          //do some pre message processing

          process(Message message);

          // do some post message processing
     }

     protected abstract void process(Message message);

}
Run Code Online (Sandbox Code Playgroud)

问题:有没有一种方法可以使用@RabbitListener批注实现类似的功能,在其中我可以继承前/后消息处理逻辑,而不必在每个子@RabbitListener批注内重新实现或调用前/后消息处理,并且始终保持子@RabbitListener的可自定义方法签名?还是这太贪心?

预期结果示例:

public class SomeRabbitListenerClass {

    @RabbitListener( id = "listener.mypojo",queues = "${rabbitmq.some.queue}")
   public void listen(@Valid MyPojo myPojo) {
      //...
   }
}

public class SomeOtherRabbitListenerClass {

    @RabbitListener(id = "listener.orders",queues ="${rabbitmq.some.other.queue}")
   public void listen(Order order, @Header("order_type") String orderType) {
      //...
   }
}
Run Code Online (Sandbox Code Playgroud)

这两个@RabbitListener都使用相同的继承的前后消息处理

我看到@RabbitListener批注中有一个'containerFactory'参数,但是我已经在配置中声明了一个...我真的确定如何通过自定义containerFactory实现我想要的继承。


更新答案:这就是我最终要做的。

建议定义: …

spring-rabbit spring-amqp

6
推荐指数
1
解决办法
4245
查看次数

尝试从<rabbit:> xml名称空间配置迁移到java @Configurable无法复制

我正在尝试从XML Spring amqp配置迁移到基于java的注释,因为它"更简单".不确定我做错了什么XML配置工作正常但java @Configurable抛出"引起:java.net.SocketException:连接重置"异常.

XML配置(完美运行):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:rabbit="http://www.springframework.org/schema/rabbit"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/rabbit
           http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context.xsd
           http://www.springframework.org/schema/util
           http://www.springframework.org/schema/util/spring-util.xsd
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- define which properties files will be used -->
    <context:property-placeholder location="classpath:*.properties" />

    <rabbit:connection-factory id="connectionFactory"
                               addresses='${rabbitmq.hostname}'
                               username='${rabbitmq.username}'
                               password='${rabbitmq.password}' 
                               virtual-host='${rabbitmq.virtual_host}'  
                               cache-mode='${rabbitmq.cache_mode}'                             
                               channel-cache-size='${rabbitmq.channel_cache_size}'/>

    <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
        <property name="corePoolSize" value="3"/>
        <property name="maxPoolSize" value="5"/>
        <property name="queueCapacity" value="15"/>                          
    </bean>                              


    <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
    <rabbit:admin connection-factory="connectionFactory"/>
       <rabbit:queue name="${rabbitmq.queue_name}" />
<rabbit:topic-exchange name="${rabbitmq.topic_exchange_name}">
    <rabbit:bindings>
        <rabbit:binding queue="${rabbitmq.queue_name}" pattern="${rabbitmq.topic_exchange_pattern}"/>
    </rabbit:bindings>
</rabbit:topic-exchange>

    <bean id="listener" class="com.my.package.path.worker.DefaultMessageListener"/>


    <rabbit:listener-container id="listenerContainer" connection-factory="connectionFactory" task-executor="taskExecutor"> …
Run Code Online (Sandbox Code Playgroud)

spring-rabbit spring-amqp spring-rabbitmq

5
推荐指数
1
解决办法
2723
查看次数

如何为@RabbitListener注释编写集成测试?

我的问题实际上是一个后续问题

RabbitMQ集成测试和线程

在那里它声明包装"你的监听器"并传入CountDownLatch并最终所有线程将合并.如果我们手动创建和注入消息监听器但是对于@RabbitListener注释,这个答案是有效的...我不知道如何传入CountDownLatch.该框架在幕后自动神奇地创建了消息监听器.

还有其他方法吗?

spring-rabbit spring-amqp

5
推荐指数
2
解决办法
2748
查看次数

如何在没有 Redis 且没有自动配置的情况下使用 spring-boot 配置 spring-session 以使用另一个数据库存储

我想在没有 Redis 的情况下使用 spring-boot + spring-session 但使用 dynamodb 作为 sessionRepository 实现。

所有可用的示例都与 Redis 或 Hazelcast 紧密耦合,并且主要是自动配置,抽象出正在初始化的 bean。此外,我的 spring boot 配置明确定义了一个

@Bean
    public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory(Environment env) {

        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();

return factory;
}
Run Code Online (Sandbox Code Playgroud)

我还禁用了SessionAutoConfiguration.classspring-session的 spring-boot 自动配置。

所以我有几个问题。

1. 如何配置具有明确定义的 TomcatEmbeddedServletContainerFactory bean 的 spring-boot 项目以使用 spring-session?

2. 我注意到 spring-session 与 Redis 和 Hazelcast 紧密结合(仅此而已)。对于会话存储库 impl 使用像 amazon dynamodb 这样的商店是否有任何反对意见?

我在看https://github.com/spring-projects/spring-session/blob/master/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration。爪哇

让我了解如何配置我想要实现的目标,但我一直遇到初始化异常。如果有人能指出正确的方向,我将不胜感激。

使用 spring-session 版本:1.1.0.M1

configuration spring-session

4
推荐指数
1
解决办法
8232
查看次数

设置属性logging.pattern.console或logging.pattern.level时忽略覆盖模式

使用 spring-boot 1.3.2

我试图覆盖 application.properties 文件中的 logback 模式,但无论我放入什么模式,总是会调用 spring-boot jar xml 中的默认模式。我可以成功地从INFO -> DEBUG调整logging.level值,并且可以观察输出中的变化,但logging.pattern.[console | level] 始终被忽略。

logging.level.org.springframework=INFO
logging.pattern.console=user:%X{username} %X{ipAddress} %5p
#logging.pattern.console=%5p    #Also ignored 
#logging.pattern.level=%5p      #Also ignored 
Run Code Online (Sandbox Code Playgroud)

是的,我正在尝试使用 MDC 值,但即使我不使用 MDC 值,覆盖仍然会被忽略。

关于如何进一步排除故障有什么想法吗?

这是我的类路径层次结构,其中包含名称中包含字符串“log”的任何依赖项。

这是我的类路径层次结构,其中包含名称中包含字符串“log”的任何依赖项。

spring-boot

0
推荐指数
1
解决办法
4024
查看次数