gpt4 book ai didi

windows - @Transactional 和 JerseyTest 在 Linux 或 Mac 上的问题,但在 Windows 上没有

转载 作者:可可西里 更新时间:2023-11-01 09:38:30 24 4
gpt4 key购买 nike

我们将 jersey test 与 grizzly2 结合使用,以针对模拟的 REST 资源运行验收测试。在我的 Windows 机器上一切正常。但是另一位使用他的 Mac 的开发人员遇到了与我们的 Jenkins(在 Linux 上)相同的错误:

INFO: Creating Grizzly2 Web Container configured at the base URI http://localhost:9998/
02.08.2012 09:46:36 org.glassfish.grizzly.http.server.HttpServer start
SEVERE: Failed to start listener [NetworkListener{name='grizzly', host='localhost', port=9998, secure=false}] : java.net.BindException: Address already in use

显然我们检查过情况并非如此:没有其他进程正在使用 9998..

我一直将问题追踪到单个测试,即结合使用 @Transactional 和扩展 JerseyTest:

@ContextConfiguration({ "classpath:context-test.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@TransactionConfiguration(defaultRollback = true)
public class TestPage extends JerseyTest {

public TestPage() throws Exception {
super("", "", "path.to.package");
}

// init database to be rolled back after test
// ...

// test that calls a controller requiring database access and then sends a request to a mock REST resource.
// ...
}

所以,这里的问题是:为什么不在 Windows 上?使用@Transactional 有什么问题。

编辑2似乎@Transactional 正在创建一个代理,这可能是个问题..?! See here

最佳答案

我遇到了类似的问题,请确保您没有在 TestPage 测试中覆盖 tearDown() 方法。如果您有要拆除的东西,请使用另一种方法 customTearDown() 并使用 @After 对其进行注释。

JerseyTest 也使用相同的方法名称 tearDown(),如果我们覆盖它,容器永远不会关闭。

关于windows - @Transactional 和 JerseyTest 在 Linux 或 Mac 上的问题,但在 Windows 上没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11772693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com