Skip to content

Commit

Permalink
Remove Kissaten dependency (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax authored Jan 22, 2024
1 parent 706df9a commit 4c9df9b
Show file tree
Hide file tree
Showing 123 changed files with 23,693 additions and 31 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.idea/
*.swp
test/spec/fixtures/repos/*
target
*.iml
.DS_Store
14 changes: 0 additions & 14 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,5 @@
"hatchet": {
"directory": "test/spec/fixtures"
},
"java": [
"kissaten/java-servlets-sample",
"kissaten/webapp-runner-sample",
"kissaten/korvan",
"kissaten/maven-polyglot",
"kissaten/libpng-test"
],
"spring": [
"kissaten/spring-boot-webapp-runner",
"kissaten/spring-boot-executable"
],
"db": [
"kissaten/java-apache-dbcp-sample"
],
"github": ["heroku/java-getting-started"]
}
16 changes: 0 additions & 16 deletions hatchet.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
---
- - test/spec/fixtures/repos/db/java-apache-dbcp-sample
- bc8ef681cf36bf3d78dd94ea514e6d26c649bbb1
- - test/spec/fixtures/repos/github/java-getting-started
- main
- - test/spec/fixtures/repos/java/java-servlets-sample
- 1cc2843067197d939a1218f1bbe63f5ed28c6111
- - test/spec/fixtures/repos/java/korvan
- 1a99202ecc10f9a27ad3fedb30403b3f4bcb4750
- - test/spec/fixtures/repos/java/libpng-test
- 2afd98d3a953fd49f9a2f77380a639ae3091ec98
- - test/spec/fixtures/repos/java/maven-polyglot
- ecab985c6fa8678b69cc6764f939fd76a9de70ee
- - test/spec/fixtures/repos/java/webapp-runner-sample
- 02b128a87db6df7776baafdcb9a69504e4a41a58
- - test/spec/fixtures/repos/spring/spring-boot-executable
- e10d57ce128ad43225b2e0c6c3a0c0d0aa71ff9e
- - test/spec/fixtures/repos/spring/spring-boot-webapp-runner
- dd3ec06e76b562bd3734ad5dc576b416ff1559ea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
21 changes: 21 additions & 0 deletions test/spec/fixtures/repos/java-apache-dbcp-sample/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Joe Kutner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions test/spec/fixtures/repos/java-apache-dbcp-sample/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java $JAVA_OPTS -cp target/classes:target/dependency/* Main
47 changes: 47 additions & 0 deletions test/spec/fixtures/repos/java-apache-dbcp-sample/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.0.v20120127</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.*;
import java.sql.*;
import org.apache.commons.dbcp2.*;

public class Main extends HttpServlet {

private BasicDataSource connectionPool;

public Main() throws URISyntaxException, SQLException {
URI dbUri = new URI(System.getenv("DATABASE_URL"));
String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + dbUri.getPath();
connectionPool = new BasicDataSource();

if (dbUri.getUserInfo() != null) {
connectionPool.setUsername(dbUri.getUserInfo().split(":")[0]);
connectionPool.setPassword(dbUri.getUserInfo().split(":")[1]);
}
connectionPool.setDriverClassName("org.postgresql.Driver");
connectionPool.setUrl(dbUrl);
connectionPool.setInitialSize(1);
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

if (req.getRequestURI().endsWith("/db")) {
showDatabase(req,resp);
} else {
showHome(req,resp);
}
}

private void showHome(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().print("Hello from Java!");
}

private void showDatabase(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try {
Connection connection = connectionPool.getConnection();

Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS ticks (tick timestamp)");
stmt.executeUpdate("INSERT INTO ticks VALUES (now())");
ResultSet rs = stmt.executeQuery("SELECT tick FROM ticks");

String out = "Hello!\n";
while (rs.next()) {
out += "Read from DB: " + rs.getTimestamp("tick") + "\n";
}

resp.getWriter().print(out);
} catch (Exception e) {
resp.getWriter().print("There was an error: " + e.getMessage());
}
}

public static void main(String[] args) throws Exception{
Server server = new Server(Integer.valueOf(System.getenv("PORT")));
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new Main()),"/*");
server.start();
server.join();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java.runtime.version=1.7

3 changes: 3 additions & 0 deletions test/spec/fixtures/repos/java-servlets-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
*.iml
.idea
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
21 changes: 21 additions & 0 deletions test/spec/fixtures/repos/java-servlets-sample/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Joe Kutner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions test/spec/fixtures/repos/java-servlets-sample/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java $JAVA_OPTS -cp target/classes:target/dependency/* Main
Loading

0 comments on commit 4c9df9b

Please sign in to comment.