Source Code
Source Code
Source Code
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<groupId>com.userAuthentication</groupId>
<artifactId>UserAuthentication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>UserAuthentication</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--Junit Jupiter API-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<!--maven compiler plugin-->
<!--link: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-
target.html-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
AuthenticationUser.java:
package com.userAuthentication;
AuthTest.java
package com.userAuthentication;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.userAuthentication.AuthenticationUser;
class AuthTest {
@BeforeEach
public void setup() {
authU= new AuthenticationUser();
System.out.println("Authentication User main class inititated");
}
@AfterEach
public void tearDown() {
authU=null;
System.out.println("Class Closed");
}
@Test
public void checkUser() {
assertEquals("namratakudachi@gmail.com", authU.username());
}
@Test
public void checkUserNull()
{
assertNotNull(authU.username());
}
@Test
public void checkPass() {
assertEquals("Namrata@12345", authU.paswd());
}
@Test
public void checkPassNull()
{
assertNotNull(authU.paswd());
}
@Test
public void checkUserRegx()
{
String email = authU.username();
String regex = "^(.+)@(.+)$";
assertEquals(true, matcher.matches());
}
}