11/*******************************************************************************
2- * Copyright (c) 2018 Remain Software
2+ * Copyright (c) 2018, 2025 Remain Software
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
1717import static org .junit .jupiter .api .Assertions .assertThrows ;
1818
1919import java .io .IOException ;
20- import java .net .MalformedURLException ;
20+ import java .net .URI ;
21+ import java .net .URISyntaxException ;
2122import java .net .URL ;
2223
2324import org .eclipse .core .runtime .AssertionFailedException ;
@@ -34,73 +35,77 @@ public void testTipImage() {
3435
3536 @ Test
3637 public void testTipImage3 () {
37- assertThrows (MalformedURLException .class , () -> new TipImage (new URL ("0gl kjfslkfjsl dkfjsldkfjl" )));
38+ assertThrows (URISyntaxException .class , () -> new TipImage (new URI ("0gl kjfslkfjsl dkfjsldkfjl" ). toURL ( )));
3839 }
3940
4041 @ Test
41- public void testTipImage2 () throws IOException {
42+ public void testTipImage2 () throws IOException , URISyntaxException {
4243 getTipImage ();
4344 }
4445
45- private TipImage getTipImage () throws IOException {
46- return new TipImage (new URL (URL ));
46+ private TipImage getTipImage () throws IOException , URISyntaxException {
47+ return new TipImage (new URI (URL ). toURL ( ));
4748 }
4849
4950 @ Test
50- public void testSetMaxHeight () throws IOException {
51- String imgAttributes = new TipImage (new URL (URL )).setAspectRatio (2 ).setMaxHeight (300 ).getIMGAttributes (200 ,
51+ public void testSetMaxHeight () throws IOException , URISyntaxException {
52+ String imgAttributes = new TipImage (new URI (URL ).toURL ()).setAspectRatio (2 ).setMaxHeight (300 )
53+ .getIMGAttributes (200 ,
5254 200 );
5355 assertThat (imgAttributes .trim ()).isEqualToIgnoringCase ("width=\" 200\" height=\" 100\" " );
5456 }
5557
5658 @ Test
57- public void testSetMaxWidth () throws IOException {
58- String imgAttributes = new TipImage (new URL (URL )).setAspectRatio (1.6 ).setMaxWidth (200 ).getIMGAttributes (400 ,
59+ public void testSetMaxWidth () throws IOException , URISyntaxException {
60+ String imgAttributes = new TipImage (new URI (URL ).toURL ()).setAspectRatio (1.6 ).setMaxWidth (200 )
61+ .getIMGAttributes (400 ,
5962 300 );
6063 assertThat (imgAttributes .trim ()).isEqualToIgnoringCase ("width=\" 200\" height=\" 125\" " );
6164 }
6265
6366 @ Test
6467 public void testAssertWidth () {
65- assertThrows (AssertionFailedException .class , () -> new TipImage (new URL (URL )).setAspectRatio (0 , 100 , false ));
68+ assertThrows (AssertionFailedException .class ,
69+ () -> new TipImage (new URI (URL ).toURL ()).setAspectRatio (0 , 100 , false ));
6670 }
6771
6872 @ Test
6973 public void testAssertHeight () {
70- assertThrows (AssertionFailedException .class , () -> new TipImage (new URL (URL )).setAspectRatio (1000 , 0 , false ));
74+ assertThrows (AssertionFailedException .class ,
75+ () -> new TipImage (new URI (URL ).toURL ()).setAspectRatio (1000 , 0 , false ));
7176 }
7277
7378 @ Test
74- public void testSetAspectRatioIntIntFalse () throws IOException {
79+ public void testSetAspectRatioIntIntFalse () throws IOException , URISyntaxException {
7580 String result = getTipImage ().setAspectRatio (200 , 50 , false ).getIMGAttributes (100 , 100 ).trim ();
7681 assertThat (result ).isEqualToIgnoringCase ("width=\" 100\" height=\" 25\" " );
7782 }
7883
7984 @ Test
80- public void testSetAspectRatioIntIntTrue () throws IOException {
85+ public void testSetAspectRatioIntIntTrue () throws IOException , URISyntaxException {
8186 String result = getTipImage ().setAspectRatio (400 , 300 , true ).getIMGAttributes (740 , 370 ).trim ();
8287 assertThat (result ).isEqualToIgnoringCase ("width=\" 400\" height=\" 300\" " );
8388 }
8489
8590 @ Test
86- public void testSetAspectRatioDouble () throws IOException {
91+ public void testSetAspectRatioDouble () throws IOException , URISyntaxException {
8792 String result = getTipImage ().setAspectRatio (1.5 ).getIMGAttributes (740 , 370 ).trim ();
8893 assertThat (result ).isEqualToIgnoringCase ("width=\" 555\" height=\" 370\" " );
8994 }
9095
9196 @ Test
92- public void testGetIMGAttributes () throws IOException {
97+ public void testGetIMGAttributes () throws IOException , URISyntaxException {
9398 String result = getTipImage ().setAspectRatio (1.5 ).getIMGAttributes (740 , 370 ).trim ();
9499 assertThat (result ).isEqualToIgnoringCase ("width=\" 555\" height=\" 370\" " );
95100 }
96101
97102 @ Test
98- public void testSetExtension () throws IOException {
103+ public void testSetExtension () throws IOException , URISyntaxException {
99104 assertThat (getTipImage ().getBase64Image ()).contains ("png" );
100105 }
101106
102107 @ Test
103- public void testSetExtension2 () throws IOException {
108+ public void testSetExtension2 () throws IOException , URISyntaxException {
104109 assertThat (getTipImage ().setExtension ("bmp" ).getBase64Image ()).contains ("bmp" );
105110 }
106111}
0 commit comments