Skip to content

Commit

Permalink
Init starter code
Browse files Browse the repository at this point in the history
  • Loading branch information
Amarygdala committed Oct 25, 2022
1 parent 1e7ccfb commit b52ed5a
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEO4J_ADDR=localhost
29 changes: 29 additions & 0 deletions .github/workflows/app-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: app-test

on:
push:
branches:
- develop
- master
pull_request:

defaults:
run:
working-directory: .

jobs:
apptests:
name: Tests
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
uses: actions/setup-java@v1
with:
java-version: 16
- name: Clean db before tests
run: delete_all_nodes
- name: Run mvn test
run: mvn test
- name: Clean db after tests
run: delete_all_nodes
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target/
.settings
.classpath
.factorypath
.project
.idea
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM maven:3.6.3-openjdk-16

WORKDIR /root/.m2/repository
COPY . ./
RUN mvn verify clean --fail-never
RUN mvn compile; sleep 15
ENTRYPOINT [ "mvn","exec:java" ]
EXPOSE 8000
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.7"
services:
assignment:
container_name: a1
build:
context: ./
dockerfile: Dockerfile
depends_on:
- neo4j
ports:
- '8080:8080'
environment:
- NEO4J_ADDR=neo4j
- HTTP_PROXY="http://cms-proxy.utsc.utoronto.ca:8118/"
- HTTPS_PROXY="http://cms-proxy.utsc.utoronto.ca:8118/"
- NO_PROXY=".utsc.utoronto.ca,.utoronto.ca,127.0.0.0/8"
neo4j:
container_name: neo4j
#platform: linux/amd64
image: neo4j:latest
environment:
- NEO4J_AUTH=neo4j/123456
ports:
- '7687:7687'
90 changes: 90 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<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>ca.utoronto.utm.mcs</groupId>
<artifactId>a1</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>a1</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.35.1</version>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.3.4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>dotenv-java</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>16</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>16</release>
<annotationProcessorPaths>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.35.1</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>ca.utoronto.utm.mcs.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ca.utoronto.utm.mcs;

import io.github.cdimascio.dotenv.Dotenv;
import java.io.IOException;

public class App
{
static int port = 8080;

public static void main(String[] args) throws IOException
{
// TODO Create Your Server Context Here, There Should Only Be One Context
System.out.printf("Server started on port %d\n", port);

// This code is used to get the neo4j address, you must use this so that we can mark :)
Dotenv dotenv = Dotenv.load();
String addr = dotenv.get("NEO4J_ADDR");
System.out.println(addr);
}
}
7 changes: 7 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ca.utoronto.utm.mcs;

// All your database transactions or queries should
// go in this class
public class Neo4jDAO {
// TODO Complete This Class
}
15 changes: 15 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/ReqHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ca.utoronto.utm.mcs;

import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

public class ReqHandler implements HttpHandler {

// TODO Complete This Class

@Override
public void handle(HttpExchange exchange) throws IOException {

}
}
12 changes: 12 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/ReqHandlerComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ca.utoronto.utm.mcs;

import dagger.Component;
import javax.inject.Singleton;

@Singleton
// TODO Uncomment The Line Below When You Have Implemented ReqHandlerModule
// @Component(modules = ReqHandlerModule.class)
public interface ReqHandlerComponent {

public ReqHandler buildHandler();
}
8 changes: 8 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/ReqHandlerModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ca.utoronto.utm.mcs;

import dagger.Module;

@Module
public class ReqHandlerModule {
// TODO Complete This Module
}
5 changes: 5 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/Server.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ca.utoronto.utm.mcs;

public class Server {
// TODO Complete This Class
}
12 changes: 12 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/ServerComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ca.utoronto.utm.mcs;

import dagger.Component;
import javax.inject.Singleton;

@Singleton
// TODO Uncomment The Line Below When You Have Implemented ServerModule
// @Component(modules = ServerModule.class)
public interface ServerComponent {

public Server buildServer();
}
8 changes: 8 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/ServerModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ca.utoronto.utm.mcs;

import dagger.Module;

@Module
public class ServerModule {
// TODO Complete This Module
}
16 changes: 16 additions & 0 deletions src/main/java/ca/utoronto/utm/mcs/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ca.utoronto.utm.mcs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

public class Utils {
public static String convert(InputStream inputStream) throws IOException {

try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
15 changes: 15 additions & 0 deletions src/test/java/ca/utoronto/utm/mcs/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ca.utoronto.utm.mcs;

import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

// TODO Please Write Your Tests For CI/CD In This Class. You will see
// these tests pass/fail on github under github actions.
public class AppTest {

@Test
public void exampleTest() {
assertTrue(true);
}

}

0 comments on commit b52ed5a

Please sign in to comment.