Last active
January 19, 2023 07:22
-
-
Save darkmastermindz/2716d0a1214209f2a4f4ea7a25e22c10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<title>ChatGPT Convo with Hansel (junit4readfromjson.html)</title> | |
<link rel="stylesheet" href="https://chat.openai.com/_next/static/css/f4f41a0ce0da0c77.css"> | |
</head> | |
<body> | |
<div class="react-scroll-to-bottom--css-orefo-79elbk h-full dark:bg-gray-800"> | |
<div class="react-scroll-to-bottom--css-orefo-1n7m0yu"> | |
<div class="flex flex-col items-center text-sm h-full dark:bg-gray-800"> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1c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qQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">give me an example | |
of a junit4 test class that reads input from a json file to be used for testing using GSON | |
and stores an ArrayList<Student> objects using standard JUnit 4 template setUpClass(), | |
tearDownClass(), setup(), and tearDown() then create a test case to test for name, email, | |
roles, and if admin is true or false </div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>Here is an example of a JUnit 4 test class that reads input from a JSON file using GSON | |
and stores an ArrayList of Student objects:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.google.gson.Gson; | |
<span class="hljs-keyword">import</span> com.google.gson.reflect.TypeToken; | |
<span class="hljs-keyword">import</span> org.junit.AfterClass; | |
<span class="hljs-keyword">import</span> org.junit.BeforeClass; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.io.FileReader; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertTrue; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> ArrayList<Student> students; | |
<span class="hljs-meta">@BeforeClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">setUpClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
students = gson.fromJson(<span class="hljs-keyword">new</span> <span class="hljs-title class_">FileReader</span>(<span class="hljs-string">"students.json"</span>), <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
<span class="hljs-meta">@AfterClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">tearDownClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
students = <span class="hljs-literal">null</span>; | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testName</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"John Smith"</span>, students.get(<span class="hljs-number">0</span>).getName()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testEmail</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"[email protected]"</span>, students.get(<span class="hljs-number">0</span>).getEmail()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testRoles</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).getRoles().contains(<span class="hljs-string">"student"</span>)); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testAdmin</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).isAdmin()); | |
} | |
} | |
</code></div></div></pre> | |
<p>This example assumes that the <code>Student</code> class has appropriate getters for | |
<code>name</code>, <code>email</code>, <code>roles</code>, and <code>admin</code>. The | |
<code>students.json</code> file should contain a json representation of the ArrayList | |
of Student objects.</p> | |
<p>The <code>setUpClass</code> method is run once before any of the test methods are | |
executed. It uses GSON to parse the JSON file and store the students in the | |
<code>students</code> field. The <code>tearDownClass</code> method is run once after | |
all of the test methods have completed, and it sets the <code>students</code> field to | |
<code>null</code>.</p> | |
<p>The <code>testName</code>, <code>testEmail</code>, <code>testRoles</code>, | |
<code>testAdmin</code> methods are the test cases that test for the name, email, roles, | |
and if admin is true or false respectively.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD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4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">assume | |
StudentTest.java is in src/test/java/model package and json file is in src/test/resources | |
package</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>Here is an updated version of the JUnit 4 test class that takes into account the | |
specified file locations:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.google.gson.Gson; | |
<span class="hljs-keyword">import</span> com.google.gson.reflect.TypeToken; | |
<span class="hljs-keyword">import</span> org.junit.AfterClass; | |
<span class="hljs-keyword">import</span> org.junit.BeforeClass; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.io.File; | |
<span class="hljs-keyword">import</span> java.io.FileReader; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertTrue; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> ArrayList<Student> students; | |
<span class="hljs-meta">@BeforeClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">setUpClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
<span class="hljs-type">File</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">File</span>(<span class="hljs-string">"src/test/resources/students.json"</span>); | |
students = gson.fromJson(<span class="hljs-keyword">new</span> <span class="hljs-title class_">FileReader</span>(jsonFile), <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
<span class="hljs-meta">@AfterClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">tearDownClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
students = <span class="hljs-literal">null</span>; | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testName</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"John Smith"</span>, students.get(<span class="hljs-number">0</span>).getName()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testEmail</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"[email protected]"</span>, students.get(<span class="hljs-number">0</span>).getEmail()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testRoles</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).getRoles().contains(<span class="hljs-string">"student"</span>)); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testAdmin</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).isAdmin()); | |
} | |
} | |
</code></div></div></pre> | |
<p>This version of the test class will look for the json file in the | |
<code>src/test/resources</code> package. The <code>File</code> constructor takes a | |
string argument that is the file path, in this case | |
<code>"src/test/resources/students.json"</code>. | |
It will work as long as the file is located in the specified folder, otherwise it will | |
throw a <code>FileNotFoundException</code></p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-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yZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">doesn't | |
annotations in junit account for exceptions?</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>Yes, JUnit provides several annotations that can be used to handle exceptions in test | |
methods.</p> | |
<p><code>@Test(expected = Exception.class)</code> annotation can be used to indicate that | |
a test method should throw an exception of a specific type. If the test method does not | |
throw the expected exception, the test will fail.</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"> <span class="hljs-meta">@Test(expected = FileNotFoundException.class)</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testFileNotFound</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-type">File</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">File</span>(<span class="hljs-string">"src/test/resources/students.json"</span>); | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
students = gson.fromJson(<span class="hljs-keyword">new</span> <span class="hljs-title class_">FileReader</span>(jsonFile), <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
</code></div></div></pre> | |
<p><code>@Test(expected = Exception.class)</code> can also be used with a try-catch block | |
</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"> <span class="hljs-meta">@Test(expected = FileNotFoundException.class)</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testFileNotFound</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-keyword">try</span> { | |
<span class="hljs-type">File</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">File</span>(<span class="hljs-string">"src/test/resources/students.json"</span>); | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
students = gson.fromJson(<span class="hljs-keyword">new</span> <span class="hljs-title class_">FileReader</span>(jsonFile), <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} <span class="hljs-keyword">catch</span> (FileNotFoundException e) { | |
<span class="hljs-keyword">throw</span> e; | |
} | |
} | |
</code></div></div></pre> | |
<p>Alternatively, <code>@Rule</code> and <code>ExpectedException</code> can be used to | |
test for exceptions.</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> org.junit.Rule; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> org.junit.rules.ExpectedException; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-meta">@Rule</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-type">ExpectedException</span> <span class="hljs-variable">thrown</span> <span class="hljs-operator">=</span> ExpectedException.none(); | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testFileNotFound</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
thrown.expect(FileNotFoundException.class); | |
<span class="hljs-type">File</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">File</span>(<span class="hljs-string">"src/test/resources/students.json"</span>); | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
students = gson.fromJson(<span class="hljs-keyword">new</span> <span class="hljs-title class_">FileReader</span>(jsonFile), <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
} | |
</code></div></div></pre> | |
<p>By using <code>@Rule</code> and <code>ExpectedException</code>, you can test the | |
exception message and assert it too.</p> | |
<p>It's worth noting that, when it comes to testing the exceptions it's best to use the | |
<code>assertThrows</code> method provided by JUnit5, this method is more readable and | |
expressive.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DW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oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">assume the use of | |
Thread.currentThread().getContextClassLoader().getResourceAsStream() to get json file</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>Here is an updated version of the JUnit 4 test class that uses | |
<code>Thread.currentThread().getContextClassLoader().getResourceAsStream()</code> to | |
get the JSON file:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.google.gson.Gson; | |
<span class="hljs-keyword">import</span> com.google.gson.reflect.TypeToken; | |
<span class="hljs-keyword">import</span> org.junit.AfterClass; | |
<span class="hljs-keyword">import</span> org.junit.BeforeClass; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.io.InputStreamReader; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertTrue; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> ArrayList<Student> students; | |
<span class="hljs-meta">@BeforeClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">setUpClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
<span class="hljs-type">InputStreamReader</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">InputStreamReader</span>(Thread.currentThread().getContextClassLoader().getResourceAsStream(<span class="hljs-string">"students.json"</span>)); | |
students = gson.fromJson(jsonFile, <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
<span class="hljs-meta">@AfterClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">tearDownClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
students = <span class="hljs-literal">null</span>; | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testName</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"John Smith"</span>, students.get(<span class="hljs-number">0</span>).getName()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testEmail</span><span class="hljs-params">()</span> { | |
assertEquals(<span class="hljs-string">"[email protected]"</span>, students.get(<span class="hljs-number">0</span>).getEmail()); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testRoles</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).getRoles().contains(<span class="hljs-string">"student"</span>)); | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testAdmin</span><span class="hljs-params">()</span> { | |
assertTrue(students.get(<span class="hljs-number">0</span>).isAdmin()); | |
} | |
} | |
</code></div></div></pre> | |
<p>The | |
<code>Thread.currentThread().getContextClassLoader().getResourceAsStream("students.json")</code> | |
method returns an input stream that reads the <code>students.json</code> file. It is | |
then wrapped with an InputStreamReader, which is passed to GSON's <code>fromJson</code> | |
method to parse the JSON file and store the students in the <code>students</code> | |
field. | |
This way of reading the file is different from the previous one, it doesn't need the | |
file path to be specified as it reads the file relative to the classpath, this means | |
that the file needs to be in the classpath, this is useful when the file is packaged in | |
a jar file. | |
It's worth noting that when using <code>getResourceAsStream()</code> it's always | |
looking for the file in classpath, so it's better to use the path relative to classpath | |
and not the filesystem path.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND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ptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">Does java include | |
src/test/resources in classpath by default when building with gradle?</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>By default, Gradle includes the <code>src/main/resources</code> and | |
<code>src/test/resources</code> directories in the classpath when building a Java | |
project. | |
This means that any files in these directories will be included in the classpath and | |
can be accessed via the classloader using | |
<code>Thread.currentThread().getContextClassLoader().getResourceAsStream()</code> | |
method as we have seen in the previous example. | |
You can also access the files in these directories by using the | |
<code>getResource()</code> method of the classloader, this method returns a URL that | |
can be used to read the resource. | |
This way of reading the files is useful when the file is packaged in a jar file.</p> | |
<p>It's worth noting that the files in the <code>src/test/resources</code> directory are | |
not included in the final artifact, this means that if you want the files to be part of | |
your final jar, you should move them to <code>src/main/resources</code>.</p> | |
<p>In addition, if you want to include additional directories in the classpath, you can | |
use the <code>sourceSets</code> block in your <code>build.gradle</code> file to specify | |
additional directories to include.</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-bash">sourceSets { | |
<span class="hljs-built_in">test</span> { | |
resources { | |
srcDir <span class="hljs-string">'src/test/resources'</span> | |
} | |
} | |
} | |
</code></div></div></pre> | |
<p>This way you can specify other directories to be included in the classpath.</p> | |
<p>In summary, <code>src/test/resources</code> is included in the classpath by default | |
when building a Java project with Gradle. This allows you to access files in this | |
directory using the classloader, and you can use the <code>sourceSets</code> block to | |
include additional directories in the classpath if needed.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73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_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">explain to me the | |
difference between @BeforeClass setupClass() and @Before setUp(), @AfterClass tearDownClass() | |
and @After tearDown() usage with above context</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>In JUnit, the <code>@BeforeClass</code> annotation is used to indicate that a method | |
should be run once before any of the test methods in the class are executed. This | |
method is typically used to set up any resources that are needed for the test class as | |
a whole, such as initializing a shared object or loading a file that will be used by | |
multiple test methods.</p> | |
<p>The <code>@AfterClass</code> annotation is used to indicate that a method should be run | |
once after all of the test methods in the class have completed. This method is | |
typically used to clean up any resources that were set up in the | |
<code>@BeforeClass</code> method, such as releasing a shared object or closing a file. | |
</p> | |
<p>On the other hand, the <code>@Before</code> annotation is used to indicate that a | |
method should be run before each individual test method is executed. This method is | |
typically used to set up any resources that are needed for a single test, such as | |
creating a new object or initializing a variable.</p> | |
<p>The <code>@After</code> annotation is used to indicate that a method should be run | |
after each individual test method has completed. This method is typically used to clean | |
up any resources that were set up in the <code>@Before</code> method, such as deleting | |
an object or resetting a variable.</p> | |
<p>In the case of the example provided, the <code>setUpClass</code> method reads the json | |
file, parse it and store the students in the <code>students</code> field, this is a | |
resource that will be used by all the test methods in the class, so it makes sense to | |
do this setup once before any of the test methods are executed, that's why this method | |
is annotated with <code>@BeforeClass</code>.</p> | |
<p>The <code>tearDownClass</code> method is used to clean up the resource created in the | |
<code>setUpClass</code>, it sets the <code>students</code> field to <code>null</code>, | |
this is done only once after all the test methods have completed, that's why this | |
method is annotated with <code>@AfterClass</code>.</p> | |
<p>In this example there are no use of <code>setUp</code> and <code>tearDown</code> | |
methods, as the test methods don't need any additional setup or clean up for each test | |
method. But if for example, the test methods need to create a new object from | |
<code>students</code> each time, then it would make sense to use <code>setUp</code> and | |
<code>tearDown</code> methods to do this setup and clean up for each test method.</p> | |
<p>In summary, <code>@BeforeClass</code> and <code>@AfterClass</code> methods are used to | |
set up and clean up resources that are shared among all test methods within a test | |
class, while <code>@Before</code> and <code>@After</code> methods are used to set up | |
and clean up resources that are specific to a single test method.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-c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Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">okay, now give me | |
a JUnit4 integration test example with context above of sending a request to a StudentService | |
with the json items assuming there's a StudentRequest class with method | |
sendRequest(ArrayList<Student> students) returning a StudentResponse soap object. | |
retrieve the response tag in the object and compare the output to a hardcoded expected output | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>Here is an example of a JUnit 4 integration test that sends a request to a | |
<code>StudentService</code> using an <code>ArrayList</code> of <code>Student</code> | |
objects, retrieves the response and compares it to a hardcoded expected output:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.example.model.Student; | |
<span class="hljs-keyword">import</span> com.example.model.StudentRequest; | |
<span class="hljs-keyword">import</span> com.example.model.StudentResponse; | |
<span class="hljs-keyword">import</span> org.junit.AfterClass; | |
<span class="hljs-keyword">import</span> org.junit.BeforeClass; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentServiceTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> ArrayList<Student> students; | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">StudentService</span> <span class="hljs-variable">studentService</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentService</span>(); | |
<span class="hljs-meta">@BeforeClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">setUpClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
<span class="hljs-type">Gson</span> <span class="hljs-variable">gson</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Gson</span>(); | |
<span class="hljs-type">InputStreamReader</span> <span class="hljs-variable">jsonFile</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">InputStreamReader</span>(Thread.currentThread().getContextClassLoader().getResourceAsStream(<span class="hljs-string">"students.json"</span>)); | |
students = gson.fromJson(jsonFile, <span class="hljs-keyword">new</span> <span class="hljs-title class_">TypeToken</span><ArrayList<Student>>(){}.getType()); | |
} | |
<span class="hljs-meta">@AfterClass</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">tearDownClass</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
students = <span class="hljs-literal">null</span>; | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testStudentService</span><span class="hljs-params">()</span> { | |
<span class="hljs-type">StudentRequest</span> <span class="hljs-variable">request</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentRequest</span>(); | |
<span class="hljs-type">StudentResponse</span> <span class="hljs-variable">response</span> <span class="hljs-operator">=</span> request.sendRequest(students); | |
<span class="hljs-type">String</span> <span class="hljs-variable">responseTag</span> <span class="hljs-operator">=</span> response.getResponseTag(); | |
<span class="hljs-type">String</span> <span class="hljs-variable">expectedResponseTag</span> <span class="hljs-operator">=</span> <span class="hljs-string">"Success"</span>; | |
assertEquals(expectedResponseTag, responseTag); | |
} | |
} | |
</code></div></div></pre> | |
<p>This test class sends a request to the <code>StudentService</code> using an | |
<code>ArrayList</code> of <code>Student</code> objects and retrieves a | |
<code>StudentResponse</code> object. It then retrieves the <code>responseTag</code> | |
from the <code>StudentResponse</code> object and compares it to the hardcoded expected | |
output "Success".</p> | |
<p>The <code>setUpClass</code> method is used to read the json file, parse it, and store | |
the students in the <code>students</code> field. The <code>tearDownClass</code> method | |
is used to clean up the resource created in the <code>setUpClass</code>. This is done | |
only once before and after all the test methods have completed.</p> | |
<p>The <code>testStudentService</code> method is the test case that sends the request to | |
the <code>StudentService</code> and compares the responseTag to the expected output. | |
</p> | |
<p>It's worth noting that you should use this kind of test when you want to test the | |
integration</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj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7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">make it so this | |
integration test extends the previous test</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>You can make the integration test class extend the previous test class to reuse the | |
setup and cleanup methods by using the <code>extends</code> keyword. | |
Here is an example of how the integration test class would look like:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.example.model.Student; | |
<span class="hljs-keyword">import</span> com.example.model.StudentRequest; | |
<span class="hljs-keyword">import</span> com.example.model.StudentResponse; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentServiceTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">StudentService</span> <span class="hljs-variable">studentService</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentService</span>(); | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testStudentService</span><span class="hljs-params">()</span> { | |
<span class="hljs-type">StudentRequest</span> <span class="hljs-variable">request</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentRequest</span>(); | |
<span class="hljs-type">StudentResponse</span> <span class="hljs-variable">response</span> <span class="hljs-operator">=</span> request.sendRequest(students); | |
<span class="hljs-type">String</span> <span class="hljs-variable">responseTag</span> <span class="hljs-operator">=</span> response.getResponseTag(); | |
<span class="hljs-type">String</span> <span class="hljs-variable">expectedResponseTag</span> <span class="hljs-operator">=</span> <span class="hljs-string">"Success"</span>; | |
assertEquals(expectedResponseTag, responseTag); | |
} | |
} | |
</code></div></div></pre> | |
<p>This test class extends the <code>StudentTest</code> class, so it inherits the | |
<code>setUpClass</code> and <code>tearDownClass</code> methods. The | |
<code>setUpClass</code> method is used to read the json file, parse it, and store the | |
students in the <code>students</code> field. The <code>tearDownClass</code> method is | |
used to clean up the resource created in the <code>setUpClass</code>. This is done only | |
once before and after all the test methods have completed.</p> | |
<p>The <code>testStudentService</code> method is the new test case that sends the request | |
to the <code>StudentService</code> and compares the responseTag to the expected output. | |
</p> | |
<p>This way you can reuse the setup and cleanup methods of the previous test class, and | |
you can also add new test cases in the new class to test other functionalities. | |
It's worth noting that if you want to add more test methods to the previous class, you | |
don't need to repeat the setup and cleanup methods, they are already inherited by the | |
new class.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6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14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">assume there's a | |
producer and consumer pattern when generating request and response payloads</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>If you are using a producer and consumer pattern to generate request and response | |
payloads in your integration test, you can use the <code>@Before</code> and | |
<code>@After</code> annotations to set up and tear down the producer and consumer | |
objects before and after each test method, respectively. Here is an example of how the | |
integration test class would look like:</p> | |
<pre><div class="bg-black mb-4 rounded-md"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans"><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre-wrap hljs language-java"><span class="hljs-keyword">import</span> com.example.model.Student; | |
<span class="hljs-keyword">import</span> com.example.model.StudentRequest; | |
<span class="hljs-keyword">import</span> com.example.model.StudentResponse; | |
<span class="hljs-keyword">import</span> org.junit.After; | |
<span class="hljs-keyword">import</span> org.junit.Before; | |
<span class="hljs-keyword">import</span> org.junit.Test; | |
<span class="hljs-keyword">import</span> java.util.ArrayList; | |
<span class="hljs-keyword">import</span> <span class="hljs-keyword">static</span> org.junit.Assert.assertEquals; | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">StudentServiceTest</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">StudentTest</span> { | |
<span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-type">StudentService</span> <span class="hljs-variable">studentService</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentService</span>(); | |
<span class="hljs-keyword">private</span> StudentRequestProducer requestProducer; | |
<span class="hljs-keyword">private</span> StudentResponseConsumer responseConsumer; | |
<span class="hljs-meta">@Before</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">setUp</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
requestProducer = <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentRequestProducer</span>(); | |
responseConsumer = <span class="hljs-keyword">new</span> <span class="hljs-title class_">StudentResponseConsumer</span>(); | |
} | |
<span class="hljs-meta">@After</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">tearDown</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception { | |
requestProducer = <span class="hljs-literal">null</span>; | |
responseConsumer = <span class="hljs-literal">null</span>; | |
} | |
<span class="hljs-meta">@Test</span> | |
<span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">testStudentService</span><span class="hljs-params">()</span> { | |
<span class="hljs-type">StudentRequest</span> <span class="hljs-variable">request</span> <span class="hljs-operator">=</span> requestProducer.createRequest(students); | |
<span class="hljs-type">StudentResponse</span> <span class="hljs-variable">response</span> <span class="hljs-operator">=</span> studentService.sendRequest(request); | |
responseConsumer.consumeResponse(response); | |
<span class="hljs-type">String</span> <span class="hljs-variable">responseTag</span> <span class="hljs-operator">=</span> responseConsumer.getResponseTag(); | |
<span class="hljs-type">String</span> <span class="hljs-variable">expectedResponseTag</span> <span class="hljs-operator">=</span> <span class="hljs-string">"Success"</span>; | |
assertEquals(expectedResponseTag, responseTag); | |
} | |
} | |
</code></div></div></pre> | |
<p>The <code>setUp</code> method is used to instantiate the | |
<code>StudentRequestProducer</code> and <code>StudentResponseConsumer</code> objects | |
before each test method. The <code>tearDown</code> method is used to set the | |
<code>StudentRequestProducer</code> and <code>StudentResponseConsumer</code> objects to | |
<code>null</code> after each test method.</p> | |
<p>The <code>testStudentService</code> method uses the <code>StudentRequestProducer</code> | |
to create a <code>StudentRequest</code> object, send it to the | |
<code>StudentService</code> to get a <code>StudentResponse</code> object, and then | |
consume the response using <code>StudentResponseConsumer</code>. It then retrieves the | |
<code>responseTag</code> from the <code>StudentResponseConsumer</code> and compares it | |
to the hardcoded expected output "Success".</p> | |
<p>This way, you can use the producer and consumer pattern to separate the logic of | |
creating the request and consuming the response, and you can use the | |
<code>@Before</code> and <code>@After</code> annotations to set up and tear down the | |
producer and consumer objects for each test method.</p> | |
<p>It's</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMF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4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">continue</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>It's worth noting that the <code>setUpClass</code> and <code>tearDownClass</code> | |
methods from the <code>StudentTest</code> class are still being used to set up and | |
clean up the <code>students</code> field before and after all test methods are run. | |
This allows you to reuse the same <code>students</code> field for all test methods, | |
including the one in this integration test.</p> | |
<p>It's also worth mentioning that in this example, the | |
<code>StudentRequestProducer</code> and <code>StudentResponseConsumer</code> classes | |
are not provided and it's assumed that these classes exist and have the methods | |
specified in the example, you should implement them or adjust the test methods to use | |
the existing classes in your project.</p> | |
<p>In summary, when using a producer and consumer pattern in your integration test, you | |
can use the <code>@Before</code> and <code>@After</code> annotations to set up and tear | |
down the producer and consumer objects before and after each test method, respectively. | |
This allows you to separate the logic of creating the request and consuming the | |
response and reuse the setup and cleanup methods of the previous test class.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative flex"><span | |
style="box-sizing: border-box; display: inline-block; overflow: hidden; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span | |
style="box-sizing: border-box; display: block; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-width: 100%;"><img | |
alt="" aria-hidden="true" | |
src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e" | |
style="display: block; max-width: 100%; background-image: none; opacity: 1; border: 0px; margin: 0px; padding: 0px;"></span><img | |
alt="Hansel Wei" | |
srcset="/_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAD5-WCludGY5Sk-Uy50XXlqDH7C7fbjcD8RqjLfiFE-Wu0sGOTKw80_sqE7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=32&q=75 1x, /_next/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa-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E7RFnJmgpvvxmbjqbR3JDfY2taBrCSjbSqasTRTHoQ4x0rLSvZT_4u-W1cWwK-A6uKDDUjIKMFOIc76-j6JBG3TRj431780BaXnwTYuFA4M49hubhugOWm959I6oKE44FQ72WJF6WOYTxTW194VVfWnA_kp_5fN-zm-m7r9TAk3a8GekLND69k_x29igRAYhLHtisyZvqQ2rUE4DgQN97bXJ4F-TOj14FBuNeOed5orqgdMOD7H1I08Qunux1EQaP7yrGHrtiimxUHBff1RX3Z2x1J2DWq6Sc7sz312fqhqVHk365lFoWAjPkhptElwI5QCUdLTH-bFeQcqCG-qne0SY2MDsfQ90AazcCZ3szvrk1KfXs8M768Hs7wZXnkfdBzyv8FCMAahp0txm-VEPwyrDKoP0jAnKS9oZ73gdTJrFzlazP6_zJW-T73aOD0KK0qRPf0aXRJB17mkN1d1-SDZHMkP3W9oc6q6BHHXhEXz8KXRuuzwjbS8j1ATG7nOS8Aj3wBpuM_OzGCb8SjwFj9F9a-VZktalrwIVc2rO6UM0Rg-r4yhSSh_ve5guD1CZM0n11a6roXnKt3YFQnQe-qO0xHaBwh52Jx0sJ5KlNUqiGu4nNBx7EwHANU230712bOIPAS7odZa01y9cojbxIUjLe_3hF4FSfX-cRwg_vJKXSCAp2REijVRO_KklnmX6jbNCQsZHrOJI_tUMsiu-opCbPOnwygcYbm893fO3DHZX46Hd6c5viO6OSPfHf_VaPq1BCNDAqEQyRQKhD8RRpJ71xqPVCJaSvS5yOh5Ldf5kgHU-6eXQFw7wEI_p9BOQKOb798D0nV9d6HrIZWNQ_DRU_AFavvx2DJFRhCcRhPy2YrvsSbu_Df_RaAP7qciKiSSaXmm%3Ds96-c&w=64&q=75" | |
decoding="async" data-nimg="intrinsic" class="rounded-sm" | |
style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"></span> | |
</div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">Awesome job! Ty! | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:invisible md:group-hover:visible"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path> | |
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div | |
class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]"> | |
<div | |
class="text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"> | |
<div class="w-[30px] flex flex-col relative items-end"> | |
<div class="relative h-[30px] w-[30px] p-1 rounded-sm text-white flex items-center justify-center" | |
style="background-color: rgb(16, 163, 127);"><svg width="41" height="41" viewBox="0 0 41 41" | |
fill="none" xmlns="http://www.w3.org/2000/svg" stroke-width="1.5" class="h-6 w-6"> | |
<path | |
d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7909 35.6841C26.3872 37.0892 24.4838 37.8806 22.4978 37.8849ZM6.39227 31.0064C5.51397 29.4888 5.19742 27.7107 5.49804 25.9832C5.55718 26.0187 5.66048 26.0818 5.73461 26.1244L13.699 30.7248C13.8975 30.8408 14.1233 30.902 14.3532 30.902C14.583 30.902 14.8088 30.8408 15.0073 30.7248L24.731 25.1103V28.9979C24.7321 29.0177 24.7283 29.0376 24.7199 29.0556C24.7115 29.0736 24.6988 29.0893 24.6829 29.1012L16.6317 33.7497C14.9096 34.7416 12.8643 35.0097 10.9447 34.4954C9.02506 33.9811 7.38785 32.7263 6.39227 31.0064ZM4.29707 13.6194C5.17156 12.0998 6.55279 10.9364 8.19885 10.3327C8.19885 10.4013 8.19491 10.5228 8.19491 10.6071V19.808C8.19351 20.0378 8.25334 20.2638 8.36823 20.4629C8.48312 20.6619 8.64893 20.8267 8.84863 20.9404L18.5723 26.5542L15.206 28.4979C15.1894 28.5089 15.1703 28.5155 15.1505 28.5173C15.1307 28.5191 15.1107 28.516 15.0924 28.5082L7.04046 23.8557C5.32135 22.8601 4.06716 21.2235 3.55289 19.3046C3.03862 17.3858 3.30624 15.3413 4.29707 13.6194ZM31.955 20.0556L22.2312 14.4411L25.5976 12.4981C25.6142 12.4872 25.6333 12.4805 25.6531 12.4787C25.6729 12.4769 25.6928 12.4801 25.7111 12.4879L33.7631 17.1364C34.9967 17.849 36.0017 18.8982 36.6606 20.1613C37.3194 21.4244 37.6047 22.849 37.4832 24.2684C37.3617 25.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z" | |
fill="currentColor"></path> | |
</svg></div> | |
</div> | |
<div class="relative flex w-[calc(100%-50px)] md:flex-col lg:w-[calc(100%-115px)]"> | |
<div class="flex flex-grow flex-col gap-3"> | |
<div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap"> | |
<div class="markdown prose w-full break-words dark:prose-invert light"> | |
<p>You're welcome! I'm glad I could help. Let me know if you have any other question.</p> | |
</div> | |
</div> | |
</div> | |
<div | |
class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible"> | |
<button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"> | |
</path> | |
</svg></button><button | |
class="p-1 rounded-md hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" | |
stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" | |
xmlns="http://www.w3.org/2000/svg"> | |
<path | |
d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"> | |
</path> | |
</svg></button></div> | |
</div> | |
</div> | |
</div> | |
<div class="w-full h-48 flex-shrink-0"></div> | |
</div><button | |
class="cursor-pointer absolute right-6 bottom-[124px] md:bottom-[120px] z-10 rounded-full border border-gray-200 bg-gray-50 text-gray-600 dark:border-white/10 dark:bg-white/10 dark:text-gray-200"><svg | |
stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" | |
stroke-linejoin="round" class="h-4 w-4 m-1" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"> | |
<line x1="12" y1="5" x2="12" y2="19"></line> | |
<polyline points="19 12 12 19 5 12"></polyline> | |
</svg></button> | |
</div><button class="react-scroll-to-bottom--css-orefo-1tj0vk3 scroll-convo" type="button"></button> | |
</div> | |
</body> | |
<footer> | |
<div class="px-3 pt-2 pb-3 text-center text-xs text-black/50 dark:text-white/50 md:px-4 md:pt-3 md:pb-6"><a | |
href="https://help.openai.com/en/articles/6825453-chatgpt-release-notes" target="_blank" rel="noreferrer" | |
class="underline">ChatGPT Jan 9 Version</a>. Free Research Preview. Our goal is to make AI systems more natural | |
and safe to interact with. Your feedback will help us improve.</div> | |
</footer> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment