Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvariyath committed Feb 16, 2025
2 parents e6a344e + d0a3b65 commit 1a29276
Show file tree
Hide file tree
Showing 39 changed files with 204 additions and 18 deletions.
2 changes: 0 additions & 2 deletions core-java-modules/core-java-lang-syntax-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ This module contains articles about Java syntax

- [Guide to Java Packages](https://www.baeldung.com/java-packages)
- [If-Else Statement in Java](https://www.baeldung.com/java-if-else)
- [Control Structures in Java](https://www.baeldung.com/java-control-structures)
- [Java Double Brace Initialization](https://www.baeldung.com/java-double-brace-initialization)
- [The Java Native Keyword and Methods](https://www.baeldung.com/java-native)
- [Variable Scope in Java](https://www.baeldung.com/java-variable-scope)
- [Introduction to Basic Syntax in Java](https://www.baeldung.com/java-syntax)
- [Java ‘protected’ Access Modifier](https://www.baeldung.com/java-protected-access-modifier)
- [Using the Not Operator in If Conditions in Java](https://www.baeldung.com/java-using-not-in-if-conditions)
- [The for-each Loop in Java](https://www.baeldung.com/java-for-each-loop)
Expand Down
6 changes: 6 additions & 0 deletions core-java-modules/core-java-lang-syntax-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ This module contains articles about Java syntax
### Relevant Articles:

- [Create an Instance of Generic Type in Java](https://www.baeldung.com/java-generic-type-instance-create)
- [Java For Loop](https://www.baeldung.com/java-for-loop)
- [A Guide to Java Loops](https://www.baeldung.com/java-loops)
- [Breaking Out of Nested Loops](https://www.baeldung.com/java-breaking-out-nested-loop)
- [Java Do-While Loop](https://www.baeldung.com/java-do-while-loop)
- [Java While Loop](https://www.baeldung.com/java-while-loop)
- [Java Primitives Type Casting](https://www.baeldung.com/java-primitive-conversions)
- [[<-- Prev]](/core-java-modules/core-java-lang-syntax-2)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.baeldung.initializationguide;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

public class User implements Serializable, Cloneable {

private static final Logger LOGGER = LoggerFactory.getLogger(User.class);
private static final long serialVersionUID = 1L;
static String forum;
private String name;
private int id;

{
id = 0;
LOGGER.debug("Instance Initializer");
}

static {
forum = "Java";
LOGGER.debug("Static Initializer");
}

public User(String name, int id) {
super();
this.name = name;
this.id = id;
}

public User() {
LOGGER.debug("Constructor");
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

@Override
protected Object clone() throws CloneNotSupportedException {
return this;
}

}

8 changes: 2 additions & 6 deletions core-java-modules/core-java-lang-syntax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ This module contains articles about Java syntax

### Relevant Articles:
- [The Basics of Java Generics](https://www.baeldung.com/java-generics)
- [Java Primitives Type Casting](https://www.baeldung.com/java-primitive-conversions)
- [A Guide to Creating Objects in Java](https://www.baeldung.com/java-initialization)
- [A Guide to Java Loops](https://www.baeldung.com/java-loops)
- [Varargs in Java](https://www.baeldung.com/java-varargs)
- [Java Switch Statement](https://www.baeldung.com/java-switch)
- [Breaking Out of Nested Loops](https://www.baeldung.com/java-breaking-out-nested-loop)
- [Java Do-While Loop](https://www.baeldung.com/java-do-while-loop)
- [Java While Loop](https://www.baeldung.com/java-while-loop)
- [Java For Loop](https://www.baeldung.com/java-for-loop)
- [Control Structures in Java](https://www.baeldung.com/java-control-structures)
- [Introduction to Basic Syntax in Java](https://www.baeldung.com/java-syntax)
- [[More -->]](/core-java-modules/core-java-lang-syntax-2)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.baeldung.switchstatement;

import com.baeldung.loops.LoopsInJava;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.baeldung.lombok.intro;

import java.util.ArrayList;

import lombok.val;

public class TypeInferred {

public String lombokTypeInferred() {

val list = new ArrayList<String>();
list.add("Hello, Lombok!");
val listElem = list.get(0);
return listElem.toLowerCase();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class})
public class DateTimeIntegrationTest {
public class DateTimeLiveTest {

@Autowired
private DateTimeValueRepository dateTimeValueRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ export class UserService {
: User.ANONYMOUS
);
}
if (!!user.exp) {
if (typeof user.exp === "number" && user.exp > 0 && user.exp < Number.MAX_SAFE_INTEGER / 1000) {
const now = Date.now();
const delay = (1000 * user.exp - now) * 0.8;
if (delay > 2000) {
this.refreshSub = interval(delay).subscribe(() => this.refresh());
const expMs = user.exp * 1000; // Convert expiration time to milliseconds safely

if (expMs > now) { // Ensure expiration is in the future
const delay = (expMs - now) * 0.8;

if (delay > 2000 && delay < Number.MAX_SAFE_INTEGER) {
this.refreshSub = interval(delay).subscribe(() => this.refresh());
}
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions testing-modules/junit-5-basics-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
- [assertEquals() vs. assertSame() in JUnit](https://www.baeldung.com/java-assertequals-vs-assertsame)
- [The Difference Between JUnit and Mockito](https://www.baeldung.com/junit-vs-mockito)
- [Avoiding “no runnable methods” Error in JUnit](https://www.baeldung.com/java-junit-no-runnable-methods)
- [Tagging and Filtering JUnit Tests](https://www.baeldung.com/junit-filtering-tests)
- [JUnit 5 Temporary Directory Support](https://www.baeldung.com/junit-5-temporary-directory)
- [JUnit 5 @Test Annotation](http://www.baeldung.com/junit-5-test-annotation)
- [The Difference Between Failure and Error in JUnit](https://www.baeldung.com/junit-failure-vs-error)
107 changes: 107 additions & 0 deletions testing-modules/junit-5-basics-2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
</parent>

<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand All @@ -34,6 +46,27 @@
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>

Expand All @@ -43,7 +76,81 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>filtering</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
**/*IntegrationTest.java
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>category</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<groups>com.baeldung.categories.UnitTest</groups>
<excludedGroups>com.baeldung.categories.IntegrationTest</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>tags</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<groups>UnitTest</groups>
<excludedGroups>IntegrationTest</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<properties>
<spring.version>5.0.6.RELEASE</spring.version>
<h2.version>1.4.197</h2.version> <!-- needs to be specified to be compatible with spring.version 5.0.6.RELEASE -->
</properties>
</project>
4 changes: 0 additions & 4 deletions testing-modules/junit-5-basics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
- [A Guide to JUnit 5](http://www.baeldung.com/junit-5)
- [JUnit5 @RunWith](http://www.baeldung.com/junit-5-runwith)
- [Get the Path of the /src/test/resources Directory in JUnit](https://www.baeldung.com/junit-src-test-resources-directory-path)
- [Tagging and Filtering JUnit Tests](https://www.baeldung.com/junit-filtering-tests)
- [JUnit 5 Temporary Directory Support](https://www.baeldung.com/junit-5-temporary-directory)
- [@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll](http://www.baeldung.com/junit-before-beforeclass-beforeeach-beforeall)
- [JUnit 5 @Test Annotation](http://www.baeldung.com/junit-5-test-annotation)
- [Migrating from JUnit 4 to JUnit 5](http://www.baeldung.com/junit-5-migration)
- [Assert an Exception Is Thrown in JUnit 4 and 5](https://www.baeldung.com/junit-assert-exception)
- [The Difference Between Failure and Error in JUnit](https://www.baeldung.com/junit-failure-vs-error)

0 comments on commit 1a29276

Please sign in to comment.