Skip to content

Commit 4cd39cf

Browse files
committed
Little additional fixes
1 parent b96b415 commit 4cd39cf

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

utbot-spring-analyzer/src/main/java/application/SpringAnalysisRunner.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
public class SpringAnalysisRunner {
1616

1717
public static void main(String[] args) throws Exception {
18-
String arg0 = "D:/Projects/spring-starter-lesson-28/build/classes/java/main";
19-
String arg1 = "com.dmdev.spring.config.ApplicationConfiguration";
20-
String arg2 = "D:/Projects/spring-starter-lesson-28/src/main/resources/application.properties";
21-
String arg3 = "D:/Projects/spring-starter-lesson-28/src/main/resources/application.xml";
18+
//String arg0 = "D:/Projects/spring-starter-lesson-28/build/classes/java/main";
19+
//String arg1 = "com.dmdev.spring.config.ApplicationConfiguration";
20+
//String arg2 = "D:/Projects/spring-starter-lesson-28/src/main/resources/application.properties";
21+
//String arg3 = "D:/Projects/spring-starter-lesson-28/src/main/resources/application.xml";
2222

23-
ClassLoader classLoader = new URLClassLoader(new URL[]{Path.of(arg0).toUri().toURL()});
24-
Class<?> userConfigurationClass = classLoader.loadClass(arg1);
23+
ClassLoader classLoader = new URLClassLoader(new URL[]{Path.of(args[0]).toUri().toURL()});
24+
Class<?> userConfigurationClass = classLoader.loadClass(args[1]);
2525

2626
ConfigurationManager configurationManager = new ConfigurationManager(classLoader, userConfigurationClass);
27-
PropertiesAnalyzer propertiesAnalyzer = new PropertiesAnalyzer(arg2);
28-
XmlConfigurationAnalyzer xmlConfigurationAnalyzer = new XmlConfigurationAnalyzer(arg3);
27+
PropertiesAnalyzer propertiesAnalyzer = new PropertiesAnalyzer(args[2]);
28+
XmlConfigurationAnalyzer xmlConfigurationAnalyzer = new XmlConfigurationAnalyzer(args[2]);
2929

3030
xmlConfigurationAnalyzer.fillFakeApplicationXml();
3131

@@ -45,5 +45,4 @@ public static void main(String[] args) throws Exception {
4545
System.out.println("Bean analysis finished successfully");
4646
}
4747
}
48-
4948
}

utbot-spring-analyzer/src/main/java/utils/ConfigurationManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ public void patchImportResourceAnnotation() throws Exception {
2828
patchAnnotation(ImportResource.class, String.format("classpath:%s", ResourceNames.fakeApplicationXmlFileName));
2929
}
3030

31-
private void patchAnnotation(Class<?> type, String path) throws Exception {
31+
private void patchAnnotation(Class<?> annotationType, String newValue) throws Exception {
3232
Class<?> proxyClass = classLoader.loadClass("java.lang.reflect.Proxy");
3333
Field hField = proxyClass.getDeclaredField("h");
3434
hField.setAccessible(true);
3535

3636
Optional<Annotation> propertySourceAnnotation =
3737
Arrays.stream(userConfigurationClass.getAnnotations())
38-
.filter(el -> el.annotationType() == type)
38+
.filter(el -> el.annotationType() == annotationType)
3939
.findFirst();
40+
4041
if (propertySourceAnnotation.isPresent()) {
4142
InvocationHandler annotationInvocationHandler = (InvocationHandler) (hField.get(propertySourceAnnotation.get()));
4243

@@ -46,7 +47,7 @@ private void patchAnnotation(Class<?> type, String path) throws Exception {
4647
memberValuesField.setAccessible(true);
4748

4849
Map<String, Object> memberValues = (Map<String, Object>) (memberValuesField.get(annotationInvocationHandler));
49-
memberValues.put("value", path);
50+
memberValues.put("value", newValue);
5051
}
5152
}
5253
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
</beans>

0 commit comments

Comments
 (0)