junit

LeetCode

被刻印的时光 ゝ 提交于 2021-01-01 18:01:05
Topic Array Two Pointers Description https://leetcode.com/problems/3sum-closest/ Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1 : Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). Constraints : 3 <= nums.length <= 10³ -10³ <= nums[i] <= 10³ -10⁴ <= target <= 10⁴ Analysis 方法一:我写的,受到 LeetCode - Medium - 15. 3Sum 启发而写,幸运成功地成功验收。与方法二相比

LeetCode

 ̄綄美尐妖づ 提交于 2020-12-30 16:52:38
Topic String Description https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string s, int numRows); Example 1 : Input: s = "PAYPALISHIRING", numRows = 3 Output: "PAHNAPLSIIGYIR" Example 2 : Input: s = "PAYPALISHIRING", numRows = 4 Output:

Test the SpringBoot application startup

天大地大妈咪最大 提交于 2020-12-30 08:07:38
问题 I have a JUnit test that starts an spring-boot application (in my case, the main class is SpringTestDemoApp ) after the test: @WebIntegrationTest @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringTestDemoApp.class) public class SpringTest { @Test public void test() { // Test http://localhost:8080/ (with Selenium) } } Everything works fine using spring-boot 1.3.3.RELEASE . Nevertheless, the annotation @WebIntegrationTest and @SpringApplicationConfiguration

Test the SpringBoot application startup

喜夏-厌秋 提交于 2020-12-30 08:02:43
问题 I have a JUnit test that starts an spring-boot application (in my case, the main class is SpringTestDemoApp ) after the test: @WebIntegrationTest @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringTestDemoApp.class) public class SpringTest { @Test public void test() { // Test http://localhost:8080/ (with Selenium) } } Everything works fine using spring-boot 1.3.3.RELEASE . Nevertheless, the annotation @WebIntegrationTest and @SpringApplicationConfiguration

RestAssuredMockMvc Connection to http://localhost:8080 refused

我怕爱的太早我们不能终老 提交于 2020-12-30 06:48:05
问题 I developed a Spring MVC webapp with rest methods. I would love to use RestAssured to create JUnit test classes. From the documentation it looks really simple to do but I'm having some problem instead. Basically I want to use it to avoid a runtime Tomcat instance but the problem is that when I execute the JUnit test class I obtain the following exception: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8082 refused ... Caused by: java.net.ConnectException:

RestAssuredMockMvc Connection to http://localhost:8080 refused

做~自己de王妃 提交于 2020-12-30 06:47:55
问题 I developed a Spring MVC webapp with rest methods. I would love to use RestAssured to create JUnit test classes. From the documentation it looks really simple to do but I'm having some problem instead. Basically I want to use it to avoid a runtime Tomcat instance but the problem is that when I execute the JUnit test class I obtain the following exception: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8082 refused ... Caused by: java.net.ConnectException:

RestAssuredMockMvc Connection to http://localhost:8080 refused

北战南征 提交于 2020-12-30 06:47:45
问题 I developed a Spring MVC webapp with rest methods. I would love to use RestAssured to create JUnit test classes. From the documentation it looks really simple to do but I'm having some problem instead. Basically I want to use it to avoid a runtime Tomcat instance but the problem is that when I execute the JUnit test class I obtain the following exception: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8082 refused ... Caused by: java.net.ConnectException:

LeetCode

故事扮演 提交于 2020-12-29 20:44:25
Topic String Dynamic Programming Description https://leetcode.com/problems/longest-palindromic-substring/ Given a string s , return the longest palindromic substring in s . Example 1 : Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2 : Input: s = "cbbd" Output: "bb" Example 3 : Input: s = "a" Output: "a" Example 4 : Input: s = "ac" Output: "a" Constraints : 1 <= s.length <= 1000 s consist of only digits and English letters (lower-case and/or upper-case), Analysis 方法一:以字符为中心向其两侧扩展探测是否回文。 方法二:动态规划。 dp(i, j) represents whether s(i ... j) can form a palindromic

Why isn't JUnit TemporaryFolder deleted?

被刻印的时光 ゝ 提交于 2020-12-29 09:04:13
问题 The documentation for JUnit's TemporaryFolder rule states that it creates files and folders that are "guaranteed to be deleted when the test method finishes (whether it passes or fails)" However, asserting that the TemporaryFolder does not exist fails: import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; public class MyTest { @Rule public TemporaryFolder _tempFolder = new

Why isn't JUnit TemporaryFolder deleted?

霸气de小男生 提交于 2020-12-29 09:02:24
问题 The documentation for JUnit's TemporaryFolder rule states that it creates files and folders that are "guaranteed to be deleted when the test method finishes (whether it passes or fails)" However, asserting that the TemporaryFolder does not exist fails: import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; public class MyTest { @Rule public TemporaryFolder _tempFolder = new