Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sre] Avoid anyoing exceptions in event handlers.
close #613 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
8f30181
commit 9ec8d92
Showing
5 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
87 changes: 87 additions & 0 deletions
87
sre/io.janusproject/io.janusproject.tests/src/io/janusproject/tests/bugs/Bug613.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* Janus platform is an open-source multiagent platform. | ||
* More details on http://www.janusproject.io | ||
* | ||
* Copyright (C) 2014-2015 Sebastian RODRIGUEZ, Nicolas GAUD, Stéphane GALLAND. | ||
* | ||
* 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 | ||
* http://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. | ||
*/ | ||
|
||
package io.janusproject.tests.bugs; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
import org.junit.Test; | ||
|
||
import io.janusproject.services.executor.EarlyExitException; | ||
import io.janusproject.tests.testutils.AbstractJanusRunTest; | ||
|
||
import io.sarl.core.Destroy; | ||
import io.sarl.core.Initialize; | ||
import io.sarl.core.Lifecycle; | ||
import io.sarl.core.Schedules; | ||
import io.sarl.lang.SARLVersion; | ||
import io.sarl.lang.annotation.PerceptGuardEvaluator; | ||
import io.sarl.lang.annotation.SarlSpecification; | ||
import io.sarl.lang.core.BuiltinCapacitiesProvider; | ||
import io.sarl.lang.core.Capacity; | ||
import io.sarl.lang.core.Skill; | ||
import io.sarl.lang.core.UnimplementedCapacityException; | ||
import io.sarl.lang.util.ClearableReference; | ||
|
||
/** | ||
* Unit test for the issue #613: Exception when destroying the agent java.lang.InterruptedException. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @see https://github.com/sarl/sarl/issues/613 | ||
*/ | ||
@SuppressWarnings("all") | ||
public class Bug613 extends AbstractJanusRunTest { | ||
|
||
@Test | ||
public void killMeInInit() throws Exception { | ||
runJanus(TAgent1.class, true); | ||
assertEquals(0, getResults().size()); | ||
} | ||
|
||
/** | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
@SarlSpecification(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING) | ||
public static class TAgent1 extends TestingAgent { | ||
|
||
public TAgent1(BuiltinCapacitiesProvider provider, UUID parentID, UUID agentID) { | ||
super(provider, parentID, agentID); | ||
} | ||
|
||
@Override | ||
protected boolean runAgentTest() { | ||
getSkill(Schedules.class).in(100, (it) -> forceKillMe()); | ||
return false; | ||
} | ||
|
||
} | ||
|
||
} |