isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1031521 - in /incubator/isis/trunk/viewer/bdd: common/src/main/java/org/apache/isis/viewer/bdd/common/ common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/ concordion/src/main/java/org/apache/isis/viewer/bdd/concordi...
Date Fri, 05 Nov 2010 11:35:57 GMT
Author: danhaywood
Date: Fri Nov  5 11:35:56 2010
New Revision: 1031521

URL: http://svn.apache.org/viewvc?rev=1031521&view=rev
Log:
mods to BDD viewer, change NOF->Isis

Added:
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/IsisInitializer.java
      - copied, changed from r1031497, incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/InitNakedObjects.java
    incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionTest.java
      - copied, changed from r1031497, incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractNakedObjectsConcordionTest.java
    incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java
      - copied, changed from r1031497, incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingNakedObjectsViewerForConcordion.java
Removed:
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/InitNakedObjects.java
    incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractNakedObjectsConcordionTest.java
    incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingNakedObjectsViewerForConcordion.java
Modified:
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/Story.java
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/StoryBootstrapper.java

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/Story.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/Story.java?rev=1031521&r1=1031520&r2=1031521&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/Story.java
(original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/Story.java
Fri Nov  5 11:35:56 2010
@@ -15,7 +15,7 @@ import org.apache.isis.runtime.persisten
 import org.apache.isis.runtime.system.DeploymentType;
 import org.apache.isis.runtime.system.IsisSystem;
 import org.apache.isis.runtime.transaction.IsisTransactionManager;
-import org.apache.isis.viewer.bdd.common.story.bootstrapping.InitNakedObjects;
+import org.apache.isis.viewer.bdd.common.story.bootstrapping.IsisInitializer;
 import org.apache.isis.viewer.bdd.common.story.bootstrapping.OpenSession;
 import org.apache.isis.viewer.bdd.common.story.bootstrapping.SetClock;
 import org.apache.isis.viewer.bdd.common.story.bootstrapping.ShutdownNakedObjects;
@@ -75,9 +75,9 @@ public class Story implements StoryBoots
     }
 
     /**
-     * Called by {@link InitNakedObjects}.
+     * Called by {@link IsisInitializer}.
      */
-    public void setNakedObjectsSystem(
+    public void setIsisSystem(
             final IsisSystem nakedObjectsSystem) {
         this.nakedObjectsSystem = nakedObjectsSystem;
     }

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/StoryBootstrapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/StoryBootstrapper.java?rev=1031521&r1=1031520&r2=1031521&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/StoryBootstrapper.java
(original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/StoryBootstrapper.java
Fri Nov  5 11:35:56 2010
@@ -20,7 +20,7 @@ public interface StoryBootstrapper  {
 	void setInstallerLookup(InstallerLookup installerLookup);
 
 	IsisSystem getSystem();
-	void setNakedObjectsSystem(IsisSystem system);
+	void setIsisSystem(IsisSystem system);
 
 
     /**

Copied: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/IsisInitializer.java
(from r1031497, incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/InitNakedObjects.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/IsisInitializer.java?p2=incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/IsisInitializer.java&p1=incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/InitNakedObjects.java&r1=1031497&r2=1031521&rev=1031521&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/InitNakedObjects.java
(original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/bootstrapping/IsisInitializer.java
Fri Nov  5 11:35:56 2010
@@ -18,12 +18,12 @@ import org.apache.isis.viewer.bdd.common
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class InitNakedObjects extends AbstractHelper {
+public class IsisInitializer extends AbstractHelper {
 
 	private final ConfigurationBuilder configurationBuilder;
 	private final DeploymentType deploymentType;
 
-    public InitNakedObjects(final Story story, ConfigurationBuilder configurationBuilder,
DeploymentType deploymentType) {
+    public IsisInitializer(final Story story, ConfigurationBuilder configurationBuilder,
DeploymentType deploymentType) {
         super(story);
         this.configurationBuilder = configurationBuilder;
         this.deploymentType = deploymentType;
@@ -58,7 +58,7 @@ public class InitNakedObjects extends Ab
             system = injector.getInstance(IsisSystem.class);
             
             getStory().setInstallerLookup(installerLookup);
-            getStory().setNakedObjectsSystem(system);
+            getStory().setIsisSystem(system);
 
             // provide a session in order to install fixtures
             IsisContext.openSession(new InitialisationSession());

Copied: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionTest.java
(from r1031497, incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractNakedObjectsConcordionTest.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionTest.java?p2=incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionTest.java&p1=incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractNakedObjectsConcordionTest.java&r1=1031497&r2=1031521&rev=1031521&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractNakedObjectsConcordionTest.java
(original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionTest.java
Fri Nov  5 11:35:56 2010
@@ -19,481 +19,428 @@ import org.apache.isis.viewer.bdd.common
 import org.apache.isis.viewer.bdd.common.StoryValueException;
 import org.apache.isis.viewer.bdd.common.fixtures.SetUpObjectsPeer.Mode;
 import org.apache.isis.viewer.bdd.common.fixtures.perform.Perform;
-import org.apache.isis.viewer.bdd.common.story.bootstrapping.InitNakedObjects;
+import org.apache.isis.viewer.bdd.common.story.bootstrapping.IsisInitializer;
 import org.apache.isis.viewer.bdd.concordion.internal.concordion.ExecuteCommandWithHeader;
 import org.apache.isis.viewer.bdd.concordion.internal.fixtures.AliasItemsInListForConcordion;
 import org.apache.isis.viewer.bdd.concordion.internal.fixtures.AliasServicesForConcordion;
 import org.apache.isis.viewer.bdd.concordion.internal.fixtures.SetUpObjectsForConcordion;
-import org.apache.isis.viewer.bdd.concordion.internal.fixtures.UsingNakedObjectsViewerForConcordion;
+import org.apache.isis.viewer.bdd.concordion.internal.fixtures.UsingIsisViewerForConcordion;
 import org.concordion.Concordion;
 import org.concordion.api.ResultSummary;
 import org.concordion.internal.ConcordionBuilder;
 import org.concordion.internal.FileTarget;
 import org.junit.Test;
 
-public class AbstractNakedObjectsConcordionTest {
+public class AbstractIsisConcordionTest {
 
-	public static final String DEFAULT_CONCORDION_CSS = "concordion.css";
-	public static final String DEFAULT_TARGET_DIR = "/tmp/concordion";
-	
-	private final static String NS_URI = "http://testedobjects.sourceforge.net/2010/concordion";
-	private static final String CMD_EXECUTE = "execute";
-	private final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
-			"dd MMM yyyy hh:mm");
-
-	private static ThreadLocal<Story> storyThreadLocal = new ThreadLocal<Story>()
{
-		@Override
-		protected Story initialValue() {
-			return new Story();
-		}
-	};
-
-	protected static Story getStory() {
-		return storyThreadLocal.get();
-	}
-
-	@Test
-	public void runStory() throws Throwable {
-		Concordion concordion = createConcordion();
-		ResultSummary resultSummary = concordion.process(this);
-		resultSummary.print(System.out, this);
-		resultSummary.assertIsSatisfied(this);
-		copyCustomCssIfDefined();
-	}
-
-	private void copyCustomCssIfDefined()  {
-		Class<?> cssClass = customCssPackage();
-		String customCss = customCss();
-		if (cssClass == null || customCss == null) {
-			return;
-		}
-		InputStream cssInputFile = cssClass.getResourceAsStream(customCss);
-		String cssPackageName = cssClass.getPackage().getName();
-		String cssPackagePath = asPath(cssPackageName);
-		String cssOutputFileName = combine(targetDir(), cssPackagePath, customCss);
-		try {
-			ByteArrayOutputStream baos = new ByteArrayOutputStream();
-			IoUtils.copy(cssInputFile, baos);
-			if (baos.size() > 0) {
-				IoUtils.copy(new ByteArrayInputStream(baos.toByteArray()), new FileOutputStream(cssOutputFileName));
-			}
-		} catch (IllegalArgumentException e) {
-			System.err.printf("failed to copy custom CSS to '%s'\n", customCss, cssOutputFileName);
-			return;
-		} catch (IOException e) {
-			System.err.printf("failed to copy custom CSS '%s' to '%s'\n", customCss, cssOutputFileName);
-			return;
-		}
-	}
-
-	
-
-	private String asPath(String name) {
-		return name.replace('.', File.separatorChar);
-	}
-
-	/**
-	 * Optional hook method to specify the directory to which the processed HTML should be
-	 * copied.
-	 * 
-	 * <p>
-	 * Defaults to {@value #DEFAULT_TARGET_DIR}.
-	 */
-	protected String targetDir() {
-		return DEFAULT_TARGET_DIR;
-	}
-
-	/**
-	 * Optional hook method to specify the class (any class) that resides in the same package
as the {@link #customCss()}.
-	 * 
-	 * <p>
-	 * Return <tt>null</tt> if no custom CSS has been provided.
-	 * 
-	 * @see #customCss()
-	 */
-	protected Class<?> customCssPackage() {
-		return null;
-	}
-
-	/**
-	 * Optional hook method to specify the name of the custom CSS file.
-	 * 
-	 * <p>
-	 * Defaults to {@value #DEFAULT_CONCORDION_CSS} so you do not need to override if
-	 * your custom CSS file has this name.  However, it is necessary to override
-	 * {@link #customCssPackage()} to indicate the package that the CSS resides in.
-	 * 
-	 * @see #customCssPackage()
-	 */
-	protected String customCss() {
-		return DEFAULT_CONCORDION_CSS;
-	}
-
-	private String combine(String tmpDir, String... paths) {
-		StringBuilder buf = new StringBuilder(tmpDir);
-		for(String path: paths) {
-			if (buf.charAt(buf.length()-1) != File.separatorChar) {
-				buf.append(File.separatorChar);	
-			}
-			buf.append(path);
-		}
-		return buf.toString();
-	}
-
-	private Concordion createConcordion() {
-		if (targetDir() == null) {
-			throw new IllegalStateException("targetDir() cannot be null");
-		}
-		ConcordionBuilder builder = new ConcordionBuilder()
-			.withTarget(new FileTarget(new File(targetDir())))
-			.withCommand(NS_URI, CMD_EXECUTE, new ExecuteCommandWithHeader());
-		return builder.build();
-	}
-
-	@SuppressWarnings("unused")
-	private ConfigurationBuilder configurationBuilder;
-
-	public String getConfigDirectory() {
-		return getStory().getConfigDirectory();
-	}
-
-	public DeploymentType getDeploymentType() {
-		return getStory().getDeploymentType();
-	}
-
-	public boolean initNakedObjects(String configDirectory,
-			String deploymentType) {
-		getStory().setConfigDirectory(configDirectory);
-		if (DeploymentType.EXPLORATION.toString().equalsIgnoreCase(
-				deploymentType)) {
-			getStory().enableExploration();
-		}
-		ConfigurationBuilderFileSystem configurationBuilder = new ConfigurationBuilderFileSystem(
-				getConfigDirectory());
-		InitNakedObjects initializer = new InitNakedObjects(
-				getStory(), configurationBuilder, getDeploymentType());
-		initializer.initialize();
-		return true; // any runtime exception will propogate
-	}
-
-	public void aliasAs(String alias, ObjectAdapter adapter) {
-		getStory().aliasAs(alias, adapter);
-	}
-
-	public String aliasPrefixedAs(String prefix, ObjectAdapter adapter) {
-		return getStory().aliasPrefixedAs(prefix, adapter);
-	}
-
-	public void aliasServiceAs(String alias, String serviceClassName)
-			throws StoryValueException {
-		getStory().registerService(alias, serviceClassName);
-	}
-
-	public String getAlias(ObjectAdapter adapter) {
-		return getStory().getAlias(adapter);
-	}
-
-	public ObjectAdapter getAliased(String alias) {
-		return getStory().getAliased(alias);
-	}
-
-	public boolean logonAs(String userName) {
-		getStory().logonAs(userName);
-		return true;
-	}
-
-	public boolean logonAsWithRoles(String userName, String roleList) {
-		getStory().logonAsWithRoles(userName, roleList);
-		return true;
-	}
-
-	public void switchUser(String userName) {
-		getStory().switchUser(userName);
-	}
-
-	public void switchUserWithRoles(String userName, String roleList) {
-		getStory().switchUserWithRoles(userName, roleList);
-	}
-
-	public boolean dateIs(String dateAndTimeStr) throws StoryValueException {
-		getStory().dateIs(asDateAndTime(dateAndTimeStr));
-		return true;
-	}
-
-	public boolean dateIsNow(String dateAndTimeStr) throws StoryValueException {
-		getStory().dateIsNow(asDateAndTime(dateAndTimeStr));
-		return true;
-	}
-
-	public boolean timeIs(String dateAndTimeStr) throws StoryValueException {
-		getStory().timeIs(asDateAndTime(dateAndTimeStr));
-		return true;
-	}
-
-	public boolean timeIsNow(String dateAndTimeStr) throws StoryValueException {
-		getStory().timeIsNow(asDateAndTime(dateAndTimeStr));
-		return true;
-	}
-
-	private Date asDateAndTime(String dateAndTimeStr)
-			throws StoryValueException {
-		try {
-			Date dateAndTime = DATE_FORMAT.parse(dateAndTimeStr);
-			return dateAndTime;
-		} catch (ParseException e) {
-			throw new StoryValueException(e);
-		}
-	}
-
-	private AliasServicesForConcordion aliasServices;
-
-	public boolean aliasService(String className, String alias) {
-		return aliasServices(className, alias);
-	}
-
-	public boolean aliasServices(String className, String alias) {
-		if (aliasServices == null) {
-			aliasServices = new AliasServicesForConcordion(getStory());
-		}
-		aliasServices.execute(alias, className);
-		return true;
-	}
-
-	public void shutdownNakedObjects() {
-		getStory().shutdownNakedObjects();
-	}
-
-	public String setUpObject(String className, String alias, String arg0) {
-		return setUpObjectsVarargs(className, alias, arg0);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4, String arg5) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4, arg5);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4, String arg5,
-			String arg6) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4, arg5, arg6);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4, String arg5,
-			String arg6, String arg7) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4, arg5, arg6, arg7);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4, String arg5,
-			String arg6, String arg7, String arg8) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4, arg5, arg6, arg7, arg8);
-	}
-
-	public String setUpObject(String className, String alias, String arg0,
-			String arg1, String arg2, String arg3, String arg4, String arg5,
-			String arg6, String arg7, String arg8, String arg9) {
-		return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3,
-				arg4, arg5, arg6, arg7, arg8, arg9);
-	}
-
-	private SetUpObjectsForConcordion setUpObjects;
-
-	/**
-	 * Workaround for OGNL defect.
-	 */
-	private String setUpObjectsVarargs(String className, String alias,
-			String... propertyValues) {
-		if (executingInline()) {
-			setUpObjects = new SetUpObjectsForConcordion(getStory(), className,
-					Mode.PERSIST);
-			setUpObjects.executeHeader(alias, propertyValues);
-			return setUpObjects.executeRow(alias, propertyValues);
-		} else {
-			if (executingTableHeader()) {
-				setUpObjects = new SetUpObjectsForConcordion(getStory(), className,
-						Mode.PERSIST);
-				return setUpObjects.executeHeader(alias, propertyValues);
-			} else {
-				return setUpObjects.executeRow(alias, propertyValues);
-			}
-		}
-	}
-
-	private UsingNakedObjectsViewerForConcordion usingNakedObjectsViewer;
-
-	public String usingNakedObjectsViewer(String onObject,
-			String aliasResultAs, String perform, String usingMember) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, null, null, null);
-	}
-
-	public String usingNakedObjectsViewerThat(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, null, null, null);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0, String arg1) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0, arg1);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0, String arg1, String arg2) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0, arg1, arg2);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0, String arg1, String arg2, String arg3) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0, arg1, arg2, arg3);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0, String arg1, String arg2, String arg3, String arg4) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0, arg1, arg2, arg3, arg4);
-	}
-
-	public String usingNakedObjectsViewerArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String arg0, String arg1, String arg2, String arg3, String arg4,
-			String arg5) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, null, arg0, arg1, arg2, arg3, arg4, arg5);
-	}
-
-	public String usingNakedObjectsViewerThatArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, arg0);
-	}
-
-	public String usingNakedObjectsViewerThatArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0, String arg1) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, arg0, arg1);
-	}
-
-	public String usingNakedObjectsViewerThatArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0, String arg1, String arg2) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, arg0, arg1, arg2);
-	}
-
-	public String usingNakedObjectsViewerThatArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0, String arg1, String arg2, String arg3) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, arg0, arg1, arg2, arg3);
-	}
-
-	public String usingNakedObjectsViewerThatArgs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0, String arg1, String arg2, String arg3,
-			String arg4) {
-		return usingNakedObjectsViewerThatArgsVarargs(onObject, aliasResultAs,
-				perform, usingMember, thatIt, arg0, arg1, arg2, arg3, arg4);
-	}
-
-	private String usingNakedObjectsViewerThatArgsVarargs(String onObject,
-			String aliasResultAs, String perform, String usingMember,
-			String thatIt, String arg0, String... remainingArgs) {
-		if (executingInline()) {
-			usingNakedObjectsViewer = new UsingNakedObjectsViewerForConcordion(
-					getStory(), Perform.Mode.TEST);
-			usingNakedObjectsViewer.executeHeader(onObject, aliasResultAs,
-					perform, usingMember, thatIt, arg0, remainingArgs);
-			return usingNakedObjectsViewer.executeRow(onObject, aliasResultAs,
-					perform, usingMember, thatIt, arg0, remainingArgs);
-		} else {
-			if (executingTableHeader()) {
-				usingNakedObjectsViewer = new UsingNakedObjectsViewerForConcordion(
-						getStory(), Perform.Mode.TEST);
-				return usingNakedObjectsViewer.executeHeader(onObject, aliasResultAs,
-						perform, usingMember, thatIt, arg0, remainingArgs);
-			} else {
-				return usingNakedObjectsViewer.executeRow(onObject, aliasResultAs,
-						perform, usingMember, thatIt, arg0, remainingArgs);
-			}
-		}
-	}
-
-	private AliasItemsInListForConcordion aliasItemsInList;
-
-	public String aliasItemsInList(String listAlias, String title,
-			String aliasAs) {
-		return aliasItemsInList(listAlias, title, null, aliasAs);
-	}
-
-	public String aliasItemsInList(String listAlias, String title, String type,
-			String aliasAs) {
-		aliasItemsInList = new AliasItemsInListForConcordion(getStory(),
-				listAlias);
-		return aliasItemsInList.execute(aliasAs, title, type);
-	}
-
-	private boolean executingTableHeader() {
-		return executingTable() && 
-			   ExecuteCommandWithHeader.tableRow
-			.get() == ExecuteCommandWithHeader.TableRow.HEADER;
-	}
-
-	private boolean executingTable() {
-		ExecuteCommandWithHeader.Context context = ExecuteCommandWithHeader.context
-		.get();
-		return context == ExecuteCommandWithHeader.Context.TABLE;
-	}
-
-	private boolean executingInline() {
-		return !executingTable();
-	}
-
-	public void runViewer() {
-		getStory().runViewer();
-	}
+    public static final String DEFAULT_CONCORDION_CSS = "concordion.css";
+    public static final String DEFAULT_TARGET_DIR = "/tmp/concordion";
+
+    private final static String NS_URI = "http://isis.apache.org/2010/concordion";
+    private static final String CMD_EXECUTE = "execute";
+    private final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd MMM yyyy
hh:mm");
+
+    private static ThreadLocal<Story> storyThreadLocal = new ThreadLocal<Story>()
{
+        @Override
+        protected Story initialValue() {
+            return new Story();
+        }
+    };
+
+    protected static Story getStory() {
+        return storyThreadLocal.get();
+    }
+
+    @Test
+    public void runStory() throws Throwable {
+        Concordion concordion = createConcordion();
+        ResultSummary resultSummary = concordion.process(this);
+        resultSummary.print(System.out, this);
+        resultSummary.assertIsSatisfied(this);
+        copyCustomCssIfDefined();
+    }
+
+    private void copyCustomCssIfDefined() {
+        Class<?> cssClass = customCssPackage();
+        String customCss = customCss();
+        if (cssClass == null || customCss == null) {
+            return;
+        }
+        InputStream cssInputFile = cssClass.getResourceAsStream(customCss);
+        String cssPackageName = cssClass.getPackage().getName();
+        String cssPackagePath = asPath(cssPackageName);
+        String cssOutputFileName = combine(targetDir(), cssPackagePath, customCss);
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            IoUtils.copy(cssInputFile, baos);
+            if (baos.size() > 0) {
+                IoUtils.copy(new ByteArrayInputStream(baos.toByteArray()), new FileOutputStream(cssOutputFileName));
+            }
+        } catch (IllegalArgumentException e) {
+            System.err.printf("failed to copy custom CSS to '%s'\n", customCss, cssOutputFileName);
+            return;
+        } catch (IOException e) {
+            System.err.printf("failed to copy custom CSS '%s' to '%s'\n", customCss, cssOutputFileName);
+            return;
+        }
+    }
+
+    private String asPath(String name) {
+        return name.replace('.', File.separatorChar);
+    }
+
+    /**
+     * Optional hook method to specify the directory to which the processed HTML should be
copied.
+     * 
+     * <p>
+     * Defaults to {@value #DEFAULT_TARGET_DIR}.
+     */
+    protected String targetDir() {
+        return DEFAULT_TARGET_DIR;
+    }
+
+    /**
+     * Optional hook method to specify the class (any class) that resides in the same package
as the
+     * {@link #customCss()}.
+     * 
+     * <p>
+     * Return <tt>null</tt> if no custom CSS has been provided.
+     * 
+     * @see #customCss()
+     */
+    protected Class<?> customCssPackage() {
+        return null;
+    }
+
+    /**
+     * Optional hook method to specify the name of the custom CSS file.
+     * 
+     * <p>
+     * Defaults to {@value #DEFAULT_CONCORDION_CSS} so you do not need to override if your
custom CSS file has this
+     * name. However, it is necessary to override {@link #customCssPackage()} to indicate
the package that the CSS
+     * resides in.
+     * 
+     * @see #customCssPackage()
+     */
+    protected String customCss() {
+        return DEFAULT_CONCORDION_CSS;
+    }
+
+    private String combine(String tmpDir, String... paths) {
+        StringBuilder buf = new StringBuilder(tmpDir);
+        for (String path : paths) {
+            if (buf.charAt(buf.length() - 1) != File.separatorChar) {
+                buf.append(File.separatorChar);
+            }
+            buf.append(path);
+        }
+        return buf.toString();
+    }
+
+    private Concordion createConcordion() {
+        if (targetDir() == null) {
+            throw new IllegalStateException("targetDir() cannot be null");
+        }
+        ConcordionBuilder builder =
+            new ConcordionBuilder().withTarget(new FileTarget(new File(targetDir()))).withCommand(NS_URI,
CMD_EXECUTE,
+                new ExecuteCommandWithHeader());
+        return builder.build();
+    }
+
+    @SuppressWarnings("unused")
+    private ConfigurationBuilder configurationBuilder;
+
+    public String getConfigDirectory() {
+        return getStory().getConfigDirectory();
+    }
+
+    public DeploymentType getDeploymentType() {
+        return getStory().getDeploymentType();
+    }
+
+    public boolean bootstrapIsis(String configDirectory, String deploymentType) {
+        getStory().setConfigDirectory(configDirectory);
+        if (DeploymentType.EXPLORATION.toString().equalsIgnoreCase(deploymentType)) {
+            getStory().enableExploration();
+        }
+        ConfigurationBuilderFileSystem configurationBuilder = new ConfigurationBuilderFileSystem(getConfigDirectory());
+        IsisInitializer initializer = new IsisInitializer(getStory(), configurationBuilder,
getDeploymentType());
+        initializer.initialize();
+        return true; // any runtime exception will propogate
+    }
+
+    public void aliasAs(String alias, ObjectAdapter adapter) {
+        getStory().aliasAs(alias, adapter);
+    }
+
+    public String aliasPrefixedAs(String prefix, ObjectAdapter adapter) {
+        return getStory().aliasPrefixedAs(prefix, adapter);
+    }
+
+    public void aliasServiceAs(String alias, String serviceClassName) throws StoryValueException
{
+        getStory().registerService(alias, serviceClassName);
+    }
+
+    public String getAlias(ObjectAdapter adapter) {
+        return getStory().getAlias(adapter);
+    }
+
+    public ObjectAdapter getAliased(String alias) {
+        return getStory().getAliased(alias);
+    }
+
+    public boolean logonAs(String userName) {
+        getStory().logonAs(userName);
+        return true;
+    }
+
+    public boolean logonAsWithRoles(String userName, String roleList) {
+        getStory().logonAsWithRoles(userName, roleList);
+        return true;
+    }
+
+    public void switchUser(String userName) {
+        getStory().switchUser(userName);
+    }
+
+    public void switchUserWithRoles(String userName, String roleList) {
+        getStory().switchUserWithRoles(userName, roleList);
+    }
+
+    public boolean dateIs(String dateAndTimeStr) throws StoryValueException {
+        getStory().dateIs(asDateAndTime(dateAndTimeStr));
+        return true;
+    }
+
+    public boolean dateIsNow(String dateAndTimeStr) throws StoryValueException {
+        getStory().dateIsNow(asDateAndTime(dateAndTimeStr));
+        return true;
+    }
+
+    public boolean timeIs(String dateAndTimeStr) throws StoryValueException {
+        getStory().timeIs(asDateAndTime(dateAndTimeStr));
+        return true;
+    }
+
+    public boolean timeIsNow(String dateAndTimeStr) throws StoryValueException {
+        getStory().timeIsNow(asDateAndTime(dateAndTimeStr));
+        return true;
+    }
+
+    private Date asDateAndTime(String dateAndTimeStr) throws StoryValueException {
+        try {
+            Date dateAndTime = DATE_FORMAT.parse(dateAndTimeStr);
+            return dateAndTime;
+        } catch (ParseException e) {
+            throw new StoryValueException(e);
+        }
+    }
+
+    private AliasServicesForConcordion aliasServices;
+
+    public boolean aliasService(String className, String alias) {
+        return aliasServices(className, alias);
+    }
+
+    public boolean aliasServices(String className, String alias) {
+        if (aliasServices == null) {
+            aliasServices = new AliasServicesForConcordion(getStory());
+        }
+        aliasServices.execute(alias, className);
+        return true;
+    }
+
+    public void shutdownNakedObjects() {
+        getStory().shutdownNakedObjects();
+    }
+
+    public String setUpObject(String className, String alias, String arg0) {
+        return setUpObjectsVarargs(className, alias, arg0);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4, String arg5) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4, String arg5, String arg6) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5,
arg6);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4, String arg5, String arg6, String arg7) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5,
arg6, arg7);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4, String arg5, String arg6, String arg7, String arg8) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5,
arg6, arg7, arg8);
+    }
+
+    public String setUpObject(String className, String alias, String arg0, String arg1, String
arg2, String arg3,
+        String arg4, String arg5, String arg6, String arg7, String arg8, String arg9) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5,
arg6, arg7, arg8, arg9);
+    }
+
+    private SetUpObjectsForConcordion setUpObjects;
+
+    /**
+     * Workaround for OGNL defect.
+     */
+    private String setUpObjectsVarargs(String className, String alias, String... propertyValues)
{
+        if (executingInline()) {
+            setUpObjects = new SetUpObjectsForConcordion(getStory(), className, Mode.PERSIST);
+            setUpObjects.executeHeader(alias, propertyValues);
+            return setUpObjects.executeRow(alias, propertyValues);
+        } else {
+            if (executingTableHeader()) {
+                setUpObjects = new SetUpObjectsForConcordion(getStory(), className, Mode.PERSIST);
+                return setUpObjects.executeHeader(alias, propertyValues);
+            } else {
+                return setUpObjects.executeRow(alias, propertyValues);
+            }
+        }
+    }
+
+    private UsingIsisViewerForConcordion usingIsisViewer;
+
+    public String usingIsisViewer(String onObject, String aliasResultAs, String perform,
String usingMember) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, null, null,
+            null);
+    }
+
+    public String usingIsisViewerThat(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, null,
+            null, null);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0, String arg1) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0, arg1);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0, String arg1, String arg2) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0, arg1,
+            arg2);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0, String arg1, String arg2, String arg3) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0, arg1,
+            arg2, arg3);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0, String arg1, String arg2, String arg3, String arg4)
{
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0, arg1,
+            arg2, arg3, arg4);
+    }
+
+    public String usingIsisViewerArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String arg0, String arg1, String arg2, String arg3, String arg4,
String arg5) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
null, arg0, arg1,
+            arg2, arg3, arg4, arg5);
+    }
+
+    public String usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt, String arg0) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0);
+    }
+
+    public String usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt, String arg0, String arg1) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0, arg1);
+    }
+
+    public String usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt, String arg0, String arg1, String arg2) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+            arg1, arg2);
+    }
+
+    public String usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt, String arg0, String arg1, String arg2, String
arg3) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+            arg1, arg2, arg3);
+    }
+
+    public String usingIsisViewerThatArgs(String onObject, String aliasResultAs, String perform,
+        String usingMember, String thatIt, String arg0, String arg1, String arg2, String
arg3, String arg4) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+            arg1, arg2, arg3, arg4);
+    }
+
+    private String usingIsisViewerThatArgsVarargs(String onObject, String aliasResultAs,
String perform,
+        String usingMember, String thatIt, String arg0, String... remainingArgs) {
+        if (executingInline()) {
+            usingIsisViewer = new UsingIsisViewerForConcordion(getStory(), Perform.Mode.TEST);
+            usingIsisViewer.executeHeader(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+                remainingArgs);
+            return usingIsisViewer.executeRow(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+                remainingArgs);
+        } else {
+            if (executingTableHeader()) {
+                usingIsisViewer = new UsingIsisViewerForConcordion(getStory(), Perform.Mode.TEST);
+                return usingIsisViewer.executeHeader(onObject, aliasResultAs, perform, usingMember,
thatIt,
+                    arg0, remainingArgs);
+            } else {
+                return usingIsisViewer.executeRow(onObject, aliasResultAs, perform, usingMember,
thatIt, arg0,
+                    remainingArgs);
+            }
+        }
+    }
+
+    private AliasItemsInListForConcordion aliasItemsInList;
+
+    public String aliasItemsInList(String listAlias, String title, String aliasAs) {
+        return aliasItemsInList(listAlias, title, null, aliasAs);
+    }
+
+    public String aliasItemsInList(String listAlias, String title, String type, String aliasAs)
{
+        aliasItemsInList = new AliasItemsInListForConcordion(getStory(), listAlias);
+        return aliasItemsInList.execute(aliasAs, title, type);
+    }
+
+    private boolean executingTableHeader() {
+        return executingTable() && ExecuteCommandWithHeader.tableRow.get() == ExecuteCommandWithHeader.TableRow.HEADER;
+    }
+
+    private boolean executingTable() {
+        ExecuteCommandWithHeader.Context context = ExecuteCommandWithHeader.context.get();
+        return context == ExecuteCommandWithHeader.Context.TABLE;
+    }
+
+    private boolean executingInline() {
+        return !executingTable();
+    }
+
+    public void runViewer() {
+        getStory().runViewer();
+    }
 
 }

Copied: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java
(from r1031497, incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingNakedObjectsViewerForConcordion.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java?p2=incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java&p1=incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingNakedObjectsViewerForConcordion.java&r1=1031497&r2=1031521&rev=1031521&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingNakedObjectsViewerForConcordion.java
(original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/UsingIsisViewerForConcordion.java
Fri Nov  5 11:35:56 2010
@@ -17,12 +17,12 @@ import org.apache.isis.viewer.bdd.concor
 
 import com.google.common.collect.Lists;
 
-public class UsingNakedObjectsViewerForConcordion extends
+public class UsingIsisViewerForConcordion extends
 		AbstractFixture<UsingNakedObjectsViewerPeer> {
 
 	private final List<String> argumentCells = new ArrayList<String>();
 
-	public UsingNakedObjectsViewerForConcordion(
+	public UsingIsisViewerForConcordion(
 			final AliasRegistry aliasesRegistry,
 			final Perform.Mode mode) {
 		this(aliasesRegistry, mode, 
@@ -46,7 +46,7 @@ public class UsingNakedObjectsViewerForC
 						.optional().build());
 	}
 
-	private UsingNakedObjectsViewerForConcordion(
+	private UsingIsisViewerForConcordion(
 			final AliasRegistry aliasesRegistry,
 			final Perform.Mode mode,
 			final CellBinding onObjectBinding,



Mime
View raw message