Skip to content

Commit 8ddea81

Browse files
committed
dev: update deps and fix manifest
1 parent a18df05 commit 8ddea81

3 files changed

Lines changed: 128 additions & 17 deletions

File tree

pom.xml

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1414
<okhttp.version>4.12.0</okhttp.version>
15-
<gson.version>2.9.0</gson.version>
15+
<gson.version>2.13.1</gson.version>
1616
</properties>
1717
<licenses>
1818
<license>
@@ -59,7 +59,7 @@
5959
<plugin>
6060
<groupId>org.apache.maven.plugins</groupId>
6161
<artifactId>maven-source-plugin</artifactId>
62-
<version>3.2.0</version>
62+
<version>3.4.0</version>
6363
<executions>
6464
<execution>
6565
<id>attach-sources</id>
@@ -72,7 +72,7 @@
7272
<plugin>
7373
<groupId>org.apache.maven.plugins</groupId>
7474
<artifactId>maven-javadoc-plugin</artifactId>
75-
<version>3.3.1</version>
75+
<version>3.12.0</version>
7676
<executions>
7777
<execution>
7878
<id>attach-javadocs</id>
@@ -85,7 +85,7 @@
8585
<plugin>
8686
<groupId>org.apache.maven.plugins</groupId>
8787
<artifactId>maven-gpg-plugin</artifactId>
88-
<version>3.0.1</version>
88+
<version>3.2.8</version>
8989
<executions>
9090
<execution>
9191
<id>sign-artifacts</id>
@@ -113,7 +113,7 @@
113113
<plugin>
114114
<groupId>org.apache.maven.plugins</groupId>
115115
<artifactId>maven-surefire-plugin</artifactId>
116-
<version>3.0.0</version>
116+
<version>3.5.5</version>
117117
<configuration>
118118
<skip>true</skip>
119119
</configuration>
@@ -153,13 +153,13 @@
153153
<dependency>
154154
<groupId>com.squareup.okio</groupId>
155155
<artifactId>okio</artifactId>
156-
<version>3.7.0</version>
156+
<version>3.12.0</version>
157157
<scope>compile</scope>
158158
</dependency>
159159
<dependency>
160160
<groupId>com.google.code.gson</groupId>
161161
<artifactId>gson</artifactId>
162-
<version>2.9.0</version>
162+
<version>${gson.version}</version>
163163
<scope>compile</scope>
164164
</dependency>
165165
<dependency>
@@ -189,7 +189,7 @@
189189
<dependency>
190190
<groupId>commons-codec</groupId>
191191
<artifactId>commons-codec</artifactId>
192-
<version>1.15</version>
192+
<version>1.21.0</version>
193193
<scope>test</scope>
194194
</dependency>
195195
</dependencies>
@@ -198,7 +198,7 @@
198198
<plugin>
199199
<groupId>org.apache.maven.plugins</groupId>
200200
<artifactId>maven-dependency-plugin</artifactId>
201-
<version>2.5.1</version>
201+
<version>3.10.0</version>
202202
<executions>
203203
<execution>
204204
<id>copy-agent</id>
@@ -223,15 +223,15 @@
223223
<plugin>
224224
<groupId>org.apache.maven.plugins</groupId>
225225
<artifactId>maven-surefire-plugin</artifactId>
226-
<version>3.0.0</version>
226+
<version>3.5.5</version>
227227
<configuration>
228228
<argLine>-javaagent:"${project.build.directory}/agents/jmockit-1.49.jar"</argLine>
229229
</configuration>
230230
</plugin>
231231
<plugin>
232232
<groupId>org.apache.maven.plugins</groupId>
233233
<artifactId>maven-compiler-plugin</artifactId>
234-
<version>3.11.0</version>
234+
<version>3.15.0</version>
235235
<configuration>
236236
<source>1.8</source>
237237
<target>1.8</target>
@@ -243,7 +243,7 @@
243243
<plugin>
244244
<groupId>org.apache.maven.plugins</groupId>
245245
<artifactId>maven-jar-plugin</artifactId>
246-
<version>3.2.2</version>
246+
<version>3.5.0</version>
247247
<configuration>
248248
<archive>
249249
<manifest>
@@ -256,7 +256,7 @@
256256
<plugin>
257257
<groupId>org.sonatype.plugins</groupId>
258258
<artifactId>nexus-staging-maven-plugin</artifactId>
259-
<version>1.6.13</version>
259+
<version>1.7.0</version>
260260
<extensions>true</extensions>
261261
<configuration>
262262
<serverId>ossrh</serverId>
@@ -267,11 +267,24 @@
267267
<plugin>
268268
<groupId>org.apache.felix</groupId>
269269
<artifactId>maven-bundle-plugin</artifactId>
270-
<version>3.5.1</version>
270+
<version>5.1.9</version>
271271
<extensions>true</extensions>
272272
<configuration>
273273
<instructions>
274-
<Import-Package>!com.tinify.*,!org.bouncycastle.jsse.*,!com.experian.b2b.global.mvdam-project.*,!android.*,!javax.annotation.meta.*,!org.conscrypt.*;resolution:=optional,*
274+
<Import-Package>
275+
!com.tinify.*,
276+
!org.bouncycastle.jsse.*,
277+
!com.experian.b2b.global.mvdam-project.*,
278+
!android.*,
279+
!dalvik.*,
280+
!javax.annotation.meta.*,
281+
!javax.lang.model.*,
282+
!kotlin.reflect.jvm.internal.*,
283+
!org.conscrypt.*,
284+
!org.openjsse.*,
285+
sun.misc;resolution:=optional,
286+
sun.security.ssl;resolution:=optional,
287+
*
275288
</Import-Package>
276289
<Embed-Dependency>
277290
*;scope=compile|runtime
@@ -283,7 +296,26 @@
283296
<plugin>
284297
<groupId>org.apache.maven.plugins</groupId>
285298
<artifactId>maven-dependency-plugin</artifactId>
286-
<version>3.6.1</version>
299+
<version>3.10.0</version>
300+
</plugin>
301+
<plugin>
302+
<groupId>org.apache.maven.plugins</groupId>
303+
<artifactId>maven-failsafe-plugin</artifactId>
304+
<version>3.5.5</version>
305+
<configuration>
306+
<systemPropertyVariables>
307+
<project.build.directory>${project.build.directory}</project.build.directory>
308+
<project.build.finalName>${project.build.finalName}</project.build.finalName>
309+
</systemPropertyVariables>
310+
</configuration>
311+
<executions>
312+
<execution>
313+
<goals>
314+
<goal>integration-test</goal>
315+
<goal>verify</goal>
316+
</goals>
317+
</execution>
318+
</executions>
287319
</plugin>
288320
</plugins>
289321
</build>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.tinify;
2+
3+
import org.junit.Test;
4+
5+
import java.io.File;
6+
import java.io.IOException;
7+
import java.util.Arrays;
8+
import java.util.List;
9+
import java.util.jar.JarFile;
10+
import java.util.jar.Manifest;
11+
import java.util.jar.Attributes;
12+
13+
import static org.junit.Assert.*;
14+
15+
public class BundleManifestIT {
16+
17+
private static final List<String> FORBIDDEN_IMPORTS = Arrays.asList(
18+
"org.openjsse.",
19+
"dalvik.",
20+
"android.",
21+
"kotlin.reflect.jvm.internal"
22+
);
23+
24+
private Manifest loadBundleManifest() throws IOException {
25+
String buildDir = System.getProperty("project.build.directory", "target");
26+
String finalName = System.getProperty("project.build.finalName", "tinify-1.8.8");
27+
File jar = new File(buildDir, finalName + ".jar");
28+
assertTrue("Bundle JAR not found: " + jar.getAbsolutePath(), jar.exists());
29+
try (JarFile jarFile = new JarFile(jar)) {
30+
return jarFile.getManifest();
31+
}
32+
}
33+
34+
@Test
35+
public void bundleHasRequiredOsgiHeaders() throws IOException {
36+
Attributes attrs = loadBundleManifest().getMainAttributes();
37+
38+
assertEquals("2", attrs.getValue("Bundle-ManifestVersion"));
39+
assertNotNull("Missing Bundle-SymbolicName", attrs.getValue("Bundle-SymbolicName"));
40+
assertNotNull("Missing Bundle-Version", attrs.getValue("Bundle-Version"));
41+
assertNotNull("Missing Export-Package", attrs.getValue("Export-Package"));
42+
}
43+
44+
@Test
45+
public void importPackageDoesNotContainUnresolvablePackages() throws IOException {
46+
Attributes attrs = loadBundleManifest().getMainAttributes();
47+
String importPackage = attrs.getValue("Import-Package");
48+
assertNotNull("Missing Import-Package header", importPackage);
49+
50+
for (String forbidden : FORBIDDEN_IMPORTS) {
51+
assertFalse(
52+
"Import-Package must not contain " + forbidden + " but was: " + importPackage,
53+
importPackage.contains(forbidden)
54+
);
55+
}
56+
}
57+
58+
@Test
59+
public void exportPackageContainsTinify() throws IOException {
60+
Attributes attrs = loadBundleManifest().getMainAttributes();
61+
String exportPackage = attrs.getValue("Export-Package");
62+
assertTrue(
63+
"Export-Package must contain com.tinify",
64+
exportPackage.contains("com.tinify")
65+
);
66+
}
67+
68+
@Test
69+
public void bundleEmbedsDependencies() throws IOException {
70+
Attributes attrs = loadBundleManifest().getMainAttributes();
71+
String bundleClassPath = attrs.getValue("Bundle-ClassPath");
72+
assertNotNull("Missing Bundle-ClassPath", bundleClassPath);
73+
assertTrue("Bundle-ClassPath must contain okhttp", bundleClassPath.contains("okhttp"));
74+
assertTrue("Bundle-ClassPath must contain gson", bundleClassPath.contains("gson"));
75+
assertTrue("Bundle-ClassPath must contain okio", bundleClassPath.contains("okio"));
76+
}
77+
}

src/test/java/com/tinify/ClientTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.logging.Logger;
2626

2727
import static org.junit.Assert.assertEquals;
28+
import static org.junit.Assert.assertTrue;
2829
import static org.junit.Assert.fail;
2930

3031
public class ClientTest {
@@ -424,7 +425,8 @@ public void requestWithBadServerResponseRepeatedlyShouldThrowExceptionWithMessag
424425
new Client(key).request(Client.Method.POST, "/shrink");
425426
fail("Expected an Exception to be thrown");
426427
} catch (Exception e) {
427-
assertEquals("Error while parsing response: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ (HTTP 543/ParseError)", e.getMessage());
428+
assertTrue(e.getMessage().startsWith("Error while parsing response: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $"));
429+
assertTrue(e.getMessage().endsWith("(HTTP 543/ParseError)"));
428430
}
429431
}
430432

0 commit comments

Comments
 (0)