16
16
import java .util .zip .ZipEntry ;
17
17
import java .util .zip .ZipFile ;
18
18
19
+ import static java .lang .String .format ;
19
20
import static java .nio .charset .StandardCharsets .UTF_8 ;
20
21
import static java .util .Collections .list ;
21
22
import static org .assertj .core .api .Assertions .assertThat ;
@@ -44,12 +45,32 @@ public GeneratorIntegrationTest(MavenRuntimeBuilder mavenBuilder)
44
45
public void testBasic ()
45
46
throws Exception
46
47
{
47
- File basedir = resources .getBasedir ("basic" );
48
+ testProjectPackaging ("basic" , "its.BasicPlugin" );
49
+ }
50
+
51
+ @ Test
52
+ public void testAbstractPlugin ()
53
+ throws Exception
54
+ {
55
+ testProjectPackaging ("abstract-plugin-class" , "its.TestPlugin" );
56
+ }
57
+
58
+ @ Test
59
+ public void testInterfacePlugin ()
60
+ throws Exception
61
+ {
62
+ testProjectPackaging ("interface-plugin-class" , "its.TestPlugin" );
63
+ }
64
+
65
+ protected void testProjectPackaging (String projectId , String expectedPluginClass )
66
+ throws Exception
67
+ {
68
+ File basedir = resources .getBasedir (projectId );
48
69
maven .forProject (basedir )
49
70
.execute ("package" )
50
71
.assertErrorFreeLog ();
51
72
52
- File mainJarFile = new File (basedir , "target/basic -1.0.jar" );
73
+ File mainJarFile = new File (basedir , format ( "target/%s -1.0.jar" , projectId ) );
53
74
assertThat (mainJarFile ).isFile ();
54
75
55
76
try (JarFile jar = new JarFile (mainJarFile )) {
@@ -58,26 +79,26 @@ public void testBasic()
58
79
.doesNotContain (DESCRIPTOR );
59
80
}
60
81
61
- File servicesJarFile = new File (basedir , "target/basic -1.0-services.jar" );
82
+ File servicesJarFile = new File (basedir , format ( "target/%s -1.0-services.jar" , projectId ) );
62
83
assertThat (servicesJarFile ).isFile ();
63
84
64
85
try (JarFile jar = new JarFile (servicesJarFile )) {
65
86
JarEntry entry = jar .getJarEntry (DESCRIPTOR );
66
87
assertNotNull (entry );
67
88
try (InputStream in = jar .getInputStream (entry )) {
68
89
String contents = new String (toByteArray (in ), UTF_8 );
69
- assertThat (contents ).isEqualTo ("its.BasicPlugin \n " );
90
+ assertThat (contents ).isEqualTo (expectedPluginClass + " \n " );
70
91
}
71
92
}
72
93
73
- File pluginZipFile = new File (basedir , "target/basic -1.0.zip" );
94
+ File pluginZipFile = new File (basedir , format ( "target/%s -1.0.zip" , projectId ) );
74
95
assertThat (pluginZipFile ).isFile ();
75
96
76
97
try (ZipFile zip = new ZipFile (pluginZipFile )) {
77
98
assertThat (list (zip .entries ()))
78
99
.extracting (ZipEntry ::getName )
79
- .contains ("basic -1.0/basic -1.0.jar" )
80
- .contains ("basic -1.0/basic -1.0-services.jar" );
100
+ .contains (format ( "%1$s -1.0/%1$s -1.0.jar", projectId ) )
101
+ .contains (format ( "%1$s -1.0/%1$s -1.0-services.jar", projectId ) );
81
102
}
82
103
}
83
104
}
0 commit comments