Skip to content

Commit

Permalink
WIP - Removals rules
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed Dec 20, 2024
1 parent 29c8b77 commit d8bb0de
Show file tree
Hide file tree
Showing 8 changed files with 4,021 additions and 0 deletions.
3,748 changes: 3,748 additions & 0 deletions default/generated/spring-boot/spring-boot-2.x-to-3.0-removals.yaml

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions default/generated/spring-boot/tests/data/removals/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>spring-boot-2-7-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Spring Boot 2.7.18 Example</name>
<description>Example Spring Boot 2.7.18 project</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/> <!-- Lookup parent from Maven repository -->
</parent>

<properties>
<java.version>11</java.version> <!-- Set Java version (11 or later for Spring Boot 2.7.x) -->
</properties>

<dependencies>
<!-- Spring Boot Starter Web for building RESTful APIs -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Boot Starter Data JPA for database access -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version> <!-- Use the latest version if needed -->
</dependency>

<!-- Uncomment if using MySQL instead -->
<!--
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
-->

<!-- Spring Boot Starter Test for unit and integration tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- Lombok for reducing boilerplate code -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.konveyor.deps;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;

@SpringBootApplication
public class BootDepsApplication {

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

public void method() {
ConfigFileApplicationListener configFileApplicationListener = new ConfigFileApplicationListener();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.konveyor.deps;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jdbc.AbstractDataSourceInitializer;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceInitializationMode;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;

import javax.sql.DataSource;

@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
public class CustomDataSourceInitializer extends AbstractDataSourceInitializer {

private ResourceLoader resourceLoader;

@Autowired
public CustomDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
super(dataSource, resourceLoader);
this.resourceLoader = resourceLoader;
}

@Override
protected void customize(ResourceDatabasePopulator populator) {
populator.addScript(resourceLoader.getResource("schema.sql"));
}

@Override
protected DataSourceInitializationMode getMode() {
return null;
}

@Override
protected String getSchemaLocation() {
return null;
}

@Override
protected String getDatabaseName() {
// Return the database name for which this initializer applies
return "H2"; // Adjust based on your database type
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.konveyor.deps;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.batch.BatchDataSourceInitializer;
import org.springframework.boot.autoconfigure.batch.BatchProperties;
import org.springframework.boot.autoconfigure.integration.IntegrationDataSourceInitializer;
import org.springframework.boot.autoconfigure.integration.IntegrationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;

import javax.sql.DataSource;

import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.core.io.ResourceLoader;

@Configuration
public class DataSourceConfig {

@Value("${spring.datasource.url}")
private String url;

@Value("${spring.datasource.username}")
private String username;

@Value("${spring.datasource.password}")
private String password;

@Value("${spring.datasource.driver-class-name:org.h2.Driver}")
private String driverClassName;

@Value("${spring.datasource.initial-size:10}")
private int initialSize;

@Value("${spring.datasource.max-total:50}")
private int maxTotal;

@Bean
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setDriverClassName(driverClassName);
dataSource.setInitialSize(initialSize);
dataSource.setMaxTotal(maxTotal);
return dataSource;
}

@Bean
public BatchProperties batchProperties() {
return new BatchProperties();
}

@Bean
public IntegrationProperties integrationProperties() {
return new IntegrationProperties();
}

@Bean
@Autowired
public BatchDataSourceInitializer batchDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, BatchProperties batchProperties) {
return new BatchDataSourceInitializer(dataSource, resourceLoader, batchProperties);
}

@Bean
@Autowired
public IntegrationDataSourceInitializer integrationDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, IntegrationProperties integrationProperties) {
return new IntegrationDataSourceInitializer(dataSource, resourceLoader, integrationProperties);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.application.name=boot-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.konveyor.boot_deps;

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

@SpringBootTest
class BootDepsApplicationTests {

@Test
void contextLoads() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
rulesPath: ../spring-boot-2.x-to-3.0-removals.yaml
providers:
- name: java
dataPath: ./data/removals
- name: builtin
dataPath: ./data/removals
tests:
- ruleID: spring-boot-2.x-to-3.0-removals-00010
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 1
- ruleID: spring-boot-2.x-to-3.0-removals-00020
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 1
- ruleID: spring-boot-2.x-to-3.0-removals-00030
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 3
- ruleID: spring-boot-2.x-to-3.0-removals-00040
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 2
# - ruleID: spring-boot-2.x-to-3.0-removals-00050
# testCases:
# - name: tc-1
# analysisParams:
# mode: "source-only"
# hasIncidents:
# exactly: 2
- ruleID: spring-boot-2.x-to-3.0-removals-00060
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 3

0 comments on commit d8bb0de

Please sign in to comment.