-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from rujche/rujche/java-analyzer
Support all kinds of properties file like application(-profile).yaml(or yaml, properties)
- Loading branch information
Showing
9 changed files
with
170 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
cli/azd/internal/appdetect/javaanalyze/project_analyzer_spring_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package javaanalyze | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAnalyzeSpringProject(t *testing.T) { | ||
var project = analyzeSpringProject(filepath.Join("testdata", "project-one")) | ||
require.Equal(t, "", project.applicationProperties["not.exist"]) | ||
require.Equal(t, "jdbc:h2:mem:testdb", project.applicationProperties["spring.datasource.url"]) | ||
|
||
project = analyzeSpringProject(filepath.Join("testdata", "project-two")) | ||
require.Equal(t, "", project.applicationProperties["not.exist"]) | ||
require.Equal(t, "jdbc:h2:mem:testdb", project.applicationProperties["spring.datasource.url"]) | ||
|
||
project = analyzeSpringProject(filepath.Join("testdata", "project-three")) | ||
require.Equal(t, "", project.applicationProperties["not.exist"]) | ||
require.Equal(t, "HTML", project.applicationProperties["spring.thymeleaf.mode"]) | ||
|
||
project = analyzeSpringProject(filepath.Join("testdata", "project-four")) | ||
require.Equal(t, "", project.applicationProperties["not.exist"]) | ||
require.Equal(t, "mysql", project.applicationProperties["database"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...pdetect/javaanalyze/testdata/project-four/src/main/resources/application-mysql.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# database init, supports mysql too | ||
database=mysql | ||
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:petclinic} | ||
spring.datasource.username=${MYSQL_USERNAME:petclinic} | ||
spring.datasource.password=${MYSQL_PASSWORD:} | ||
# SQL is written to be idempotent so this is safe | ||
spring.sql.init.mode=always |
6 changes: 6 additions & 0 deletions
6
...tect/javaanalyze/testdata/project-four/src/main/resources/application-postgres.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
database=postgres | ||
spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_HOST:5432}/${POSTGRES_DATABASE:petclinic} | ||
spring.datasource.username=${POSTGRES_USERNAME:petclinic} | ||
spring.datasource.password=${POSTGRES_PASSWORD:} | ||
# SQL is written to be idempotent so this is safe | ||
spring.sql.init.mode=always |
29 changes: 29 additions & 0 deletions
29
...nal/appdetect/javaanalyze/testdata/project-four/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# database init, supports mysql too | ||
database=h2 | ||
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql | ||
spring.sql.init.data-locations=classpath*:db/${database}/data.sql | ||
|
||
# Web | ||
spring.thymeleaf.mode=HTML | ||
|
||
# JPA | ||
spring.jpa.hibernate.ddl-auto=none | ||
spring.jpa.open-in-view=true | ||
|
||
# Internationalization | ||
spring.messages.basename=messages/messages | ||
|
||
spring.profiles.active=mysql | ||
|
||
# Actuator | ||
management.endpoints.web.exposure.include=* | ||
|
||
# Logging | ||
logging.level.org.springframework=INFO | ||
# logging.level.org.springframework.web=DEBUG | ||
# logging.level.org.springframework.context.annotation=TRACE | ||
|
||
# Maximum time static resources should be cached | ||
spring.web.resources.cache.cachecontrol.max-age=12h | ||
|
||
server.port=8081 |
12 changes: 12 additions & 0 deletions
12
...zd/internal/appdetect/javaanalyze/testdata/project-one/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:testdb | ||
jackson: | ||
date-format: com.microsoft.azure.simpletodo.configuration.RFC3339DateFormat | ||
serialization: | ||
write-dates-as-timestamps: false | ||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
show-sql: true | ||
|
29 changes: 29 additions & 0 deletions
29
...al/appdetect/javaanalyze/testdata/project-three/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# database init, supports mysql too | ||
database=h2 | ||
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql | ||
spring.sql.init.data-locations=classpath*:db/${database}/data.sql | ||
|
||
# Web | ||
spring.thymeleaf.mode=HTML | ||
|
||
# JPA | ||
spring.jpa.hibernate.ddl-auto=none | ||
spring.jpa.open-in-view=true | ||
|
||
# Internationalization | ||
spring.messages.basename=messages/messages | ||
|
||
spring.profiles.active=mysql | ||
|
||
# Actuator | ||
management.endpoints.web.exposure.include=* | ||
|
||
# Logging | ||
logging.level.org.springframework=INFO | ||
# logging.level.org.springframework.web=DEBUG | ||
# logging.level.org.springframework.context.annotation=TRACE | ||
|
||
# Maximum time static resources should be cached | ||
spring.web.resources.cache.cachecontrol.max-age=12h | ||
|
||
server.port=8081 |
12 changes: 12 additions & 0 deletions
12
...d/internal/appdetect/javaanalyze/testdata/project-two/src/main/resources/application.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:testdb | ||
jackson: | ||
date-format: com.microsoft.azure.simpletodo.configuration.RFC3339DateFormat | ||
serialization: | ||
write-dates-as-timestamps: false | ||
jpa: | ||
hibernate: | ||
ddl-auto: update | ||
show-sql: true | ||
|