Skip to content

Commit

Permalink
remove deprecated calls
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Dec 17, 2023
1 parent 306baa4 commit 775557f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
Expand All @@ -15,61 +18,69 @@ public class FieldBasedCGGamesTest extends AbstractFieldBasedTest {

@Test
public void testBunnyHunt() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.themaninblue.com/experiment/BunnyHunt/");
URL url = getUrl("http://www.themaninblue.com/experiment/BunnyHunt/");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC);
}

private static URL getUrl(String urlStr) throws MalformedURLException {
try {
return new URI(urlStr).toURL();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

@Disabled("seems to break with http issues")
@Test
public void testBeslimed() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.markus-inger.de/test/game.php");
URL url = getUrl("http://www.markus-inger.de/test/game.php");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC);
}

@Disabled("seems to break with http issues")
@Test
public void testDiggAttack() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.pixastic.com/labs/digg_attack/");
URL url = getUrl("http://www.pixastic.com/labs/digg_attack/");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC);
}

@Disabled
@Test
public void testRiverRaider() throws IOException, WalaException, Error, CancelException {
URL url =
new URL(
getUrl(
"http://playstar.mobi/games/riverraider/index.html?playerId=&gameId=8&highscore=102425");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST);
}

@Disabled("fails with \"timed out\" CancelException")
@Test
public void testSolitaire() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.inmensia.com/files/solitaire1.0.html");
URL url = getUrl("http://www.inmensia.com/files/solitaire1.0.html");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC);
}

@Test // (expected = CancelException.class)
public void testWorldOfSolitaire() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://worldofsolitaire.com/");
URL url = getUrl("http://worldofsolitaire.com/");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC);
}

@Test
public void testMinesweeper() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.inmensia.com/files/minesweeper1.0.html");
URL url = getUrl("http://www.inmensia.com/files/minesweeper1.0.html");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST);
}

@Test
public void testProtoRPG() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.protorpg.com/games/protorpg/?game=prologue");
URL url = getUrl("http://www.protorpg.com/games/protorpg/?game=prologue");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST);
}

@Test
public void testBattleship() throws IOException, WalaException, Error, CancelException {
URL url = new URL("http://www.sinkmyship.com/battleship/single.html");
URL url = getUrl("http://www.sinkmyship.com/battleship/single.html");
runTest(url, new Object[][] {}, BuilderType.OPTIMISTIC_WORKLIST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;
import java.io.IOException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Tag("requires-Internet")
public class FieldBasedJQueryTest extends AbstractFieldBasedTest {

@Test
public void test1_8_2() throws IOException, WalaException, Error, CancelException {
public void test1_8_2()
throws IOException, WalaException, Error, CancelException, URISyntaxException {
runTest(
new URL("http://code.jquery.com/jquery-1.8.2.js"),
new URI("http://code.jquery.com/jquery-1.8.2.js").toURL(),
new Object[][] {},
BuilderType.OPTIMISTIC_WORKLIST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Properties;
import java.util.function.Supplier;
Expand Down Expand Up @@ -78,7 +80,7 @@ public static CGBuilderResult buildHTMLCG(
URL url = null;
try {
url = toUrl(src);
} catch (MalformedURLException e1) {
} catch (MalformedURLException | URISyntaxException e1) {
fail("Could not find page to analyse: " + src);
}
com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(
Expand Down Expand Up @@ -118,15 +120,15 @@ public static CGBuilderResult buildHTMLCG(
}
}

private static URL toUrl(String src) throws MalformedURLException {
private static URL toUrl(String src) throws MalformedURLException, URISyntaxException {
// first try interpreting as local file name, if that doesn't work just
// assume it's a URL
try {
File f = new FileProvider().getFileFromClassLoader(src, HTMLCGBuilder.class.getClassLoader());
URL url = f.toURI().toURL();
return url;
} catch (FileNotFoundException fnfe) {
return new URL(src);
return new URI(src).toURL();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Set;

Expand All @@ -44,15 +46,16 @@ public static void main(String args[])
IOException,
CancelException,
Error,
WalaException {
WalaException,
URISyntaxException {

if (args.length != 1) {
System.out.println("Usage: <URL of html page to analyze>");
System.exit(1);
}
boolean domless = false;

URL url = new URL(args[0]);
URL url = new URI(args[0]).toURL();

// computing CG + PA
JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
Expand Down

0 comments on commit 775557f

Please sign in to comment.