Added some files for maven to build

This commit is contained in:
2021-02-01 13:23:07 +02:00
parent ef5dd56394
commit 9126a8a988
5 changed files with 167 additions and 0 deletions

68
pom.xml Normal file
View File

@@ -0,0 +1,68 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>raffbrains</groupId>
<artifactId>myweb</artifactId>
<packaging>war</packaging>
<version>0.0.12</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<url>http://172.31.15.236:8081/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus</id>
<url>http://172.31.15.236:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,17 @@
package raffbrains.myweb.controller;
/*
*
*/
public class Calculator {
/*
* @param i
* @param j
* @return int
*/
public int add(int i, int j){
return i+j;
}
public int multiply(int i, int j){
return i*j;
}
}

View File

@@ -0,0 +1,7 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Mpho Raff Created Web Application</display-name>
</web-app>

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<h1 style="green:orange">Java Home App!!!!</h1>
</div>
</body>
</html>

View File

@@ -0,0 +1,57 @@
package raffbrains.myweb.controller;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
import junit.framework.Assert;
import junit.framework.TestCase;
public class CalculatorTest extends TestCase {
Calculator cal = new Calculator();
public void testAdd() {
Properties prop = new Properties();
OutputStream output = null;
try
{
output = new FileOutputStream("../config.properties");
// set the properties value
prop.setProperty("database", "localhost");
prop.setProperty("dbuser", "hari");
prop.setProperty("dbpassword", "password");
// save properties to project root folder
prop.store(output, null);
}catch(
IOException io)
{
io.printStackTrace();
}finally
{
if (output != null) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public void testMultiply() {
Assert.assertEquals(cal.multiply(10, 20), 200);
}
public void testAddNew() {
Assert.assertEquals(cal.add(10, 20), 30);
}
}