Skip to content

Commit

Permalink
some simple tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
pz2 committed Feb 19, 2024
1 parent 8b4645a commit e8cb116
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 8 deletions.
11 changes: 11 additions & 0 deletions hofund-spring-boot-e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
<!-- <artifactId>ojdbc8</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand All @@ -59,6 +69,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class HofundE2E {

public static void main(String[] args) {
SpringApplication.run(HofundE2E.class, args);
}


@GetMapping("/test")
public String test() {
return "test";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.logchange.hofund;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class TestController {

// private final TestRepository testRepository;

@GetMapping("/test")
public String test() {
return "test";
}

// @GetMapping("/testEntity")
// public Iterable<TestEntity> testEntity() {
// return testRepository.findAll();
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//package dev.logchange.hofund;
//
//import jakarta.persistence.Entity;
//import jakarta.persistence.Id;
//import lombok.Getter;
//import lombok.Setter;
//
//@Getter
//@Setter
//@Entity
//public class TestEntity {
//
// @Id
// private Long id;
//
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//package dev.logchange.hofund;
//
//import org.springframework.data.repository.CrudRepository;
//import org.springframework.stereotype.Repository;
//
//@Repository
//public interface TestRepository extends CrudRepository<TestEntity, Long> {
//}
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
server.port=8626
management.endpoints.web.exposure.include=prometheus

#spring.jpa.hibernate.ddl-auto=none

#spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
#spring.datasource.username=maindb
#spring.datasource.password=password
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.OracleDialect
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//package dev.logchange.hofund.connection.spring.datasources.oracle;
//
//import lombok.extern.slf4j.Slf4j;
//import org.junit.jupiter.api.Assertions;
//import org.junit.jupiter.api.Test;
//import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.boot.test.web.client.TestRestTemplate;
//import org.springframework.boot.test.web.server.LocalServerPort;
//
//@Slf4j
//@AutoConfigureObservability
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
// properties = {
// "spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe",
// "spring.datasource.username=system",
// "spring.datasource.password=password",
// "spring.datasource.driver-class-name=oracle.jdbc.OracleDriver"
// })
//public class OracleDataSourceE2ETest {
// private final TestRestTemplate template = new TestRestTemplate();
//
// @LocalServerPort
// private int port;
//
// @Test
// void shouldContainsHofundConnectionForOracleDatabase() {
// //given:
// String path = "http://localhost:" + port + "/actuator/prometheus";
//
// String expected = "# HELP hofund_info Basic information about application\n" +
// "# TYPE hofund_info gauge\n" +
// "hofund_info{application_name=\"testapp\",application_version=\"1.2.3\",id=\"testapp\",} 1.0";
//
// //when:
// String response = template.getForObject(path, String.class);
//
// //then:
// log.info("Expecting: \n{}\nResponse: \n{}", expected, response);
// Assertions.assertTrue(response.contains(expected));
// }
//}

0 comments on commit e8cb116

Please sign in to comment.