@@ -15,7 +15,6 @@ void packageName() {
15
15
URI classpathResourceUri = URI .create ("classpath:com/example" );
16
16
String packageName = ClasspathSupport .packageName (classpathResourceUri );
17
17
assertEquals ("com.example" , packageName );
18
-
19
18
}
20
19
21
20
@ Test
@@ -24,12 +23,84 @@ void packageNameOfResource() {
24
23
assertEquals ("com.example" , packageName );
25
24
}
26
25
26
+ @ Test
27
+ void determinePackageName () {
28
+ Path baseDir = Paths .get ("path" , "to" , "com" , "example" , "app" );
29
+ String basePackageName = "com.example.app" ;
30
+ Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
31
+ String packageName = ClasspathSupport .determinePackageName (baseDir , basePackageName , classFile );
32
+ assertEquals ("com.example.app" , packageName );
33
+ }
34
+
35
+ @ Test
36
+ void determinePackageNameFromRootPackage () {
37
+ Path baseDir = Paths .get ("path" , "to" );
38
+ String basePackageName = "" ;
39
+ Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
40
+ String packageName = ClasspathSupport .determinePackageName (baseDir , basePackageName , classFile );
41
+ assertEquals ("com.example.app" , packageName );
42
+ }
43
+
44
+ @ Test
45
+ void determinePackageNameFromComPackage () {
46
+ Path baseDir = Paths .get ("path" , "to" , "com" );
47
+ String basePackageName = "com" ;
48
+ Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
49
+ String packageName = ClasspathSupport .determinePackageName (baseDir , basePackageName , classFile );
50
+ assertEquals ("com.example.app" , packageName );
51
+ }
52
+
27
53
@ Test
28
54
void determineFullyQualifiedClassName () {
29
55
Path baseDir = Paths .get ("path" , "to" , "com" , "example" , "app" );
30
- String basePackageName = "com.example" ;
56
+ String basePackageName = "com.example.app" ;
57
+ Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
58
+ String fqn = ClasspathSupport .determineFullyQualifiedClassName (baseDir , basePackageName , classFile );
59
+ assertEquals ("com.example.app.App" , fqn );
60
+ }
61
+
62
+ @ Test
63
+ void determineFullyQualifiedClassNameFromRootPackage () {
64
+ Path baseDir = Paths .get ("path" , "to" );
65
+ String basePackageName = "" ;
66
+ Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
67
+ String fqn = ClasspathSupport .determineFullyQualifiedClassName (baseDir , basePackageName , classFile );
68
+ assertEquals ("com.example.app.App" , fqn );
69
+ }
70
+
71
+ @ Test
72
+ void determineFullyQualifiedClassNameFromComPackage () {
73
+ Path baseDir = Paths .get ("path" , "to" , "com" );
74
+ String basePackageName = "com" ;
31
75
Path classFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "App.class" );
32
76
String fqn = ClasspathSupport .determineFullyQualifiedClassName (baseDir , basePackageName , classFile );
33
- assertEquals ("com.example.App" , fqn );
77
+ assertEquals ("com.example.app.App" , fqn );
78
+ }
79
+
80
+ @ Test
81
+ void determineFullyQualifiedResourceName () {
82
+ Path baseDir = Paths .get ("path" , "to" , "com" , "example" , "app" );
83
+ String basePackageName = "com/example/app" ;
84
+ Path resourceFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "app.feature" );
85
+ URI fqn = ClasspathSupport .determineClasspathResourceUri (baseDir , basePackageName , resourceFile );
86
+ assertEquals (URI .create ("classpath:com/example/app/app.feature" ), fqn );
87
+ }
88
+
89
+ @ Test
90
+ void determineFullyQualifiedResourceNameFromRootPackage () {
91
+ Path baseDir = Paths .get ("path" , "to" );
92
+ String basePackageName = "" ;
93
+ Path resourceFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "app.feature" );
94
+ URI fqn = ClasspathSupport .determineClasspathResourceUri (baseDir , basePackageName , resourceFile );
95
+ assertEquals (URI .create ("classpath:com/example/app/app.feature" ), fqn );
96
+ }
97
+
98
+ @ Test
99
+ void determineFullyQualifiedResourceNameFromComPackage () {
100
+ Path baseDir = Paths .get ("path" , "to" , "com" );
101
+ String basePackageName = "com" ;
102
+ Path resourceFile = Paths .get ("path" , "to" , "com" , "example" , "app" , "app.feature" );
103
+ URI fqn = ClasspathSupport .determineClasspathResourceUri (baseDir , basePackageName , resourceFile );
104
+ assertEquals (URI .create ("classpath:com/example/app/app.feature" ), fqn );
34
105
}
35
106
}
0 commit comments