client: use mock webserver for client config loader test

This commit is contained in:
Adam
2019-11-23 18:55:45 -05:00
parent 6f5a719cfb
commit b273e9f464
3 changed files with 103 additions and 17 deletions

View File

@@ -232,6 +232,12 @@
<version>${guice.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>3.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* Copyright (c) 2016-2019, Adam <Adam@sigterm.info>
* 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());
}
}

View File

@@ -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 <20> 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