Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add e2e tests for java and scala #4

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autotests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Running the e2e tests from its GitHub source code requires:
* chrome browser (80 or higher)
* [conda](https://www.anaconda.com/download/)
* java (1.8 or higher) and Gradle (5.2 or higher)
* [psutil](https://pypi.org/project/psutil/)
* any beakerx kernel

## Run the tests
Expand Down
285 changes: 285 additions & 0 deletions autotests/ipynb/java/JavaTest.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import java.util.Date;\n",
"import java.text.SimpleDateFormat;\n",
"\n",
"public class BeakerxTest {\n",
" private Date _date;\n",
" private SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mmZ\");\n",
" \n",
" public BeakerxTest() {\n",
" _date = new Date();\n",
" }\n",
"\n",
" public String getDateTxt() {\n",
" return \"Today:\" + sdf.format(_date);\n",
" }\n",
"\n",
" public String getDateUpperCaseTxt() {\n",
" return getDateTxt().toUpperCase();\n",
" }\n",
"}\n",
"BeakerxTest.class.getSimpleName()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"BeakerxTest bt = new BeakerxTest();\n",
"bt.getDateUpperCaseTxt();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import java.util.List;\n",
"import java.util.ArrayList;\n",
"import beakerx.chart.xychart.Plot;\n",
"import beakerx.chart.xychart.plotitem.*;\n",
"import beakerx.chart.Color;\n",
"\n",
"Plot p = new Plot();\n",
"\n",
"p.setTitle(\"this is a Java plot\");\n",
"\n",
"Bars b = new Bars();\n",
"\n",
"List<Number> yList = new ArrayList<Number>();\n",
"yList.add(2);\n",
"yList.add(5);\n",
"yList.add(4);\n",
"yList.add(8);\n",
"\n",
"b.setY(yList);\n",
"b.setColor(Color.blue);\n",
"b.setWidth(0.5);\n",
"\n",
"p.add(b);\n",
" \n",
"p;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"interface DateGetter {\n",
" public String getDateTxt();\n",
"}\n",
"DateGetter.class.getSimpleName()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"public class DG2 extends BeakerTest implements DateGetter {\n",
"}\n",
"DG2.class.getSimpleName()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%classpath add jar ../../../doc/resources/jar/BeakerXClasspathTest.jar"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"System.out.println(\"The Groovy working folder is :\");\n",
"System.out.println(java.nio.file.Paths.get(\".\").toAbsolutePath().normalize().toString());\n",
"System.out.println(\"BeakerXClasspathTest.jar exists in this folder\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import com.beaker.BeakerXClasspathTest;\n",
"\n",
"BeakerXClasspathTest t = new BeakerXClasspathTest();\n",
"System.out.println(com.beaker.BeakerXClasspathTest.staticTest);\n",
"System.out.println(t.getObjectTest());"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%python\n",
"from beakerx import *\n",
"pp = Plot(title=\"Title\", xLabel=\"Horizontal\", yLabel=\"Vertical\")\n",
"pp.add(Line(displayName=\"Line\", x=[1, 4, 6, 8, 10],y=[3, 6, 4, 5, 9]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"press 'Tab' for autocomplete"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"press 'Shift' + 'Tab' for doc"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Output usage"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import beakerx.widget.Output;\n",
"Output out2 = new Output();\n",
"OutputManager.setOutput(out2);\n",
"out2;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import static java.lang.System.out;\n",
"\n",
"Thread t = new Thread(() -> {\n",
" out.println(\"Some output init\");\n",
" try {\n",
" Thread.sleep(2000);\n",
" } catch (InterruptedException e) {\n",
" }\n",
" for (int i = 0; i <10 ; i++){\n",
" out.println(\"Some output \"+ i); \n",
" }\n",
"});\n",
"out.println(\"Start\");\n",
"t.start();\n",
"//t.join();\n",
"out.println(\"end\");\n",
"\"Thread example result\";"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"OutputManager.clearOutput();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import static java.lang.System.out;\n",
"for (int i = 0; i <30 ; i++){\n",
" out.println(\"Done \"+ i); \n",
"}\n",
"return 3+5;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"OutputManager.setOutput(null);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Java11",
"language": "java",
"name": "java"
},
"language_info": {
"codemirror_mode": "text/x-java",
"file_extension": ".java",
"mimetype": "",
"name": "Java",
"nbconverter_exporter": "",
"version": "11.0.1"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
90 changes: 90 additions & 0 deletions autotests/ipynb/scala/ScalaTest.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class Greeter(prefix: String, suffix: String) {\n",
" def greet(name: String): Unit =\n",
" println(prefix + name + suffix)\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"val greeter = new Greeter(\"Hello, \", \"!\")\n",
"greeter.greet(\"Scala developer\") // Hello, Scala developer!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%python\n",
"from beakerx import *\n",
"pp = Plot(title=\"Title\", xLabel=\"Horizontal\", yLabel=\"Vertical\")\n",
"pp.add(Line(displayName=\"Line\", x=[1, 4, 6, 8, 10],y=[3, 6, 4, 5, 9]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"press 'Tab' for autocomplete"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"press 'Shift' + 'Tab' for doc"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Scala",
"language": "scala",
"name": "scala"
},
"language_info": {
"codemirror_mode": "text/x-scala",
"file_extension": ".scala",
"mimetype": "",
"name": "Scala",
"nbconverter_exporter": "",
"version": "2.12.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion autotests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def kill_processes(name):
# kill unused processes
if platform.system() == 'Windows':
for proc in psutil.process_iter():
if proc.name() in ["jupyter-lab.exe", "jupyter.exe", "python.exe", "chromedriver.exe"]:
if proc.name() in ["jupyter-lab.exe", "jupyter.exe", "jupyter-notebook.exe", "chromedriver.exe"]:
print(proc)
os.kill(proc.pid, signal.SIGTERM)
else:
Expand Down
Loading