Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danthe1st committed Jul 24, 2023
0 parents commit fd631f8
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "run tests"
run: mvn test -PnativeTest
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 dan1st

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.
49 changes: 49 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.github.danthe1st</groupId>
<artifactId>spring-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.danthe1st.spring_test;

import org.springframework.data.repository.CrudRepository;

public interface EntityRepository extends CrudRepository<SomeEntity, String> {
SomeEntity getByName(String name);
}
23 changes: 23 additions & 0 deletions src/main/java/io/github/danthe1st/spring_test/SomeController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.github.danthe1st.spring_test;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class SomeController {

@PostMapping
public void setStartPage(@RequestParam MultipartFile imageFile) throws IOException {
somethingTransactional();
}

@Transactional
public void somethingTransactional() {

}
}
44 changes: 44 additions & 0 deletions src/main/java/io/github/danthe1st/spring_test/SomeEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.github.danthe1st.spring_test;

import java.util.Objects;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class SomeEntity {

@Id
private String name;

public String getName() {
return name;
}

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

@Override
public int hashCode() {
return Objects.hash(name);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SomeEntity other = (SomeEntity) obj;
return Objects.equals(name, other.name);
}

@Override
public String toString() {
return "SomeEntity [name=" + name + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.danthe1st.spring_test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;

@SpringBootApplication
public class SpringTestApplication implements ApplicationListener<ApplicationReadyEvent> {

private final EntityRepository repo;

public SpringTestApplication(EntityRepository repo) {
this.repo = repo;
}

@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
repo.getByName("");
}

public static void main(String[] args) {
SpringApplication.run(SpringTestApplication.class, args);
}
}
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring.jpa.show-sql=true
spring.jpa.hibernate.show-sql=true
logging.level.org.hibernate.SQL=DEBUG
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.danthe1st.spring_test;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;

@SpringBootTest
class SpringTestApplicationTests {

@Test
void testChangeStartPage() throws Exception {
}

@Test
@WithMockUser
void testChangeStartPageAsNonAdmin() throws Exception {
}
}

0 comments on commit fd631f8

Please sign in to comment.