草庐IT

test_collection

全部标签

java - Collections.sort 没有对任何东西进行排序

我正在尝试以一种简短的方式对字符串数组进行排序。我正在尝试使用Collections.sort,但我不明白为什么它不对任何内容进行排序。代码:publicstaticString[]FishNamesSorted;.....Listnameslist=newArrayList();nameslist.toArray(FishNamesSorted);Collections.sort(nameslist,String.CASE_INSENSITIVE_ORDER);(){两种情况下的结果:紫罗兰网纹紫罗兰长尾紫罗兰假单胞菌科....为什么? 最佳答案

java - Gradle,错误找不到或加载主类 'test.Main'

我在one上实现了Gradle我的项目。我将Netbeans8.02与gradle插件一起使用。结构应该是这样的,源码在jgli/src/main/java/下,资源在jgli/src/main/resources/下>主类是jgli/src/main/java/test/Main.java如果我通过ide运行它,它会在Windows上运行,它crashes在Linux上。这就是我现在尝试通过控制台运行它的原因:java-jarjgli.jar但我不断得到:Errorcouldnotfindorloadmainclass'test.Main'这是我的build.gradleapplyp

java - 我可以使用 Collection.size() 来替换这段代码中的计数器吗?

代码如下:publicclassLogService{privatefinalBlockingQueuequeue;privatefinalLoggerThreadloggerThread;privatefinalPrintWriterwriter;@GuardedBy("this")privatebooleanisShutdown;@GuardedBy("this")privateintreservations;//这是JavaConcurrencyinPractice一书的片段,我在想也许计数器reservations是不必要的,因为我们可以简单地使用queue.size()获取q

java - 配置 maven-failsafe-plugin 以查找不在 src/test/java 中的集成测试

我的目录结构是这样的:src/integrationTest/javasrc/test/javasrc/main/java我正试图通过故障保护来进行集成测试,但未能按照我希望的方式进行。我试过这个:maven-failsafe-plugin2.17integration-testverifysrc/integrationTest/java${project.build.directory}/it-classes还有这个:maven-failsafe-plugin2.17integration-testverifysrc/integrationTest/**/*.java无济于事;fai

java - 名称冲突 : The method add(Object) of type test2 has the same erasure as add(E) of type HashSet<E> but does not override it

导入java.util.*;classAextendsHashSet{publicbooleanadd(Objectobj){//compilererrorreturntrue;}}orclassAbc{publicvoidadd(Tt){}//compilererrorpublicvoidadd(Objecti){}//compilererror(can'toverload?)}错误:名称冲突:test2类型的方法add(Object)与HashSet类型的add(E)具有相同的删除,但没有覆盖它我不知道上述错误背后的概念是什么,有人可以建议我在哪里可以研究这个概念吗?

java - SonarQube 问题 "Add at least one assertion to this test case"用于带有断言的单元测试?

我在使用SonarQube时遇到问题,我的几个单元测试出现了问题,提示了以下问题:Addatleastoneassertiontothistestcase.每个测试用例都类似于这种格式(其中许多断言被委托(delegate)给具有公共(public)断言的方法,以避免重复):@TestpublicvoidcompanyNameOneTooLong()throwsException{AddressFormBeanformBean=getValidBean();formBean.setCompanyNameOne("123456789012345678901234567890123456"

java - 为什么这么多方法使用 Collection 而不是 Iterable?

有了C#,我逐渐爱上了IEnumerable界面。在很多情况下,这就是您想要提供和接受的全部内容。此外,它在.Net库中也很有用。例如,您在List上有一个构造函数需要IEnumerable的类(class).我现在必须使用Java,自然想使用等效的Iterable界面。但是,似乎我真的不能在任何地方使用它。一切似乎都在使用扩展的Collection接口(interface)代替。为什么是这样?例如,您有ArrayList采用Collection的构造函数:Constructsalistcontainingtheelementsofthespecifiedcollection,inth

java - Guava/Google Collections 的向后兼容性如何?

我正在开发包含多个项目的大型应用程序,所有项目仍然使用GoogleCollections1.0。我想升级到Guava12。项目的测试覆盖率不是很好。有没有人有过类似的升级经验,有没有不兼容的地方?主要问题是什么? 最佳答案 这里是Guava贡献者。Guava12几乎完全向后兼容GoogleCollections,但极少数方法已经过了18个月的弃用期并被删除;见https://code.google.com/p/guava-libraries/issues/detail?id=836.也就是说,没有人应该仍然在使用GoogleColl

java - Sonar Java : check the quality of the test classes source code?

是否可以在Sonar中检查*Test.java源代码的质量,例如方法最大尺寸100行?问题是,JavaJunit测试随着生产代码的增加而增加,复杂性也在增加。我们有超过1000行和2个方法的单元测试类。我们想在Sonar中检查这些*Test.java类的一些规则。 最佳答案 从Sonar3.1开始,它包含一个插件,该插件具有针对单元测试执行的特定PMD规则(aJIRAwascreatedforthat)。您可以在Configuration>QualityProfiles>CodingRules中看到它们。但是,您似乎想要对测试源代码

java - 无法创建类 org.jboss.arquillian.test.impl.EventTestRunnerAdaptor 的新实例

我有这个pom.xml文件4.0.0companytrick-services-parent0.0.1-SNAPSHOTtricker-services-webappwartrick-resttrickorg.apache.maven.pluginsmaven-war-plugin../vagrant/deploymentsmaven-surefire-plugin2.17src/main/resourcestruesrc/test/resourcestrue-->testmaven-compiler-plugin2.3.21.61.6maven-surefire-plugin2.12