Skip to content

add instructor into readme #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
export OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
make test-e2e
make run-e2e
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build-image:
docker build . -t ghcr.io/devops-ws/learn-springboot:master
test-e2e:
run-e2e:
cd e2e && ./start.sh
run-demo:
cd e2e && docker compose up server
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project aims to verify [linuxsuren/api-testing](https://github.com/LinuxSuR
Run E2E testing:

```shell
make build-image test-e2e
make build-image run-e2e
```

Run with Maven command:
Expand All @@ -13,11 +13,19 @@ Run with Maven command:
mvn spring-boot:run
```

Run in container:

```shell
docker run -p 8080:8080 ghcr.io/devops-ws/learn-springboot:master
```

Change the listen port:
```shell
java -jar demo.jar --server.port=8081
```

The default username is `admin`, and password is: `123456`.

## OpenAPI definition
You can visit it via: http://localhost:8080/v3/api-docs

Expand Down
12 changes: 12 additions & 0 deletions e2e/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ api: |
{{default "http://localhost:8080" (env "SERVER")}}
param:
auth: Basic {{ base64 "admin:123456" }}
randNum: |
{{randInt 1 1000}}
items:
- name: health
request:
Expand Down Expand Up @@ -120,3 +122,13 @@ items:
expect:
header:
Content-Type: application/octet-stream

## cache
- name: cache
request:
api: /cache?delay={{ .param.randNum }}
header:
Authorization: "{{ .param.auth }}"
expect:
bodyFieldsExpect:
pageCount: "{{ .param.randNum }}"
2 changes: 2 additions & 0 deletions src/main/java/io/github/devopsws/demo/DemoApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

@EnableTRpc
@EnableCaching
@SpringBootApplication
public class DemoApplication {

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/github/devopsws/demo/service/CacheService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.github.devopsws.demo.service;

import io.github.devopsws.demo.model.Book;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cache")
public class CacheService {

@GetMapping("")
@Cacheable("books")
public Book index(Integer delay) {
System.out.println("getting book with cache feature");
if (delay == null) {
delay = 0;
}
try {
Thread.sleep(delay);
} catch (Exception e) {
e.printStackTrace();
}

Book book = new Book("book-1", "Effective Java", delay, "author-1");
return book;
}
}
3 changes: 0 additions & 3 deletions src/main/java/io/github/devopsws/demo/service/GraphQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.graphql.data.method.annotation.SchemaMapping;
import org.springframework.stereotype.Controller;
import io.github.devopsws.demo.model.Book;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;

@Controller
public class GraphQL {
Expand Down