diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index a07335788e..2c162879a0 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -232,6 +232,12 @@ ${guice.version} test + + com.squareup.okhttp3 + mockwebserver + 3.7.0 + test + diff --git a/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java b/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java index 436c2c2bea..c2c3d3a87e 100644 --- a/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java +++ b/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, Adam + * Copyright (c) 2016-2019, Adam * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,34 +22,49 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - package net.runelite.client.rs; +import com.google.common.base.Charsets; +import com.google.common.io.CharStreams; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.After; +import static org.junit.Assert.assertEquals; +import org.junit.Before; import org.junit.Test; -/** - * - * @author Adam - */ public class ClientConfigLoaderTest { - @Test - public void test() throws IOException + private final MockWebServer server = new MockWebServer(); + + @Before + public void before() throws IOException { - final RSConfig config = ClientConfigLoader.fetch(null); - - for (String key : config.getClassLoaderProperties().keySet()) + String response; + try (InputStream in = getClass().getResourceAsStream("jav_config.ws")) { - System.out.println(key + ": " + config.getClassLoaderProperties().get(key)); + response = CharStreams.toString(new InputStreamReader( + in, Charsets.UTF_8)); } + server.enqueue(new MockResponse().setBody(response)); - System.out.println("Applet properties:"); + server.start(); + } - for (String key : config.getAppletProperties().keySet()) - { - System.out.println(key + ": " + config.getAppletProperties().get(key)); - } + @After + public void after() throws IOException + { + server.shutdown(); + } + + @Test + public void testFetch() throws IOException + { + final RSConfig config = ClientConfigLoader.fetch(server.url("/")); + assertEquals("http://oldschool1.runescape.com/", config.getCodeBase()); } } diff --git a/runelite-client/src/test/resources/net/runelite/client/rs/jav_config.ws b/runelite-client/src/test/resources/net/runelite/client/rs/jav_config.ws new file mode 100644 index 0000000000..c85ff07cb3 --- /dev/null +++ b/runelite-client/src/test/resources/net/runelite/client/rs/jav_config.ws @@ -0,0 +1,65 @@ +title=Old School RuneScape +adverturl=http://www.runescape.com/g=oldscape/bare_advert.ws +codebase=http://oldschool1.runescape.com/ +cachedir=oldschool +storebase=0 +initial_jar=gamepack_6140455.jar +initial_class=client.class +termsurl=http://www.jagex.com/g=oldscape/terms/terms.ws +privacyurl=http://www.jagex.com/g=oldscape/privacy/privacy.ws +viewerversion=124 +win_sub_version=1 +mac_sub_version=2 +other_sub_version=2 +browsercontrol_win_x86_jar=browsercontrol_0_-1928975093.jar +browsercontrol_win_amd64_jar=browsercontrol_1_1674545273.jar +download=1276414 +window_preferredwidth=800 +window_preferredheight=600 +advert_height=96 +applet_minwidth=765 +applet_minheight=503 +applet_maxwidth=5760 +applet_maxheight=2160 +msg=lang0=English +msg=tandc=This game is copyright © 1999 - 2019 Jagex Ltd.\Use of this game is subject to our ["http://www.runescape.com/terms/terms.ws"Terms and Conditions] and ["http://www.runescape.com/privacy/privacy.ws"Privacy Policy]. +msg=options=Options +msg=language=Language +msg=changes_on_restart=Your changes will take effect when you next start this program. +msg=loading_app_resources=Loading application resources +msg=err_verify_bc64=Unable to verify browsercontrol64 +msg=err_verify_bc=Unable to verify browsercontrol +msg=err_load_bc=Unable to load browsercontrol +msg=loading_app=Loading application +msg=err_create_target=Unable to create target applet +msg=err_create_advertising=Unable to create advertising +msg=err_save_file=Error saving file +msg=err_downloading=Error downloading +msg=ok=OK +msg=cancel=Cancel +msg=message=Message +msg=copy_paste_url=Please copy and paste the following URL into your web browser +msg=information=Information +msg=err_get_file=Error getting file +msg=new_version=Update available! You can now launch the client directly from the OldSchool website.\nGet the new version from the link on the OldSchool homepage: http://oldschool.runescape.com/ +msg=new_version_linktext=Open OldSchool Homepage +msg=new_version_link=http://oldschool.runescape.com/ +param=14=0 +param=12=301 +param=11=https://auth.jagex.com/ +param=13=.runescape.com +param=3=false +param=6=0 +param=7=0 +param=9=ElZAIrq5NpKN6D3mDdihco3oPeYN2KFy2DCquj7JMmECPmLrDP3Bnw +param=15=0 +param=10=5 +param=8=true +param=17=http://www.runescape.com/g=oldscape/slr.ws?order=LPWM +param=2=https://payments.jagex.com/operator/v1/ +param=18= +param=4=45569 +param=1=1 +param=19=196515767263-1oo20deqm6edn7ujlihl6rpadk9drhva.apps.googleusercontent.com +param=16=false +param=5=0