Merge pull request #40 from cwiki-us-docs/code_bank

更新测试代码
This commit is contained in:
YuCheng Hu 2022-04-28 19:56:55 -04:00 committed by GitHub
commit 72120d88cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 11 deletions

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-8</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-8</name>
<packaging>jar</packaging>

View File

@ -11,9 +11,10 @@ import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
public class DateFormatUnitTest {
@Test
@Tes t
public void givenGregorianCalendar_whenLocaleSpecificDateInstance_givenLanguageSpecificMonths() {
GregorianCalendar gregorianCalendar = new GregorianCalendar(2018, 1, 1, 10, 15, 20);
Date date = gregorianCalendar.getTime();

View File

@ -1,6 +1,6 @@
package com.ossez.util;
import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertEquals;
import java.time.Clock;
import java.time.Instant;
@ -9,7 +9,7 @@ import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class CurrentDateTimeUnitTest {

View File

@ -3,7 +3,7 @@
This module contains articles about the Java List collection
### Relevant Articles:
- [Java Get Random Item/Element From a List](http://www.baeldung.com/java-random-list-element)
- [Java 如何从一个 List 中随机获得元素](https://www.ossez.com/t/java-list/13934)
- [Removing all nulls from a List in Java](http://www.baeldung.com/java-remove-nulls-from-list)
- [Removing all duplicates from a List in Java](http://www.baeldung.com/java-remove-duplicates-from-list)
- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list</name>
<packaging>jar</packaging>
@ -12,7 +11,7 @@
<groupId>com.ossez.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath></relativePath>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>

View File

@ -3,6 +3,8 @@ package com.ossez.list;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.LinkedList;
@ -11,12 +13,18 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
/**
* List Remove Tes
* Test for remove list
*
* @author YuCheng Hu
* <p><a href="https://www.ossez.com/t/java-list/13919">https://www.ossez.com/t/java-list/13919</a></p>
*
* @author YuCheng
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RemoveFirstElementTest {
private final static Logger logger = LoggerFactory.getLogger(RemoveFirstElementTest.class);
private ArrayList<String> list = new ArrayList();
private LinkedList<String> linkedList = new LinkedList<>();
@ -41,6 +49,8 @@ public class RemoveFirstElementTest {
*/
@Test
public void testGivenList_whenRemoveFirst_thenRemoved() {
logger.debug("Get Size of List - [{}]", list.size());
list.remove(0);
assertThat(list, hasSize(4));

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned by default the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.ossez" level="DEBUG"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>