Skip to content

Commit

Permalink
apptools: tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ketoth Xupack <ketoth.xupack@gmail.com>
  • Loading branch information
KetothXupack committed Oct 10, 2013
1 parent 46b96c5 commit 70efcce
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
5 changes: 3 additions & 2 deletions projects/apptools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.no-hope</groupId>
<artifactId>test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public final void start() throws Exception {
} else {
LOG.warn("Application was terminated due start() routine. Is it really async?");
}

}

@Override
Expand Down
14 changes: 14 additions & 0 deletions projects/apptools/src/test/java/org/nohope/app/AppStateTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.nohope.app;

import org.nohope.test.EnumTestSupport;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a>
* @since 2013-10-10 23:57
*/
public class AppStateTest extends EnumTestSupport<AppState> {
@Override
protected Class<AppState> getEnumClass() {
return AppState.class;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.nohope.app.example;
package org.nohope.app;

import org.junit.Test;
import org.nohope.app.example.AsyncAppExample;
import org.nohope.app.example.SyncAppExample;

import static org.junit.Assert.assertFalse;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
* @since 7/15/12 4:14 PM
*/
public class AppExampleTest {
public class AppTest {

@Test
public void syncApp() throws Exception {
Expand Down Expand Up @@ -44,5 +48,26 @@ public void run() {
}).start();

test.start();
assertFalse(test.isStarted());
}

@Test
public void asyncAppForcedShutdown() throws Exception {
final AsyncAppExample test = new AsyncAppExample();

new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
/* do nothing */
}
test.onVMShutdownWrapper();
}
}).start();

test.start();
assertFalse(test.isStarted());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.nohope.app.AsyncApp;

/**
* @author <a href="mailto:ketoth.xupack@gmail.com">ketoth xupack</a>
* @author <a href="mailto:ketoth.xupack@gmail.com">stopketoth xupack</a>
* @since 7/15/12 4:06 PM
*/
public class AsyncAppExample extends AsyncApp {
Expand Down

0 comments on commit 70efcce

Please sign in to comment.