项目作者: jvz

项目描述 :
Unit testing helpers for ATG Java Enterprise applications
高级语言: Java
项目地址: git://github.com/jvz/dynunit.git
创建时间: 2013-11-05T20:20:01Z
项目社区:https://github.com/jvz/dynunit

开源协议:Apache License 2.0

下载


DynUnit

Fork of ATG DUST for use with JUnit4 and various newer libraries.

Installation

First, you’ll need to make some symlinks to your local ATG JARs. Suppose your
ATG_HOME environment variable is set to something like
$HOME/ATG/ATG10.1.2. Then you should execute the following:

  1. mkdir lib
  2. cd lib
  3. for module in DAS DPS DSS; do
  4. ln -s $ATG_HOME/$module/lib/classes.jar $module.jar
  5. ln -s $ATG_HOME/$module/lib/resources.jar $module-resources.jar
  6. done

Next, build the DynUnit JAR file for use in your ATG module:

  1. ./gradlew jar
  2. cp build/libs/dynunit-1.0-SNAPSHOT.jar your/project/libs/

Usage

A JUnit test runner is still in development, but DynUnit can be invoked without a special test runner using mostly
standard annotations from javax.inject. Any field which you wish to resolve a Nucleus component to must be annotated
with @Inject, and a class must add a @Nuke annotation to an injected Nucleus instance. Named components are
specified using the @Named annotation with their component path. For example:

  1. import atg.nucleus.Nucleus;
  2. import atg.nucleus.logging.PrintStreamLogger;
  3. import org.junit.Test;
  4. import org.junit.Before;
  5. import org.junit.After;
  6. import javax.inject.Inject;
  7. import javax.inject.Named;
  8. import atg.tools.dynunit.Nuke;
  9. import static atg.tools.dynunit.DynUnit.init;
  10. import static atg.tools.dynunit.DynUnit.stop;
  11. import static org.junit.Assert.assertFalse;
  12. public class DynUnitTest {
  13. // we inject a Nucleus using the base config path specified
  14. @Inject @Nuke("src/test/resources/config")
  15. private Nucleus nucleus;
  16. // by default, Nucleus always creates this component
  17. @Inject @Named("/atg/dynamo/service/logging/ScreenLog")
  18. private PrintStreamLogger screenLog;
  19. @Before
  20. public void setUp() {
  21. // this injects the instances marked above
  22. init(this);
  23. }
  24. @After
  25. public void tearDown() {
  26. // this stops the Nucleus service
  27. stop(this);
  28. }
  29. @Test
  30. public void testScreenLogDisabled() {
  31. assertFalse(screenLog.isLoggingEnabled());
  32. }
  33. }