Some drafts
This commit is contained in:
parent
3b223dfea2
commit
76e1781864
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10
.idea/compiler.xml
generated
10
.idea/compiler.xml
generated
@ -1,6 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="19" />
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="app" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel target="1.6" />
|
||||
</component>
|
||||
</project>
|
16
.idea/jarRepositories.xml
generated
16
.idea/jarRepositories.xml
generated
@ -6,6 +6,11 @@
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
@ -16,20 +21,15 @@
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="akka-repository" />
|
||||
<option name="name" value="Akka library repository" />
|
||||
<option name="url" value="https://repo.akka.io/maven" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenLocal" />
|
||||
<option name="name" value="MavenLocal" />
|
||||
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
<option name="id" value="akka-repository" />
|
||||
<option name="name" value="Akka library repository" />
|
||||
<option name="url" value="https://repo.akka.io/maven" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -9,7 +9,7 @@
|
||||
</option>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="corretto-21" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="corretto-19" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
|
16
README.txt
16
README.txt
@ -1,12 +1,18 @@
|
||||
|
||||
Juego del bien público
|
||||
|
||||
Juego del bien público
|
||||
----------------------
|
||||
- Varios jugadores.
|
||||
- Reciben monedas al comienzo.
|
||||
- Hay un bote central
|
||||
- Cada turno se elige con cuántas monedas uno colabora al bote
|
||||
- Reciben N monedas al comienzo.
|
||||
- Hay un bote central.
|
||||
|
||||
- Cada turno se elige con cuántas monedas uno colabora al bote.
|
||||
- Entonces, el contenido del bote se multiplica por dos y se divide entre todos los jugadores.
|
||||
- Pasadas N rondas, el jugador se queda con lo que ganó + monedas iniciales.
|
||||
|
||||
|
||||
Comprobar cómo de dispuesta está la gente a contribuir a un bien, que será compartido por todos por igual,
|
||||
hayan contribuido o no.
|
||||
|
||||
-Un Chat genera una sesión para cada jugador.
|
||||
-Cada chat tiene 2 o más participantes.
|
||||
-Los chats tienen varios jugadores y ahí se juegan turnos.
|
25
build.gradle
25
build.gradle
@ -1,25 +0,0 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'application'
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven {
|
||||
url "https://repo.akka.io/maven"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.9.0'
|
||||
implementation 'ch.qos.logback:logback-classic:1.2.3'
|
||||
testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.9.0'
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
}
|
||||
|
||||
mainClassName = "com.example.AkkaQuickstart"
|
||||
|
||||
run {
|
||||
standardInput = System.in
|
||||
}
|
24
build.sbt
24
build.sbt
@ -1,24 +0,0 @@
|
||||
name := "akka-quickstart-java"
|
||||
|
||||
version := "1.0"
|
||||
|
||||
scalaVersion := "2.13.12"
|
||||
|
||||
lazy val akkaVersion = "2.9.0"
|
||||
|
||||
resolvers += "Akka library repository".at("https://repo.akka.io/maven")
|
||||
|
||||
// Run in a separate JVM, to make sure sbt waits until all threads have
|
||||
// finished before returning.
|
||||
// If you want to keep the application running while executing other
|
||||
// sbt tasks, consider https://github.com/spray/sbt-revolver/
|
||||
fork := true
|
||||
|
||||
resolvers += "Akka library repository".at("https://repo.akka.io/maven")
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
|
||||
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion,
|
||||
"ch.qos.logback" % "logback-classic" % "1.2.3",
|
||||
"junit" % "junit" % "4.13.1" % Test,
|
||||
"com.novocode" % "junit-interface" % "0.11" % Test)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,146 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
||||
<title>Test results - Class dev.freireservices.social_altruism.ChatQuickStartTest</title>
|
||||
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="../js/report.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>Class dev.freireservices.social_altruism.ChatQuickStartTest</h1>
|
||||
<div class="breadcrumbs">
|
||||
<a href="../index.html">all</a> >
|
||||
<a href="../packages/dev.freireservices.social_altruism.html">dev.freireservices.social_altruism</a> > ChatQuickStartTest</div>
|
||||
<div id="summary">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="summaryGroup">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="infoBox" id="tests">
|
||||
<div class="counter">2</div>
|
||||
<p>tests</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="failures">
|
||||
<div class="counter">0</div>
|
||||
<p>failures</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="ignored">
|
||||
<div class="counter">0</div>
|
||||
<p>ignored</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="duration">
|
||||
<div class="counter">0.944s</div>
|
||||
<p>duration</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox success" id="successRate">
|
||||
<div class="percent">100%</div>
|
||||
<p>successful</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tabs">
|
||||
<ul class="tabLinks">
|
||||
<li>
|
||||
<a href="#tab0">Tests</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab1">Standard output</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="tab0" class="tab">
|
||||
<h2>Tests</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Test</th>
|
||||
<th>Duration</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="success">testActorGetsUserDenied</td>
|
||||
<td class="success">0.856s</td>
|
||||
<td class="success">passed</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="success">testGreeterActorSendingOfGreeting</td>
|
||||
<td class="success">0.088s</td>
|
||||
<td class="success">passed</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tab1" class="tab">
|
||||
<h2>Standard output</h2>
|
||||
<span class="code">
|
||||
<pre>[2023-12-22 09:02:23,397] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
||||
[2023-12-22 09:02:23,552] [ERROR] [akka.actor.testkit.typed.internal.ActorTestKitGuardian$$anonfun$handleSpawnException$1] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user] - Spawn failed, props [EmptyProps]
|
||||
akka.actor.InvalidActorNameException: actor name [chatRoom] is not unique!
|
||||
at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:134)
|
||||
at akka.actor.dungeon.Children.reserveChild(Children.scala:147)
|
||||
at akka.actor.dungeon.Children.reserveChild$(Children.scala:145)
|
||||
at akka.actor.ActorCell.reserveChild(ActorCell.scala:410)
|
||||
at akka.actor.dungeon.Children.makeChild(Children.scala:300)
|
||||
at akka.actor.dungeon.Children.actorOf(Children.scala:49)
|
||||
at akka.actor.dungeon.Children.actorOf$(Children.scala:48)
|
||||
at akka.actor.ActorCell.actorOf(ActorCell.scala:410)
|
||||
at akka.actor.typed.internal.adapter.ActorRefFactoryAdapter$.spawn(ActorRefFactoryAdapter.scala:55)
|
||||
at akka.actor.typed.internal.adapter.ActorContextAdapter.spawn(ActorContextAdapter.scala:73)
|
||||
at akka.actor.testkit.typed.internal.ActorTestKitGuardian$.$anonfun$testKitGuardian$1(TestKitUtils.scala:35)
|
||||
at akka.actor.typed.internal.BehaviorImpl$ReceiveBehavior.receive(BehaviorImpl.scala:136)
|
||||
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
|
||||
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
|
||||
at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
|
||||
at akka.actor.typed.internal.adapter.GuardianStopInterceptor.aroundReceive(GuardianStartupBehavior.scala:59)
|
||||
at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
|
||||
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
|
||||
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
|
||||
at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
|
||||
at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:109)
|
||||
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
|
||||
at akka.actor.ActorCell.invoke(ActorCell.scala:547)
|
||||
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
|
||||
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
|
||||
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
|
||||
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
|
||||
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
|
||||
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
|
||||
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
|
||||
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
|
||||
[2023-12-22 09:02:23,640] [INFO] [akka.actor.LocalActorRef] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/$a] - Message [dev.freireservices.social_altruism.ChatRoom$GetSession] to Actor[akka://ChatQuickStartTest/user/$a#-835521502] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://ChatQuickStartTest/user/$a#-835521502] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
|
||||
[2023-12-22 09:02:23,665] [INFO] [akka.actor.CoordinatedShutdown] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [CoordinatedShutdown(akka://ChatQuickStartTest)] - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
|
||||
</pre>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p>
|
||||
<div>
|
||||
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
|
||||
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
|
||||
</label>
|
||||
</div>Generated by
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 22 dic 2023, 9:02:23</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,170 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
||||
<title>Test results - Class dev.freireservices.social_altruism.chat.ChatQuickStartTest</title>
|
||||
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="../js/report.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>Class dev.freireservices.social_altruism.chat.ChatQuickStartTest</h1>
|
||||
<div class="breadcrumbs">
|
||||
<a href="../index.html">all</a> >
|
||||
<a href="../packages/dev.freireservices.social_altruism.chat.html">dev.freireservices.social_altruism.chat</a> > ChatQuickStartTest</div>
|
||||
<div id="summary">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="summaryGroup">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="infoBox" id="tests">
|
||||
<div class="counter">1</div>
|
||||
<p>tests</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="failures">
|
||||
<div class="counter">1</div>
|
||||
<p>failures</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="ignored">
|
||||
<div class="counter">0</div>
|
||||
<p>ignored</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="duration">
|
||||
<div class="counter">10.961s</div>
|
||||
<p>duration</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox failures" id="successRate">
|
||||
<div class="percent">0%</div>
|
||||
<p>successful</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tabs">
|
||||
<ul class="tabLinks">
|
||||
<li>
|
||||
<a href="#tab0">Failed tests</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab1">Tests</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab2">Standard output</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="tab0" class="tab">
|
||||
<h2>Failed tests</h2>
|
||||
<div class="test">
|
||||
<a name="testGreeterActorSendingOfGreeting"></a>
|
||||
<h3 class="failures">testGreeterActorSendingOfGreeting</h3>
|
||||
<span class="code">
|
||||
<pre>java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
||||
at dev.freireservices.social_altruism.chat.ChatQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
||||
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
|
||||
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
|
||||
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
|
||||
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
|
||||
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
|
||||
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
|
||||
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
|
||||
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
|
||||
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
|
||||
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
|
||||
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
||||
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:57)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
|
||||
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
|
||||
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
|
||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
|
||||
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
|
||||
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
|
||||
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
|
||||
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
|
||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
|
||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
|
||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
|
||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
|
||||
</pre>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab1" class="tab">
|
||||
<h2>Tests</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Test</th>
|
||||
<th>Duration</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="failures">testGreeterActorSendingOfGreeting</td>
|
||||
<td class="failures">10.961s</td>
|
||||
<td class="failures">failed</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tab2" class="tab">
|
||||
<h2>Standard output</h2>
|
||||
<span class="code">
|
||||
<pre>[2023-12-23 11:22:37,346] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
||||
[2023-12-23 11:22:37,495] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined participanteUno turn pot: 10.0
|
||||
[2023-12-23 11:22:37,497] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Waiting for more participants.
|
||||
[2023-12-23 11:22:37,498] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined participanteDos turn pot: 1.0
|
||||
[2023-12-23 11:22:37,500] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - All participants joined; beginning turn: 11.0
|
||||
[2023-12-23 11:22:37,500] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Starting pot: 11.0
|
||||
[2023-12-23 11:22:37,502] [INFO] [dev.freireservices.social_altruism.chat.Participante] [ChatQuickStartTest-akka.actor.default-dispatcher-5] [akka://ChatQuickStartTest/user/participanteUno] - Pot returned: 11.0
|
||||
[2023-12-23 11:22:37,502] [INFO] [dev.freireservices.social_altruism.chat.Participante] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/participanteDos] - Pot returned: 11.0
|
||||
</pre>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p>
|
||||
<div>
|
||||
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
|
||||
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
|
||||
</label>
|
||||
</div>Generated by
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 23 dic 2023, 11:22:47</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -20,13 +20,13 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="infoBox" id="tests">
|
||||
<div class="counter">2</div>
|
||||
<div class="counter">1</div>
|
||||
<p>tests</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="failures">
|
||||
<div class="counter">0</div>
|
||||
<div class="counter">1</div>
|
||||
<p>failures</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -38,7 +38,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="duration">
|
||||
<div class="counter">0.944s</div>
|
||||
<div class="counter">10.961s</div>
|
||||
<p>duration</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -47,8 +47,8 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox success" id="successRate">
|
||||
<div class="percent">100%</div>
|
||||
<div class="infoBox failures" id="successRate">
|
||||
<div class="percent">0%</div>
|
||||
<p>successful</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -58,13 +58,25 @@
|
||||
<div id="tabs">
|
||||
<ul class="tabLinks">
|
||||
<li>
|
||||
<a href="#tab0">Packages</a>
|
||||
<a href="#tab0">Failed tests</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab1">Classes</a>
|
||||
<a href="#tab1">Packages</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab2">Classes</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="tab0" class="tab">
|
||||
<h2>Failed tests</h2>
|
||||
<ul class="linkList">
|
||||
<li>
|
||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>.
|
||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab1" class="tab">
|
||||
<h2>Packages</h2>
|
||||
<table>
|
||||
<thead>
|
||||
@ -79,19 +91,19 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="success">
|
||||
<a href="packages/dev.freireservices.social_altruism.html">dev.freireservices.social_altruism</a>
|
||||
<td class="failures">
|
||||
<a href="packages/dev.freireservices.social_altruism.chat.html">dev.freireservices.social_altruism.chat</a>
|
||||
</td>
|
||||
<td>2</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0.944s</td>
|
||||
<td class="success">100%</td>
|
||||
<td>10.961s</td>
|
||||
<td class="failures">0%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tab1" class="tab">
|
||||
<div id="tab2" class="tab">
|
||||
<h2>Classes</h2>
|
||||
<table>
|
||||
<thead>
|
||||
@ -106,14 +118,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="success">
|
||||
<a href="classes/dev.freireservices.social_altruism.ChatQuickStartTest.html">dev.freireservices.social_altruism.ChatQuickStartTest</a>
|
||||
<td class="failures">
|
||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">dev.freireservices.social_altruism.chat.ChatQuickStartTest</a>
|
||||
</td>
|
||||
<td>2</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0.944s</td>
|
||||
<td class="success">100%</td>
|
||||
<td>10.961s</td>
|
||||
<td class="failures">0%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -126,7 +138,7 @@
|
||||
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
|
||||
</label>
|
||||
</div>Generated by
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 22 dic 2023, 9:02:23</p>
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 23 dic 2023, 11:22:47</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -3,16 +3,16 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
||||
<title>Test results - Package dev.freireservices.social_altruism</title>
|
||||
<title>Test results - Package dev.freireservices.social_altruism.chat</title>
|
||||
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="../js/report.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>Package dev.freireservices.social_altruism</h1>
|
||||
<h1>Package dev.freireservices.social_altruism.chat</h1>
|
||||
<div class="breadcrumbs">
|
||||
<a href="../index.html">all</a> > dev.freireservices.social_altruism</div>
|
||||
<a href="../index.html">all</a> > dev.freireservices.social_altruism.chat</div>
|
||||
<div id="summary">
|
||||
<table>
|
||||
<tr>
|
||||
@ -22,13 +22,13 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="infoBox" id="tests">
|
||||
<div class="counter">2</div>
|
||||
<div class="counter">1</div>
|
||||
<p>tests</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="failures">
|
||||
<div class="counter">0</div>
|
||||
<div class="counter">1</div>
|
||||
<p>failures</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -40,7 +40,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox" id="duration">
|
||||
<div class="counter">0.944s</div>
|
||||
<div class="counter">10.961s</div>
|
||||
<p>duration</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -49,8 +49,8 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="infoBox success" id="successRate">
|
||||
<div class="percent">100%</div>
|
||||
<div class="infoBox failures" id="successRate">
|
||||
<div class="percent">0%</div>
|
||||
<p>successful</p>
|
||||
</div>
|
||||
</td>
|
||||
@ -60,10 +60,22 @@
|
||||
<div id="tabs">
|
||||
<ul class="tabLinks">
|
||||
<li>
|
||||
<a href="#tab0">Classes</a>
|
||||
<a href="#tab0">Failed tests</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab1">Classes</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="tab0" class="tab">
|
||||
<h2>Failed tests</h2>
|
||||
<ul class="linkList">
|
||||
<li>
|
||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>.
|
||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab1" class="tab">
|
||||
<h2>Classes</h2>
|
||||
<table>
|
||||
<thread>
|
||||
@ -77,14 +89,14 @@
|
||||
</tr>
|
||||
</thread>
|
||||
<tr>
|
||||
<td class="success">
|
||||
<a href="../classes/dev.freireservices.social_altruism.ChatQuickStartTest.html">ChatQuickStartTest</a>
|
||||
<td class="failures">
|
||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>
|
||||
</td>
|
||||
<td>2</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0.944s</td>
|
||||
<td class="success">100%</td>
|
||||
<td>10.961s</td>
|
||||
<td class="failures">0%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -96,7 +108,7 @@
|
||||
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
|
||||
</label>
|
||||
</div>Generated by
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 22 dic 2023, 9:02:23</p>
|
||||
<a href="http://www.gradle.org">Gradle 7.6</a> at 23 dic 2023, 11:22:47</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuite name="dev.freireservices.social_altruism.ChatQuickStartTest" tests="2" skipped="0" failures="0" errors="0" timestamp="2023-12-22T08:02:22" hostname="MacBook-Pro.local" time="0.952">
|
||||
<properties/>
|
||||
<testcase name="testActorGetsUserDenied" classname="dev.freireservices.social_altruism.ChatQuickStartTest" time="0.856"/>
|
||||
<testcase name="testGreeterActorSendingOfGreeting" classname="dev.freireservices.social_altruism.ChatQuickStartTest" time="0.088"/>
|
||||
<system-out><![CDATA[[2023-12-22 09:02:23,397] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
||||
[2023-12-22 09:02:23,552] [ERROR] [akka.actor.testkit.typed.internal.ActorTestKitGuardian$$anonfun$handleSpawnException$1] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user] - Spawn failed, props [EmptyProps]
|
||||
akka.actor.InvalidActorNameException: actor name [chatRoom] is not unique!
|
||||
at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:134)
|
||||
at akka.actor.dungeon.Children.reserveChild(Children.scala:147)
|
||||
at akka.actor.dungeon.Children.reserveChild$(Children.scala:145)
|
||||
at akka.actor.ActorCell.reserveChild(ActorCell.scala:410)
|
||||
at akka.actor.dungeon.Children.makeChild(Children.scala:300)
|
||||
at akka.actor.dungeon.Children.actorOf(Children.scala:49)
|
||||
at akka.actor.dungeon.Children.actorOf$(Children.scala:48)
|
||||
at akka.actor.ActorCell.actorOf(ActorCell.scala:410)
|
||||
at akka.actor.typed.internal.adapter.ActorRefFactoryAdapter$.spawn(ActorRefFactoryAdapter.scala:55)
|
||||
at akka.actor.typed.internal.adapter.ActorContextAdapter.spawn(ActorContextAdapter.scala:73)
|
||||
at akka.actor.testkit.typed.internal.ActorTestKitGuardian$.$anonfun$testKitGuardian$1(TestKitUtils.scala:35)
|
||||
at akka.actor.typed.internal.BehaviorImpl$ReceiveBehavior.receive(BehaviorImpl.scala:136)
|
||||
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
|
||||
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
|
||||
at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
|
||||
at akka.actor.typed.internal.adapter.GuardianStopInterceptor.aroundReceive(GuardianStartupBehavior.scala:59)
|
||||
at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
|
||||
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
|
||||
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
|
||||
at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
|
||||
at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:109)
|
||||
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
|
||||
at akka.actor.ActorCell.invoke(ActorCell.scala:547)
|
||||
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
|
||||
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
|
||||
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
|
||||
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
|
||||
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
|
||||
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
|
||||
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
|
||||
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
|
||||
[2023-12-22 09:02:23,640] [INFO] [akka.actor.LocalActorRef] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/$a] - Message [dev.freireservices.social_altruism.ChatRoom$GetSession] to Actor[akka://ChatQuickStartTest/user/$a#-835521502] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://ChatQuickStartTest/user/$a#-835521502] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
|
||||
[2023-12-22 09:02:23,665] [INFO] [akka.actor.CoordinatedShutdown] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [CoordinatedShutdown(akka://ChatQuickStartTest)] - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
|
||||
]]></system-out>
|
||||
<system-err><![CDATA[]]></system-err>
|
||||
</testsuite>
|
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuite name="dev.freireservices.social_altruism.chat.ChatQuickStartTest" tests="1" skipped="0" failures="1" errors="0" timestamp="2023-12-23T10:22:36" hostname="MacBook-Pro.local" time="10.961">
|
||||
<properties/>
|
||||
<testcase name="testGreeterActorSendingOfGreeting" classname="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="10.961">
|
||||
<failure message="java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned" type="java.lang.AssertionError">java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
||||
at dev.freireservices.social_altruism.chat.ChatQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
||||
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
|
||||
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
|
||||
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
|
||||
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
|
||||
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
|
||||
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
|
||||
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
|
||||
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
|
||||
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
|
||||
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
|
||||
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
|
||||
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
||||
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:57)
|
||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
|
||||
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
|
||||
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
|
||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
|
||||
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
|
||||
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
|
||||
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
|
||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
|
||||
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
|
||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
|
||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
|
||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
|
||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
|
||||
</failure>
|
||||
</testcase>
|
||||
<system-out><![CDATA[[2023-12-23 11:22:37,346] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
||||
[2023-12-23 11:22:37,495] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined participanteUno turn pot: 10.0
|
||||
[2023-12-23 11:22:37,497] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Waiting for more participants.
|
||||
[2023-12-23 11:22:37,498] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined participanteDos turn pot: 1.0
|
||||
[2023-12-23 11:22:37,500] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - All participants joined; beginning turn: 11.0
|
||||
[2023-12-23 11:22:37,500] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Starting pot: 11.0
|
||||
[2023-12-23 11:22:37,502] [INFO] [dev.freireservices.social_altruism.chat.Participante] [ChatQuickStartTest-akka.actor.default-dispatcher-5] [akka://ChatQuickStartTest/user/participanteUno] - Pot returned: 11.0
|
||||
[2023-12-23 11:22:37,502] [INFO] [dev.freireservices.social_altruism.chat.Participante] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/participanteDos] - Pot returned: 11.0
|
||||
]]></system-out>
|
||||
<system-err><![CDATA[]]></system-err>
|
||||
</testsuite>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
245
gradlew
vendored
245
gradlew
vendored
@ -1,245 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
92
gradlew.bat
vendored
92
gradlew.bat
vendored
@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
46
pom.xml
46
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>hello-akka-java</groupId>
|
||||
<artifactId>app</artifactId>
|
||||
<artifactId>SocialAltruism</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
@ -19,16 +19,20 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-actor-typed_2.13</artifactId>
|
||||
<version>${akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-actor-testkit-typed_2.13</artifactId>
|
||||
@ -41,16 +45,38 @@
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility-proxy</artifactId>
|
||||
<version>3.1.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<source>19</source>
|
||||
<target>19</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -62,7 +88,7 @@
|
||||
<arguments>
|
||||
<argument>-classpath</argument>
|
||||
<classpath />
|
||||
<argument>dev.freireservices.social_altruism.ChatQuickStart</argument>
|
||||
<argument>dev.freireservices.social_altruism.chat.ChatQuickStart</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -1,31 +0,0 @@
|
||||
package dev.freireservices.social_altruism;
|
||||
|
||||
import akka.actor.typed.ActorRef;
|
||||
import akka.actor.typed.ActorSystem;
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.Terminated;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
|
||||
public class ChatQuickStart {
|
||||
public static void main(String[] args) {
|
||||
// #actor-system
|
||||
ActorSystem.create(Main.create(), "ChatRoomDemo");
|
||||
}
|
||||
|
||||
public static class Main {
|
||||
public static Behavior<Void> create() {
|
||||
return Behaviors.setup(
|
||||
context -> {
|
||||
ActorRef<ChatRoom.RoomCommand> chatRoom = context.spawn(ChatRoom.create(), "chatRoom");
|
||||
ActorRef<ChatRoom.SessionEvent> gabbler = context.spawn(Gabbler.create(), "gabbler");
|
||||
context.watch(gabbler);
|
||||
chatRoom.tell(new ChatRoom.GetSession("ol’ Gabbler", gabbler));
|
||||
|
||||
return Behaviors.receive(Void.class)
|
||||
.onSignal(Terminated.class, sig -> Behaviors.stopped())
|
||||
.build();
|
||||
});
|
||||
}
|
||||
}
|
||||
// #actor-system
|
||||
}
|
@ -1,212 +0,0 @@
|
||||
package dev.freireservices.social_altruism;
|
||||
|
||||
import akka.actor.typed.ActorRef;
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.javadsl.ActorContext;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChatRoom {
|
||||
|
||||
private final ActorContext<RoomCommand> context;
|
||||
|
||||
private ChatRoom(ActorContext<RoomCommand> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
interface RoomCommand {}
|
||||
|
||||
public static final class GetSession implements RoomCommand {
|
||||
public final String screenName;
|
||||
public final ActorRef<SessionEvent> replyTo;
|
||||
|
||||
|
||||
public GetSession(String screenName, ActorRef<SessionEvent> replyTo) {
|
||||
this.screenName = screenName;
|
||||
this.replyTo = replyTo;
|
||||
}
|
||||
}
|
||||
// #chatroom-protocol
|
||||
// #chatroom-behavior
|
||||
private static final class PublishSessionMessage implements RoomCommand {
|
||||
public final String screenName;
|
||||
public final String message;
|
||||
|
||||
|
||||
public PublishSessionMessage(String screenName, String message) {
|
||||
this.screenName = screenName;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
// #chatroom-behavior
|
||||
// #chatroom-protocol
|
||||
|
||||
private Behavior<RoomCommand> onGetSession(
|
||||
List<ActorRef<SessionCommand>> sessions, GetSession getSession) {
|
||||
|
||||
if (sessions.stream().anyMatch(s -> s.path().name().equals(URLEncoder.encode(getSession.screenName, StandardCharsets.UTF_8)))) {
|
||||
getSession.replyTo.tell(new SessionDenied("duplicate session name"));
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
ActorRef<SessionEvent> client = getSession.replyTo;
|
||||
ActorRef<SessionCommand> ses =
|
||||
context.spawn(
|
||||
Session.create(context.getSelf(), getSession.screenName, client),
|
||||
URLEncoder.encode(getSession.screenName, StandardCharsets.UTF_8));
|
||||
// narrow to only expose PostMessage
|
||||
|
||||
client.tell(new SessionGranted(ses.narrow()));
|
||||
|
||||
List<ActorRef<SessionCommand>> newSessions = new ArrayList<>(sessions);
|
||||
newSessions.add(ses);
|
||||
return chatRoom(newSessions);
|
||||
}
|
||||
|
||||
private Behavior<RoomCommand> onPublishSessionMessage(
|
||||
List<ActorRef<SessionCommand>> sessions, PublishSessionMessage pub) {
|
||||
NotifyClient notification =
|
||||
new NotifyClient((new MessagePosted(pub.screenName, pub.message)));
|
||||
sessions.forEach(s -> s.tell(notification));
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private Behavior<RoomCommand> chatRoom(List<ActorRef<SessionCommand>> sessions) {
|
||||
return Behaviors.receive(RoomCommand.class)
|
||||
.onMessage(GetSession.class, getSession -> onGetSession(sessions, getSession))
|
||||
.onMessage(PublishSessionMessage.class, pub -> onPublishSessionMessage(sessions, pub))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
public static Behavior<RoomCommand> create() {
|
||||
return Behaviors.setup(
|
||||
ctx -> new ChatRoom(ctx).chatRoom(new ArrayList<ActorRef<SessionCommand>>()));
|
||||
}
|
||||
|
||||
public interface SessionEvent {}
|
||||
|
||||
|
||||
public static final class SessionGranted implements SessionEvent {
|
||||
public final ActorRef<PostMessage> handle;
|
||||
|
||||
|
||||
public SessionGranted(ActorRef<PostMessage> handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SessionGranted that = (SessionGranted) o;
|
||||
return Objects.equals(handle, that.handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionGranted{" +
|
||||
"handle=" + handle +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final class SessionDenied implements SessionEvent {
|
||||
public final String reason;
|
||||
|
||||
|
||||
public SessionDenied(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SessionDenied that = (SessionDenied) o;
|
||||
return Objects.equals(reason, that.reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionDenied{" +
|
||||
"reason='" + reason + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final class MessagePosted implements SessionEvent {
|
||||
public final String screenName;
|
||||
public final String message;
|
||||
|
||||
|
||||
public MessagePosted(String screenName, String message) {
|
||||
this.screenName = screenName;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface SessionCommand {}
|
||||
|
||||
|
||||
public static final class PostMessage implements SessionCommand {
|
||||
public final String message;
|
||||
|
||||
|
||||
public PostMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class NotifyClient implements SessionCommand {
|
||||
final MessagePosted message;
|
||||
|
||||
|
||||
NotifyClient(MessagePosted message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
static class Session {
|
||||
static Behavior<ChatRoom.SessionCommand> create(
|
||||
ActorRef<RoomCommand> room, String screenName, ActorRef<SessionEvent> client) {
|
||||
return Behaviors.receive(ChatRoom.SessionCommand.class)
|
||||
.onMessage(PostMessage.class, post -> onPostMessage(room, screenName, post))
|
||||
.onMessage(NotifyClient.class, notification -> onNotifyClient(client, notification))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Behavior<SessionCommand> onPostMessage(
|
||||
ActorRef<RoomCommand> room, String screenName, PostMessage post) {
|
||||
// from client, publish to others via the room
|
||||
room.tell(new PublishSessionMessage(screenName, post.message));
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private static Behavior<SessionCommand> onNotifyClient(
|
||||
ActorRef<SessionEvent> client, NotifyClient notification) {
|
||||
// published from the room
|
||||
client.tell(notification.message);
|
||||
return Behaviors.same();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package dev.freireservices.social_altruism;
|
||||
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.javadsl.ActorContext;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
import dev.freireservices.social_altruism.ChatRoom;
|
||||
|
||||
public class Gabbler {
|
||||
|
||||
public static Behavior<ChatRoom.SessionEvent> create() {
|
||||
return Behaviors.setup(ctx -> new Gabbler(ctx).behavior());
|
||||
}
|
||||
|
||||
private final ActorContext<ChatRoom.SessionEvent> context;
|
||||
|
||||
private Gabbler(ActorContext<ChatRoom.SessionEvent> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private Behavior<ChatRoom.SessionEvent> behavior() {
|
||||
return Behaviors.receive(ChatRoom.SessionEvent.class)
|
||||
.onMessage(ChatRoom.SessionDenied.class, this::onSessionDenied)
|
||||
.onMessage(ChatRoom.SessionGranted.class, this::onSessionGranted)
|
||||
.onMessage(ChatRoom.MessagePosted.class, this::onMessagePosted)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Behavior<ChatRoom.SessionEvent> onSessionDenied(ChatRoom.SessionDenied message) {
|
||||
context.getLog().info("cannot start chat room session: {}", message.reason);
|
||||
return Behaviors.stopped();
|
||||
}
|
||||
|
||||
private Behavior<ChatRoom.SessionEvent> onSessionGranted(ChatRoom.SessionGranted message) {
|
||||
message.handle.tell(new ChatRoom.PostMessage("Hello World!"));
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private Behavior<ChatRoom.SessionEvent> onMessagePosted(ChatRoom.MessagePosted message) {
|
||||
context
|
||||
.getLog()
|
||||
.info("message has been posted by '{}': {}", message.screenName, message.message);
|
||||
return Behaviors.stopped();
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package dev.freireservices.social_altruism.chat;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.*;
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
import akka.actor.typed.ActorRef;
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.javadsl.ActorContext;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChatPotProtocol {
|
||||
private final ActorContext<RoomCommand> context;
|
||||
|
||||
public double getCurrentPot() {
|
||||
return currentPot;
|
||||
}
|
||||
|
||||
public void setCurrentPot(double currentPot) {
|
||||
this.currentPot = currentPot;
|
||||
}
|
||||
|
||||
public void addToPot(double pot) {
|
||||
this.currentPot += pot;
|
||||
}
|
||||
|
||||
private double currentPot = 0.0;
|
||||
private int currentTurn = 0;
|
||||
private final int numberOfParticipants;
|
||||
|
||||
private ChatPotProtocol(ActorContext<RoomCommand> context, int numberOfParticipants) {
|
||||
this.numberOfParticipants = numberOfParticipants;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
interface RoomCommand {}
|
||||
|
||||
public record EnterPot(ActorRef<SessionEvent> replyTo, double pot) implements RoomCommand {}
|
||||
|
||||
// #chatroom-protocol
|
||||
// #chatroom-behavior
|
||||
private record UpdatePlayerAfterTurn(String screenName, String message) implements RoomCommand {}
|
||||
|
||||
// #chatroom-behavior
|
||||
// #chatroom-protocol
|
||||
|
||||
private Behavior<RoomCommand> onGetPotSession(
|
||||
EnterPot enterPot, List<ActorRef<SessionCommand>> sessions) {
|
||||
|
||||
//Add check session started
|
||||
|
||||
if (sessions.stream()
|
||||
.anyMatch(
|
||||
s ->
|
||||
s.path().name().equals(URLEncoder.encode(enterPot.replyTo.path().name(), UTF_8)))) {
|
||||
|
||||
enterPot.replyTo.tell(new SessionDenied("Can only enter a pot once"));
|
||||
}
|
||||
|
||||
context
|
||||
.getLog()
|
||||
.info("Participant joined {} turn pot: {}", enterPot.replyTo.path().name(), enterPot.pot);
|
||||
|
||||
// Add to current pot
|
||||
addToPot(enterPot.pot);
|
||||
|
||||
ActorRef<SessionEvent> client = enterPot.replyTo;
|
||||
|
||||
ActorRef<SessionCommand> ses =
|
||||
context.spawn(
|
||||
Session.create(client), URLEncoder.encode(enterPot.replyTo.path().name(), UTF_8));
|
||||
|
||||
// narrow to only expose PostMessage
|
||||
client.tell(new SessionGranted(ses.narrow()));
|
||||
|
||||
List<ActorRef<SessionCommand>> newSessions = new ArrayList<>(sessions);
|
||||
|
||||
newSessions.add(ses);
|
||||
|
||||
if (numberOfParticipants == newSessions.size()) {
|
||||
// Begin
|
||||
context.getLog().info("All participants joined; beginning turn: " + getCurrentPot());
|
||||
|
||||
double amountToShare = (getCurrentPot() * 2) / numberOfParticipants;
|
||||
|
||||
context.getLog().info("Starting pot: " + getCurrentPot());
|
||||
|
||||
newSessions.forEach(s -> s.tell(new SharePotWithParticipants(amountToShare)));
|
||||
|
||||
currentTurn++;
|
||||
return Behaviors.same();
|
||||
|
||||
} else {
|
||||
// Waiting for more participants
|
||||
context.getLog().info("Waiting for more participants.");
|
||||
|
||||
return createPot(newSessions);
|
||||
}
|
||||
}
|
||||
|
||||
private Behavior<RoomCommand> onUpdatePlayerAfterTurn(
|
||||
List<ActorRef<SessionCommand>> sessions, UpdatePlayerAfterTurn pub) {
|
||||
// NotifyClient notification = new NotifyClient((new MessagePosted(pub.screenName,
|
||||
// pub.message)));
|
||||
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private Behavior<RoomCommand> createPot(List<ActorRef<SessionCommand>> sessions) {
|
||||
return Behaviors.receive(RoomCommand.class)
|
||||
.onMessage(EnterPot.class, enterPot -> onGetPotSession(enterPot, sessions))
|
||||
//
|
||||
.onMessage(UpdatePlayerAfterTurn.class, pub -> onUpdatePlayerAfterTurn(sessions, pub))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static Behavior<RoomCommand> create(int numberOfParticipants) {
|
||||
return Behaviors.setup(ctx -> new ChatPotProtocol(ctx, numberOfParticipants).createPot(emptyList()));
|
||||
}
|
||||
|
||||
public interface SessionEvent {}
|
||||
|
||||
public record SessionGranted(ActorRef<ParticipateInTurn> handle) implements SessionEvent {}
|
||||
|
||||
public record SessionDenied(String reason) implements SessionEvent {}
|
||||
|
||||
public record MessagePosted(String screenName, String message) implements SessionEvent {}
|
||||
|
||||
public record PotReturned(double returnedAmount) implements SessionEvent {}
|
||||
|
||||
interface SessionCommand {}
|
||||
|
||||
public record ParticipateInTurn(String message) implements SessionCommand {}
|
||||
|
||||
public record SharePotWithParticipants(double returnedAmount) implements SessionCommand {}
|
||||
|
||||
static class Session {
|
||||
static Behavior<ChatPotProtocol.SessionCommand> create(ActorRef<SessionEvent> client) {
|
||||
return Behaviors.receive(ChatPotProtocol.SessionCommand.class)
|
||||
.onMessage(
|
||||
SharePotWithParticipants.class,
|
||||
pot -> onSharePotWithParticipants(client, pot.returnedAmount))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Behavior<SessionCommand> onSharePotWithParticipants(
|
||||
ActorRef<SessionEvent> client, double returnedAmount) {
|
||||
client.tell(new ChatPotProtocol.PotReturned(returnedAmount));
|
||||
return Behaviors.same();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package dev.freireservices.social_altruism.chat;
|
||||
|
||||
import akka.actor.typed.ActorRef;
|
||||
import akka.actor.typed.ActorSystem;
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.Terminated;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ChatQuickStart {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// #actor-system
|
||||
ActorSystem.create(Main.create(), "PotRoom");
|
||||
}
|
||||
|
||||
public static class Main {
|
||||
|
||||
static List<ActorRef<ChatPotProtocol.SessionEvent>> sessions = new ArrayList<>();
|
||||
|
||||
public static Behavior<Void> create() {
|
||||
return Behaviors.setup(
|
||||
context -> {
|
||||
ActorRef<ChatPotProtocol.RoomCommand> chatRoom = context.spawn(ChatPotProtocol.create(100), "potRoom");
|
||||
|
||||
// Agregamos jugadores
|
||||
sessions.addAll(
|
||||
IntStream.range(0, 100)
|
||||
.mapToObj(
|
||||
i ->
|
||||
context.spawn(
|
||||
Participante.create(getRandomNumberBetween(0, 100)), "participante-" + i))
|
||||
.toList());
|
||||
|
||||
sessions.forEach(s -> chatRoom.tell(new ChatPotProtocol.EnterPot(s, getRandomNumberBetween(0, 100))));
|
||||
|
||||
|
||||
|
||||
return Behaviors.receive(Void.class)
|
||||
.onSignal(Terminated.class, sig -> Behaviors.stopped())
|
||||
.build();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// #actor-system
|
||||
|
||||
public static int getRandomNumberBetween(int min, int max) {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
return secureRandom.nextInt(max - min) + min;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package dev.freireservices.social_altruism.chat;
|
||||
|
||||
import akka.actor.typed.Behavior;
|
||||
import akka.actor.typed.javadsl.ActorContext;
|
||||
import akka.actor.typed.javadsl.Behaviors;
|
||||
|
||||
public class Participante {
|
||||
|
||||
public static Behavior<ChatPotProtocol.SessionEvent> create(int monedasInit) {
|
||||
return Behaviors.setup(ctx -> new Participante(ctx, monedasInit).behavior());
|
||||
}
|
||||
|
||||
private final ActorContext<ChatPotProtocol.SessionEvent> context;
|
||||
|
||||
public double getMonedas() {
|
||||
return monedas;
|
||||
}
|
||||
|
||||
public void setMonedas(double monedas) {
|
||||
this.monedas = monedas;
|
||||
}
|
||||
|
||||
public void decrementMonedas(double monedas) {
|
||||
this.monedas -= monedas;
|
||||
}
|
||||
|
||||
public void incrementMonedas(double monedas) {
|
||||
this.monedas += monedas;
|
||||
}
|
||||
|
||||
private double monedas;
|
||||
|
||||
private Participante(ActorContext<ChatPotProtocol.SessionEvent> context, double monedas) {
|
||||
this.context = context;
|
||||
this.monedas = monedas;
|
||||
}
|
||||
|
||||
private Behavior<ChatPotProtocol.SessionEvent> behavior() {
|
||||
return Behaviors.receive(ChatPotProtocol.SessionEvent.class)
|
||||
.onMessage(ChatPotProtocol.SessionDenied.class, this::onSessionDenied)
|
||||
.onMessage(ChatPotProtocol.SessionGranted.class, this::onSessionGranted)
|
||||
.onMessage(ChatPotProtocol.MessagePosted.class, this::onMessagePosted)
|
||||
.onMessage(ChatPotProtocol.PotReturned.class, this::onPotReturned)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Behavior<ChatPotProtocol.SessionEvent> onSessionDenied(
|
||||
ChatPotProtocol.SessionDenied message) {
|
||||
context.getLog().info("cannot start chat room session: {}", message.reason());
|
||||
return Behaviors.stopped();
|
||||
}
|
||||
|
||||
private Behavior<ChatPotProtocol.SessionEvent> onSessionGranted(
|
||||
ChatPotProtocol.SessionGranted message) {
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private Behavior<ChatPotProtocol.SessionEvent> onMessagePosted(
|
||||
ChatPotProtocol.MessagePosted message) {
|
||||
context
|
||||
.getLog()
|
||||
.info("message has been posted by '{}': {}", message.screenName(), message.message());
|
||||
return Behaviors.same();
|
||||
}
|
||||
|
||||
private Behavior<ChatPotProtocol.SessionEvent> onPotReturned(
|
||||
ChatPotProtocol.PotReturned potReturned) {
|
||||
context.getLog().info("Pot returned: {}", potReturned.returnedAmount());
|
||||
incrementMonedas(potReturned.returnedAmount());
|
||||
return Behaviors.same();
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package dev.freireservices.social_altruism;
|
||||
|
||||
import akka.actor.testkit.typed.javadsl.ActorTestKit;
|
||||
import akka.actor.testkit.typed.javadsl.TestProbe;
|
||||
import akka.actor.typed.ActorRef;
|
||||
import java.time.Duration;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
// #definition
|
||||
public class ChatQuickStartTest {
|
||||
|
||||
static final ActorTestKit testKit = ActorTestKit.create();
|
||||
|
||||
// #definition
|
||||
|
||||
// #test
|
||||
@Test
|
||||
public void testGreeterActorSendingOfGreeting() {
|
||||
|
||||
TestProbe<ChatRoom.PostMessage> testProbe = testKit.createTestProbe();
|
||||
|
||||
ActorRef<ChatRoom.RoomCommand> chatRoomTest = testKit.spawn(ChatRoom.create(), "chatRoom");
|
||||
ActorRef<ChatRoom.SessionEvent> gabblerTest = testKit.spawn(Gabbler.create(), "gabbler");
|
||||
|
||||
chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", gabblerTest));
|
||||
|
||||
ChatRoom.SessionGranted sessionGranted = new ChatRoom.SessionGranted(testProbe.ref());
|
||||
gabblerTest.tell(sessionGranted);
|
||||
|
||||
ChatRoom.PostMessage postMessage = new ChatRoom.PostMessage("Hello World!");
|
||||
sessionGranted.handle.tell(postMessage);
|
||||
// #test
|
||||
|
||||
// #assert
|
||||
testProbe.expectMessage(postMessage);
|
||||
// #assert
|
||||
|
||||
testKit.stop(chatRoomTest);
|
||||
testKit.stop(gabblerTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActorGetsUserDenied() {
|
||||
|
||||
TestProbe<ChatRoom.SessionEvent> testProbe = testKit.createTestProbe();
|
||||
|
||||
ActorRef<ChatRoom.RoomCommand> chatRoomTest = testKit.spawn(ChatRoom.create(), "chatRoom");
|
||||
|
||||
chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", testProbe.ref()));
|
||||
|
||||
testProbe.expectMessageClass(ChatRoom.SessionGranted.class, Duration.ofSeconds(10));
|
||||
|
||||
chatRoomTest.tell(new ChatRoom.GetSession("ol’ Gabbler", testProbe.ref()));
|
||||
|
||||
ChatRoom.SessionDenied sessionDenied = new ChatRoom.SessionDenied("duplicate session name");
|
||||
|
||||
testProbe.expectMessage(Duration.ofSeconds(10), sessionDenied);
|
||||
|
||||
// #assert
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanup() {
|
||||
testKit.system().terminate();
|
||||
testKit.shutdownTestKit();
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package dev.freireservices.social_altruism.chat;
|
||||
|
||||
import akka.actor.testkit.typed.javadsl.ActorTestKit;
|
||||
import akka.actor.testkit.typed.javadsl.TestProbe;
|
||||
import akka.actor.typed.ActorRef;
|
||||
import java.time.Duration;
|
||||
import org.junit.Test;
|
||||
|
||||
// #definition
|
||||
public class ChatQuickStartTest {
|
||||
|
||||
// #definition
|
||||
|
||||
// #test
|
||||
@Test
|
||||
public void testCooperationCaseOne() {
|
||||
|
||||
final ActorTestKit testKit = ActorTestKit.create();
|
||||
|
||||
TestProbe<ChatPotProtocol.SessionEvent> testProbe = testKit.createTestProbe();
|
||||
|
||||
ActorRef<ChatPotProtocol.RoomCommand> chatRoomTest =
|
||||
testKit.spawn(ChatPotProtocol.create(2), "chatRoom");
|
||||
|
||||
ActorRef<ChatPotProtocol.SessionEvent> participanteUno =
|
||||
testKit.spawn(Participante.create(100), "participanteUno");
|
||||
|
||||
ActorRef<ChatPotProtocol.SessionEvent> participanteDos =
|
||||
testKit.spawn(Participante.create(10), "participanteDos");
|
||||
|
||||
ActorRef<ChatPotProtocol.SessionEvent> participanteTres =
|
||||
testKit.spawn(Participante.create(100), "participanteTres");
|
||||
|
||||
ActorRef<ChatPotProtocol.SessionEvent> participanteCuatro =
|
||||
testKit.spawn(Participante.create(10), "participanteCuatro");
|
||||
|
||||
|
||||
// Turnos
|
||||
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(participanteUno, 10));
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(participanteDos, 1));
|
||||
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(participanteTres, 11));
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(participanteCuatro, 2));
|
||||
|
||||
// #assert
|
||||
// #assert
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActorGetsUserDenied() {
|
||||
final ActorTestKit testKit = ActorTestKit.create();
|
||||
TestProbe<ChatPotProtocol.SessionEvent> testProbe = testKit.createTestProbe();
|
||||
|
||||
ActorRef<ChatPotProtocol.RoomCommand> chatRoomTest =
|
||||
testKit.spawn(ChatPotProtocol.create(2), "chatRoom");
|
||||
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(testProbe.ref(), 10));
|
||||
|
||||
testProbe.expectMessageClass(ChatPotProtocol.SessionGranted.class, Duration.ofSeconds(10));
|
||||
|
||||
chatRoomTest.tell(new ChatPotProtocol.EnterPot(testProbe.ref(), 10));
|
||||
|
||||
ChatPotProtocol.SessionDenied sessionDenied =
|
||||
new ChatPotProtocol.SessionDenied("Can only enter a pot once");
|
||||
|
||||
testProbe.expectMessage(Duration.ofSeconds(10), sessionDenied);
|
||||
|
||||
// #assert
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user