This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kernel] Stop the agent when an exception occured in the Initialize h…
…andler. see #91 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
a864941
commit fc6cc5c
Showing
4 changed files
with
177 additions
and
6 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
101 changes: 101 additions & 0 deletions
101
io.janusproject.kernel/src/test/java/io/janusproject/bugs/Bug91.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,101 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* Janus platform is an open-source multiagent platform. | ||
* More details on http://www.janusproject.io | ||
* | ||
* Copyright (C) 2014 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.bugs; | ||
|
||
import io.janusproject.Boot; | ||
import io.janusproject.testutils.AbstractJanusRunTest; | ||
|
||
import java.util.UUID; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.google.common.eventbus.SubscriberExceptionHandler; | ||
import com.google.inject.Inject; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** Unit test for the issue #91: Stop agent on initialization failure? | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @see https://github.com/janus-project/janusproject/issues/91 | ||
*/ | ||
@SuppressWarnings("all") | ||
public class Bug91 extends AbstractJanusRunTest { | ||
|
||
@Inject | ||
private SubscriberExceptionHandler uncaughtEventBusExceptionHandler; | ||
|
||
@Before | ||
public void setUp() { | ||
Boot.setOffline(true); | ||
} | ||
|
||
@Test | ||
public void ExceptionInInit() throws Exception { | ||
runJanus(ExceptionInInitAgent.class); | ||
assertNumberOfResults(1); | ||
Exception ex = getResult(Exception.class, 0); | ||
assertNotNull(ex); | ||
assertCause(TestException.class, ex); | ||
} | ||
|
||
/** | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
public static class ExceptionInInitAgent extends TestingAgent { | ||
|
||
public ExceptionInInitAgent(UUID parentID) { | ||
super(parentID); | ||
} | ||
|
||
public ExceptionInInitAgent(UUID parentID, UUID agentID) { | ||
super(parentID, agentID); | ||
} | ||
|
||
@Override | ||
protected boolean runAgentTest() { | ||
throw new TestException(); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
private static class TestException extends RuntimeException { | ||
|
||
public TestException() { | ||
super("Error in the agent"); | ||
} | ||
|
||
} | ||
|
||
} |
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