Skip to content

Commit

Permalink
UnitTests changes after #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Panasiuk committed Aug 17, 2022
1 parent 33179c2 commit d528996
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 56 deletions.
4 changes: 2 additions & 2 deletions test/CurlReaderTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sjpAPI;
package sjpapi.api;

import junit.framework.TestCase;

Expand All @@ -14,7 +14,7 @@ public class CurlReaderTest extends TestCase {
// SjpAPI has stopped working.
// If it still works, you can ignore this test.
public void testIsSJPHaveSameSite() throws IOException {
String mockCurl = "200<!DOCTYPE html> <html lang=\"pl\"> <head> <meta charset=\"utf-8\" /> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\" /> <title>Słownik SJP.PL - Słownik języka polskiego, ortograficzny</title> <style type=\"text/css\"> body { margin: 0; padding: 15px; font: 16px/1.4 sans-serif; word-wrap: break-word; } body { -webkit-text-size-adjust: 100%; } a { text-decoration: none; } a:link, .lc { color: #23a; } h1 { font: bold 24px sans-serif; } ul.m li { line-height: 2.4; } hr { border: none; height: 1px; background: #ccc; } .z p { max-width: 34em; margin-bottom: 1.5em; } .y, .s { font-size: 13px; } .y, .y a { color: #333; } .ifnm { display: none; } button, input[type=submit] { font: inherit; padding: 5px 12px; border: solid 1px rgba(0,0,0,0.3); border-radius: 4px; background: none; color: #333; } input, textarea { font: inherit; padding: 5px 3px; border: solid 1px rgba(0,0,0,0.3); border-radius: 0; outline: none; } input:not([type]) { -webkit-appearance: none; } input[type=submit]::-moz-focus-inner { border: 0; } .aucmp { display: none; position: absolute; left: 0; right: 0; background: #fff; border: solid 1px #ccc; font-weight: bold; z-index: 1; } .aucmp div { padding: 5px 3px; cursor: pointer; } .aucmp div:hover, .aucmp .ausel { background: #eee; } @media (min-width: 760px) { body { margin: 5px auto; padding: 15px; font: 14px/1.4 sans-serif; max-width: 820px; } ul.m { list-style-type: none; padding: 0; } ul.m li { display: inline; margin-right: 1em; line-height: 1.2; } ul.m a { color: #555; } .y, .s { font-size: 12px; } .win .y, .win .s { font-size: 11px; } .ifnm { display: block; } .ifm { display: none; } } @media (min-width: 760px) and (max-resolution: 1dppx) { .win body { font: 13px/1.4 verdana, sans-serif; } } @media (max-width: 320px) { .advl { margin-left: -5px; } } </style> <script> if (/Windows|X11/.test(navigator.userAgent)) document.documentElement.className = 'win'; </script> <meta name=\"Description\" content=\"Słownik języka polskiego, ortograficzny, wyrazów obcych i słownik do gier w jednym\" /> <meta name=\"google-site-verification\" content=\"mwQawI7xVDKeSxO-Alfab0eqsanOjRDJK5ayt8PAeQg\" /> </head> <body> <div class=\"ifnm\" style=\"xoverflow-y: auto; margin-bottom: 1.25em;\"> <a href=\"/\" style=\"float: left; background: #26c; color: #fff; border-radius: 2px; padding: 0 2.1em 4px; font: bold 26px Verdana, sans-serif; text-decoration: none; margin-right: .7em; \">SJP</a> <form style=\"margin: 0;\" action=\"/slownik/zg.phtml\" method=\"post\"> <div style=\"display: inline-block; position: relative; width: 34%;\"><input id=\"inp1\" accesskey=\"s\" tabindex=\"1\" autocomplete=\"off\" style=\"margin: 0; width: 100%; box-sizing: border-box; padding: 7px 2px;\" name=\"sl\" autofocus ></input><div class=\"aucmp\"></div></div> <input style=\"margin-left: 0; padding: 7px 12px;\" type=\"submit\" value=\"sprawdź\" /> </form> </div> <div class=\"ifm\" style=\"margin: -15px -15px 0; background: #26c; color: #fff; text-align: center; font: bold 18px/44px sans-serif; padding-top: 2px; border-bottom: solid 1px #fff;\"><a href=\"#\" onclick=\"a=document.getElementById('mblock'); if(a) a.className=(a.className?'':'ifnm'); return false;\" style=\"position: absolute; left: 0; width: 54px;\"><div style=\"display: inline-block; width: 22px; height: 3px; border-top: 3px solid #fff; border-bottom: 9px double #fff;\"></div></a>SŁOWNIK SJP</div> <div class=\"ifnm\" id=\"mblock\"> <ul type=\"square\" class=\"m\"><li><a href=\"/\">słownik języka polskiego sjp</a></li><li><a href=\"/slownik/lp.phtml\">słowa</a></li><li><a href=\"/slownik/ok.phtml\">komentarze</a></li><li><a href=\"/slownik/po.phtml\">więcej</a></li></ul> <hr class=\"ifnm\" style=\"margin: 1.25em 0 2em;\" /> </div> <form class=\"ifm\" action=\"/slownik/zg.phtml\" method=\"post\"> <table style=\"margin: 10px 0 20px;\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"top\" style=\"position: relative;\"><input id=\"inp2\" autocomplete=\"off\" name=\"sl\" style=\"padding: 6px 4px; box-sizing: border-box; width: 100%;\" autocapitalize=\"off\" /><div class=\"aucmp\"></div><div class=\"clx\" style=\"position: absolute; right: 0; top: 50%; transform: translateY(-50%); padding: 6px 10px; color: #ccc;\" onclick=\"xin=document.getElementById('inp2');xin.value='';xin.focus();return false;\">X</div></td><td valign=\"top\" width=\"1%\" style=\"padding-left: 4px;\"><input style=\"padding: 6px 12px;\" type=\"submit\" value=\"sprawdź\" /></td></tr></table> </form> <h1>Słownik SJP.PL</h1> <p>Słownik języka polskiego, ortograficzny, wyrazów obcych i słownik do gier w jednym.</p> <button onclick=\"this.style.display='none';document.getElementById('ab').style.display='block';return false;\" style=\"padding: 10px 0; border: none; cursor: pointer;\">więcej...</button> <div id=\"ab\" style=\"display: none;\"> <p>Słownik jest rozwijany z myślą o zastosowaniu do sprawdzania pisowni w programach open-source, do gier słownych (np. <a href=\"https://www.kurnik.pl/literaki/\">literaki</a>) i do użytku online jako kilka rodzajów słowników w jednym.</p> <p>Redakcją słownika zajmują się hobbyści.</p> <p>Słownik jest udostępniany na otwartych licencjach (różnych w zależności od wersji).</p> <p>Pierwsza wersja (słownik alternatywny) powstała na bazie dawnego słownika do ispella.</p> <p>Kontakt w sprawach technicznych: sjpslownik@gmail.com</p> <p>&copy; Zespół SJP.PL</p> </div> <script> function auc(a,k){function e(){b.innerHTML=\"\";b.style.display=\"none\";g=!0;f++}function l(d){var c=new XMLHttpRequest;c.onreadystatechange=function(){if(4==c.readyState&&200==c.status&&f==d){var a=JSON.parse(c.responseText);b.innerHTML=\"\";for(var e=0;e<a.d.length;e++)b.innerHTML+=\"<div>\"+a.d[e]+\"</div>\";g=0==a.d.length;b.style.display=g?\"none\":\"block\"}};c.open(\"GET\",\"/slownik/s/?q=\"+encodeURIComponent(a.value),!0);c.send()}if(a){var b=a.nextSibling;if(b){var f= 0,g=!1;a.onblur=function(a){e()};a.onkeydown=function(d){if(g)return!0;if(27==d.keyCode)return e(),!1;if(40!=d.keyCode&&38!=d.keyCode||!b.firstChild)return!0;var c=b.querySelector(\".ausel\");d=40==d.keyCode;if(c){c.className=\"\";var h=d?c.nextSibling:c.previousSibling}h||(h=d?b.firstChild:b.lastChild);h.className=\"ausel\";a.value=h.innerText;f++;return!1};b.onmousedown=function(d){if(d.target.parentNode==b)return a.value=d.target.innerText,a.form.submit(),!1};a.oninput=function(b){var c=++f;a.value.length? setTimeout(function(){f==c&&l(c)},k):e()}}}}auc(document.getElementById(\"inp1\"),150);auc(document.getElementById(\"inp2\"),250); </script> </body> </html> ";
String mockCurl = "200<!DOCTYPE html> <html lang=\"pl\"> <head> <meta charset=\"utf-8\" /> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\" /> <title>Słownik SJP.PL - Słownik języka polskiego, słownik do gier</title> <meta name=\"Description\" content=\"Słownik języka polskiego, ortograficzny, wyrazów obcych i słownik do gier słownych w jednym (słownik literaki, skrable)\" /> <meta name=\"google-site-verification\" content=\"mwQawI7xVDKeSxO-Alfab0eqsanOjRDJK5ayt8PAeQg\" /> <style type=\"text/css\"> body { margin: 0; padding: 15px; font: 16px/1.4 sans-serif; } body, .basecl { background: #fff; color: #222; } body { word-wrap: break-word; -webkit-text-size-adjust: 100%; } a { text-decoration: none; } a:visited { color: #528; } a:link, a.lc, .lc { color: #23a; } .bg1 { background: #cdf; } .bg0 { background: #26c; } h1 { font: bold 24px sans-serif; } hr { border: none; height: 1px; background: rgba(128,128,128,.4); } .z p { max-width: 34em; margin-bottom: 1.5em; } .y, .s { font: 14px sans-serif; } .y { opacity: .8; } .y a { color: inherit; } .lopc { opacity: .7; } .lbg { background: rgba(128,128,128,.08); } ul.m { list-style-type: square; line-height: 2.4; } .ifnm { display: none; } button, input, textarea { font: inherit; background: none; color: inherit; } button { padding: 5px 12px; border: solid 1px rgba(128,128,128,.6); border-radius: 4px; } input, textarea { padding: 5px 4px; border: solid 1px rgba(128,128,128,.6); border-radius: 3px; outline: none; } input[type=checkbox] { vertical-align: middle; } .aucmp { display: none; position: absolute; left: 0; right: 0; border: solid 1px rgba(128,128,128,.4); font-weight: bold; z-index: 1; } .aucmp div { padding: 6px 4px; cursor: pointer; } .aucmp div:hover, .aucmp .ausel { background: rgba(128,128,128,.1); } @media (min-width: 760px) { body { max-width: 820px; margin: 0 auto; font: 14px/1.4 sans-serif; } .y, .s { font: 13px sans-serif; } ul.m { list-style-type: none; padding: 0; opacity: .8; line-height: inherit; } ul.m li { display: inline; margin-right: 1em; } ul.m a { color: inherit; } .ifnm { display: block; } .ifm { display: none; } } @media (min-width: 760px) and (max-resolution: 1dppx) { .win body { font: 13px/1.4 verdana, sans-serif; } } @media (prefers-color-scheme: dark) and (max-width: 760px) { body, .basecl { background: #242424; color: #ccc; color-scheme: dark; } a:visited { color: inherit; } a:link, a.lc, .lc { color: #fff; } .bg1 { background: #444; } .bg0 { background: #444; } } </style> <script> if (/Windows|X11/.test(navigator.userAgent)) document.documentElement.className = 'win'; </script> </head> <body> <div class=\"ifnm\" style=\"margin: .5em 0 1.25em;\"> <a class=\"bg0\" href=\"/\" style=\"float: left; color: #fff; border-radius: 3px; padding: 0 2.1em 4px; font: bold 26px Verdana, sans-serif; text-decoration: none; margin-right: .7em; \">SJP</a> <form style=\"margin: 0;\" action=\"/sl/zg.phtml\" method=\"post\"> <div style=\"display: inline-block; position: relative; width: 34%;\"><input id=\"inp1\" accesskey=\"s\" tabindex=\"1\" autocomplete=\"off\" style=\"margin: 0; width: 100%; box-sizing: border-box; padding: 7px 4px;\" name=\"sl\" autofocus ></input><div class=\"aucmp basecl\"></div></div> <button style=\"margin-left: 0; padding: 7px 12px;\">sprawdź</button> </form> </div> <div class=\"ifm bg0\" style=\"margin: -15px -15px 0; color: #fff; opacity: .9; text-align: center; font: bold 18px/44px sans-serif; padding-top: 2px; position: relative;\"><a href=\"#\" onclick=\"a=document.getElementById('mblock'); if(a) a.className=(a.className?'':'ifnm'); return false;\" style=\"position: absolute; left: 0; top: 0; width: 54px;\"><svg style=\"fill: #fff; width: 24px; height: 24px; vertical-align: middle;\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M0 0h24v24H0z\" fill=\"none\"></path><path d=\"M0 5h22v2.2H0z m0 6h22v2.2H0z m0 6h22v2.2H0z\"></path></svg></a><a title=\"LOSUJ\" rel=\"nofollow\" href=\"/sl/los/\" style=\"position: absolute; right: 0; opacity: .7; padding: 0 15px; margin-top: -1px; color: inherit;\"><svg style=\"fill: currentColor; width: 15px; height: 15px; vertical-align: middle;\" viewBox=\"0 0 18 18\" xmlns=\"http://www.w3.org/2000/svg\"> <rect x=\"1\" y=\"1\" width=\"16\" height=\"16\" rx=\"2\" ry=\"2\" stroke-width=\"1.25\" stroke=\"currentColor\" fill=\"transparent\"></rect> <circle cx=\"6\" cy=\"6\" r=\"1.25\"></circle> <circle cx=\"12\" cy=\"6\" r=\"1.25\"></circle> <circle cx=\"9\" cy=\"9\" r=\"1.25\"></circle> <circle cx=\"6\" cy=\"12\" r=\"1.25\"></circle> <circle cx=\"12\" cy=\"12\" r=\"1.25\"></circle> </svg></a>SŁOWNIK SJP</div> <div class=\"ifnm\" id=\"mblock\"> <ul class=\"m\"><li><a href=\"/\">słownik języka polskiego sjp</a></li><li><a href=\"/sl/lp.phtml\">lista</a></li><li><a href=\"/sl/ok.phtml\">komentarze</a></li><li><a href=\"/sl/po.phtml\">więcej</a></li><li class=\"ifnm\"><a title=\"LOSUJ\" rel=\"nofollow\" href=\"/sl/los/\" style=\"padding: .1em .6em; line-height: .8; vertical-align: sub;\">*</a></li></ul> <hr class=\"ifnm\" style=\"margin: 1.25em 0 2em;\" /> </div> <form class=\"ifm\" action=\"/sl/zg.phtml\" method=\"post\"> <table style=\"margin: 15px 0 20px;\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"top\" style=\"position: relative;\"><input id=\"inp2\" autocomplete=\"off\" name=\"sl\" style=\"padding: 7px 4px; box-sizing: border-box; width: 100%;\" autocapitalize=\"off\" /><div class=\"aucmp basecl\"></div><div class=\"clx\" style=\"position: absolute; right: 0; top: 50%; transform: translateY(-50%); padding: 6px 10px; opacity: .3;\" onclick=\"xin=document.getElementById('inp2');xin.value='';xin.focus();return false;\">X</div></td><td valign=\"top\" width=\"1%\" style=\"padding-left: 4px;\"><button style=\"padding: 7px 12px;\">sprawdź</button></td></tr></table> </form> <h1>Słownik SJP.PL</h1> <p>Słownik języka polskiego, ortograficzny, wyrazów obcych i słownik do gier w jednym.</p> <button onclick=\"this.style.display='none'; this.nextElementSibling.style.display='block'; return false;\" style=\"padding: 5px 0; border: none; cursor: pointer;\">więcej...</button> <div style=\"display: none;\"> <p>Słownik jest rozwijany z myślą o zastosowaniu do sprawdzania pisowni w programach open-source, do gier słownych (np. <a href=\"https://www.kurnik.pl/literaki/\">literaki</a>) i do użytku online jako kilka rodzajów słowników w jednym.</p> <p>Redakcją słownika zajmują się hobbyści.</p> <p>Słownik jest udostępniany na otwartych licencjach (różnych w zależności od wersji).</p> <p>Pierwsza wersja (słownik alternatywny) powstała na bazie dawnego słownika do ispella.</p> <p>Kontakt w sprawach technicznych: sjpslownik@gmail.com</p> <p>&copy; Zespół SJP.PL</p> </div> <script> function auc(a,k){function e(){b.innerHTML=\"\";b.style.display=\"none\";g=!0;f++}function l(d){var c=new XMLHttpRequest;c.onreadystatechange=function(){if(4==c.readyState&&200==c.status&&f==d){var a=JSON.parse(c.responseText);b.innerHTML=\"\";for(var e=0;e<a.d.length;e++)b.innerHTML+=\"<div>\"+a.d[e]+\"</div>\";g=0==a.d.length;b.style.display=g?\"none\":\"block\"}};c.open(\"GET\",\"/sl/s/?q=\"+encodeURIComponent(a.value),!0);c.send()}if(a){var b=a.nextSibling;if(b){var f= 0,g=!1;a.onblur=function(a){e()};a.onkeydown=function(d){if(g)return!0;if(27==d.keyCode)return e(),!1;if(40!=d.keyCode&&38!=d.keyCode||!b.firstChild)return!0;var c=b.querySelector(\".ausel\");d=40==d.keyCode;if(c){c.className=\"\";var h=d?c.nextSibling:c.previousSibling}h||(h=d?b.firstChild:b.lastChild);h.className=\"ausel\";a.value=h.innerText;f++;return!1};b.onmousedown=function(d){if(d.target.parentNode==b)return a.value=d.target.innerText,a.form.submit(),!1};a.oninput=function(b){var c=++f;a.value.length? setTimeout(function(){f==c&&l(c)},k):e()}}}}auc(document.getElementById(\"inp1\"),150);auc(document.getElementById(\"inp2\"),250); </script> <script> document.addEventListener(\"keydown\", function(e) { if (e.key!==\"/\"||e.ctrlKey||e.metaKey||e.altKey) return; if (/^(?:input|textarea|select|button)$/i.test(e.target.tagName)) return; e.preventDefault(); var i1=document.getElementById(\"inp1\"); if (!i1) return; var il=i1.value.length; i1.setSelectionRange(il,il); i1.focus(); }); </script> </body> </html> ";
assertEquals(mockCurl,reader.getCurlOutput("https://www.sjp.pl"));
}
}
2 changes: 1 addition & 1 deletion test/CurlValidatorTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sjpAPI;
package sjpapi.api;

import junit.framework.TestCase;

Expand Down
15 changes: 0 additions & 15 deletions test/CurlWrapperTest.java

This file was deleted.

2 changes: 1 addition & 1 deletion test/SjpValidatorTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sjpAPI;
package sjpapi.api;

import junit.framework.TestCase;

Expand Down
Loading

0 comments on commit d528996

Please sign in to comment.