草庐IT

test_register_without_subscriptio

全部标签

java - com.w3c.dom.Document without <?xml version ="1.0"encoding ="UTF-8"standalone ="no"?>

我正在创建一个com.w3c.dom.Document来自String使用此代码:DocumentBuilderFactorydocFactory=DocumentBuilderFactory.newInstance();DocumentBuilderdocBuilder=docFactory.newDocumentBuilder();Documentdoc=docBuilder.parse(newInputSource(newStringReader("")));当我System.out.println(xmlToString(document)),我明白了:一切正常,但我不希望XM

java - JUnit + Derby + Spring : drop in-memory db after every test

在我的单元测试中,我Autowiring了一些使用URL的数据源jdbc:derby:memory:mydb;create=true创建内存数据库。要删除内存中的Derby数据库,您必须连接:jdbc:derby:memory:mydb;drop=true我希望在每次测试后都发生这种情况,并从一个新的数据库开始。我如何使用Spring执行此操作? 最佳答案 HowtoshutdownDerbyin-memorydatabaseProperly给了我一个解决方案的提示:mydb.drop.url=jdbc:derby:memory:m

java - 在 gradle 的 eclipse 构建中拆分 main 和 test

今天我尝试将一个带有集成测试的项目从maven切换到gradle。一切正常,除了我在testng上遇到严重问题。该项目使用hibernate/JPA2进行数据库访问,并有几个依赖于test/resources/META-INF/persistence.xml中的持久性单元的测试。当我使用gradle运行测试套件时,一切正常。但是当我从eclipse运行xml(或任何测试类本身)时,它似乎试图使用main/resources/META-INF/persistence.xml。因为我的大部分工作都使用TDD,所以我确实需要从eclipse运行/调试测试。当我将持久性单元添加到生产persi

Java servlet 和 IO : Create a file without saving to disk and sending it to the user

我希望可以帮助我解决文件创建/响应问题。我知道如何创建和保存文件。我知道如何通过ServletOutputStream将该文件发送回用户。但我需要的是创建一个文件,而不是将其保存在磁盘上,然后通过ServletOutputStream发送该文件。上面的代码解释了我拥有的部分。任何帮助表示赞赏。提前致谢。//ThisCreatesafile//Stringtext="Thesedaysrunawaylikehorsesoverthehill";Filefile=newFile("MyFile.txt");Writerwriter=newBufferedWriter(newFileWrit

java - 在 JUnit 4 的@Before 中获取当前正在执行的 @Test 方法

我想在@Before中获取当前正在执行的测试方法,以便我可以获得应用于当前正在执行的方法的注释。publicclassTestCaseExample{@BeforepublicvoidsetUp(){//getcurrentmethodhere.}@Test@MyAnnotation("id")publicvoidsomeTest{//code}} 最佳答案 尝试TestName规则publicclassTestCaseExample{@RulepublicTestNametestName=newTestName();@Before

java - 如何仅跳过针对 "compile"和 "install"目标而不是 "test"目标的测试?

我有这样一种情况,我们的单元测试需要很长时间才能为我们的业务域项目执行,因为它将数据库设置为已知状态,然后继续执行每个步骤。我知道这可以通过命令行上的“-Dmaven.test.skip=true”来完成,但希望仅在项目的NetBeans中配置它,如果有人可以阐明如何在IDE中进行配置,则全局是可以接受的。如何将maven2配置为仅在调用“测试”目标时执行测试?即使调用“测试”目标(fromthemavendocos),使用以下命令也会禁用测试。org.apache.maven.pluginsmaven-surefire-plugin2.6true 最佳答案

java - Play Framework : PersistenceException: The type is not a registered entity? (Ebean)

我正在学习适用于Java的PlayFramework2.0教程,但在尝试保存ebean模型(task.save())时遇到此错误。[PersistenceException:Thetype[classmodels.Task]isnotaregisteredentity?Ifyoudon'texplicitlylisttheentityclassestouseEbeanwillsearchforthemintheclasspath.IftheentityisinaJarchecktheebean.search.jarspropertyinebean.propertiesfileorche

java - 如何让 Jersey Test/Client 不填写默认的 Accept header ?

我正在尝试以特定方式处理没有Acceptheader的请求,但无论我做什么,Jersey似乎都一心想填写一个,所以它看起来总是请求有一个Acceptheader,即使它没有。importorg.glassfish.jersey.server.ResourceConfig;importorg.glassfish.jersey.test.JerseyTest;importorg.junit.Test;importjavax.ws.rs.GET;importjavax.ws.rs.Path;importjavax.ws.rs.core.Application;importjavax.ws.r

java.sql.SQLException : Io exception: Broken pipe how to recover without restart? 异常

在我的应用程序中,我使用到Oracle的连接,当连接丢失并尝试重新连接时,我收到异常:java.sql.SQLException:Ioexception:Brokenpipeatoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)atoracle.jdbc.driver.DatabaseError.throwSqlException(Data

java - 在类 Test 中实例化类 Test 的成员是递归吗?

这是递归吗?publicclassTest{Testtest=newTest();publicstaticvoidmain(String[]args){newTest();}}关于instanceinitalizer的版本呢??publicclassTest{{Testtest=newTest();}publicstaticvoidmain(String[]args){newTest();}}我在问,因为我更新了myoldanswer,它展示了如何在没有递归的情况下生成StackOverflowError,但现在我不能100%确定上面的代码是否是递归的。 最