junit

Internal graphics not initialized yet in JUunit test case

蹲街弑〆低调 提交于 2020-12-14 05:01:10
问题 I'm making a light weight painting application with JavaFx. I've been having some issues with my LayerController class and it's methods addLayer etc. So I thought that writing some JUunit test cases would be a good idea to check the correctness of my methods. To make the story short, I'm painting on a Canvas using its GraphicsContext in a selfmade class which I call PaintGraphics . This class does all the painting. The LayerController needs a PaintGraphics to do its work on the layers. But it

Junit multiple results in one test

谁都会走 提交于 2020-12-13 19:27:59
问题 Ok, I know this is considered an anti-pattern, and I am certainly open to a better way of doing this. I have a map of enum values. I want to ensure that each of those enum values is assigned to something. My test looks like this. @Test public void eachRowRequiresCellCalc() { Model model = new Model(); EnumValues[] values = EnumValues.values(); for (EnumValues value : values) { Assert.assertTrue(String.format("%s must be assigned", value.name()), model.hasEnumValue(value)); } } This works and

Junit multiple results in one test

你离开我真会死。 提交于 2020-12-13 19:17:31
问题 Ok, I know this is considered an anti-pattern, and I am certainly open to a better way of doing this. I have a map of enum values. I want to ensure that each of those enum values is assigned to something. My test looks like this. @Test public void eachRowRequiresCellCalc() { Model model = new Model(); EnumValues[] values = EnumValues.values(); for (EnumValues value : values) { Assert.assertTrue(String.format("%s must be assigned", value.name()), model.hasEnumValue(value)); } } This works and

Junit multiple results in one test

笑着哭i 提交于 2020-12-13 19:14:30
问题 Ok, I know this is considered an anti-pattern, and I am certainly open to a better way of doing this. I have a map of enum values. I want to ensure that each of those enum values is assigned to something. My test looks like this. @Test public void eachRowRequiresCellCalc() { Model model = new Model(); EnumValues[] values = EnumValues.values(); for (EnumValues value : values) { Assert.assertTrue(String.format("%s must be assigned", value.name()), model.hasEnumValue(value)); } } This works and

JUnit - org.hibernate.SessionException: Session is closed

本小妞迷上赌 提交于 2020-12-13 18:07:58
问题 I am facing a common error with Hibernate sessions : javax.persistence.TransactionRequiredException: Executing an update/delete query. I found a solution, make my test class extends AbstractTransactionalJUnit4SpringContextTests but I don't understand why is it necessary. I try to set junit (4.11 version) tests on my project. My test class : _ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:config/ioc/application-context-spring-test.xml" })

JUnit - org.hibernate.SessionException: Session is closed

这一生的挚爱 提交于 2020-12-13 18:07:31
问题 I am facing a common error with Hibernate sessions : javax.persistence.TransactionRequiredException: Executing an update/delete query. I found a solution, make my test class extends AbstractTransactionalJUnit4SpringContextTests but I don't understand why is it necessary. I try to set junit (4.11 version) tests on my project. My test class : _ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:config/ioc/application-context-spring-test.xml" })

JUnit - org.hibernate.SessionException: Session is closed

前提是你 提交于 2020-12-13 18:05:53
问题 I am facing a common error with Hibernate sessions : javax.persistence.TransactionRequiredException: Executing an update/delete query. I found a solution, make my test class extends AbstractTransactionalJUnit4SpringContextTests but I don't understand why is it necessary. I try to set junit (4.11 version) tests on my project. My test class : _ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:config/ioc/application-context-spring-test.xml" })

LeetCode

主宰稳场 提交于 2020-12-13 12:40:11
Topic Tree, Depth-first Search Description https://leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example 1 : Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: true Example 2 : Input: 1 1 / \ 2 2 [1,2], [1,null,2] Output: false Example 3 : Input: 1 1 / \ / \ 2 1 1 2 [1,2,1], [1,1,2] Output: false Analysis 方法一:递归前序遍历 方法二:非递归前序遍历 Submission import java.util.Arrays; import java.util.LinkedList; import com.lun.util

maven常用命令

巧了我就是萌 提交于 2020-12-13 00:37:29
上面是指定端口运行程序的,也可以先指定好,直接在上面的地方写jettty:run 当然,如果你是在控制台运行且安装了maven,直接可以进入项目的文件中:mvn jetty:run 就是说,在控制台运行只要加上一个mvn就ok了 你先需要理解maven的生命周期与插件目标这两个概念。 拿Maven clean来说吧。生命周期为clean.插件目标为maven-clean-plugin:clean。 Maven build是这个插件让你自己去配置执行目标的。 Maven clean 清除上一次Maven执行的结果 Maven generate-sources会根据pom配置去生成 源代码 格式的包 Maven install将项目输出构件部署到本地仓库 maven最主要的作用有两个方面,一个是对jar包的依赖解决功能,自己管理jar包,另一个功能就是项目的构建,打包部署。现在我觉得最重要的还是maven的生命周期和插件机制,下面就来总结一下吧。 mvn install 是将你打好的jar包安装到你的本地库中,一般没有设置过是在 用户目录下的 . m2 \下面。 mvn package 只是将你的代码打包到输出目录,一般的是 target下面。 eclipse插件,m2eclipse 1.maven install相当于maven原生的命令: mvn install 2.aven

LeetCode

落爺英雄遲暮 提交于 2020-12-12 13:51:32
Topic String Description https://leetcode.com/problems/length-of-last-word/ Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0. A word is a maximal substring consisting of non-space characters only. Example 1 : Input: s = "Hello World" Output: 5 Example 2 : Input: s = " " Output: 0 Constraints : 1 <= s.length <= 10⁴ s consists of only English letters and spaces ' '. Analysis 略 Submission public class LengthOfLastWord { public int lengthOfLastWord1(String s) { String[] array = s.split(" ");