incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1098945 [6/25] - in /incubator/isis/trunk/viewer: bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/components/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common...
Date Tue, 03 May 2011 07:18:38 GMT
Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/AliasRegistryDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/AliasRegistryDefault.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/AliasRegistryDefault.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/AliasRegistryDefault.java Tue May  3 07:18:19 2011
@@ -16,93 +16,93 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.common.story.registries;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.viewer.bdd.common.AliasRegistry;
-import org.apache.isis.viewer.bdd.common.ScenarioValueException;
-
-public class AliasRegistryDefault implements AliasRegistry {
-
-    private final Map<String, ObjectAdapter> adaptersByAlias = new HashMap<String, ObjectAdapter>();
-    private final Map<ObjectAdapter, String> aliasesByAdapter = new HashMap<ObjectAdapter, String>();
-
-    /**
-     * @see #nextAlias()
-     * @see #aliasPrefixedAs(String, NakedObject)
-     */
-    private final Map<String, int[]> aliasCountsByPrefix = new TreeMap<String, int[]>();
-
-    @Override
-    public void aliasAs(final String alias, final ObjectAdapter adapter) {
-        adaptersByAlias.put(alias, adapter);
-        aliasesByAdapter.put(adapter, alias);
-    }
-
-    @Override
-    public ObjectAdapter getAliased(final String alias) {
-        return adaptersByAlias.get(alias);
-    }
-
-    @Override
-    public String getAlias(final ObjectAdapter adapter) {
-        return aliasesByAdapter.get(adapter);
-    }
-
-    @Override
-    public String aliasPrefixedAs(final String prefix, final ObjectAdapter adapter) {
-        int[] aliasCountForPrefix = aliasCountsByPrefix.get(prefix);
-        if (aliasCountForPrefix == null) {
-            aliasCountForPrefix = new int[1];
-            aliasCountsByPrefix.put(prefix, aliasCountForPrefix);
-        }
-        final String nextAliasForPrefix = nextAlias(prefix, aliasCountForPrefix);
-        adaptersByAlias.put(nextAliasForPrefix, adapter);
-        return nextAliasForPrefix;
-    }
-
-    private String nextAlias(final String prefix, final int[] heldAsCount) {
-        return prefix + "#" + (++heldAsCount[0]);
-    }
-
-    @Override
-    public Iterator<Entry<String, ObjectAdapter>> iterator() {
-        final Set<Entry<String, ObjectAdapter>> entrySet = adaptersByAlias.entrySet();
-        return Collections.unmodifiableSet(entrySet).iterator();
-    }
-
-    @Override
-    public void aliasService(final String aliasAs, final String className) throws ScenarioValueException {
-        final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
-        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
-            if (serviceAdapter.getSpecification().getFullIdentifier().equals(className)) {
-                adaptersByAlias.put(aliasAs, serviceAdapter);
-                return;
-            }
-        }
-        throw new ScenarioValueException("no such service");
-    }
-
-    protected PersistenceSession getPersistenceSession() {
-        return IsisContext.getPersistenceSession();
-    }
-
-    @Override
-    public void clear() {
-        this.adaptersByAlias.clear();
-        this.aliasesByAdapter.clear();
-        this.aliasCountsByPrefix.clear();
-    }
-
-}
+package org.apache.isis.viewer.bdd.common.story.registries;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.viewer.bdd.common.AliasRegistry;
+import org.apache.isis.viewer.bdd.common.ScenarioValueException;
+
+public class AliasRegistryDefault implements AliasRegistry {
+
+    private final Map<String, ObjectAdapter> adaptersByAlias = new HashMap<String, ObjectAdapter>();
+    private final Map<ObjectAdapter, String> aliasesByAdapter = new HashMap<ObjectAdapter, String>();
+
+    /**
+     * @see #nextAlias()
+     * @see #aliasPrefixedAs(String, NakedObject)
+     */
+    private final Map<String, int[]> aliasCountsByPrefix = new TreeMap<String, int[]>();
+
+    @Override
+    public void aliasAs(final String alias, final ObjectAdapter adapter) {
+        adaptersByAlias.put(alias, adapter);
+        aliasesByAdapter.put(adapter, alias);
+    }
+
+    @Override
+    public ObjectAdapter getAliased(final String alias) {
+        return adaptersByAlias.get(alias);
+    }
+
+    @Override
+    public String getAlias(final ObjectAdapter adapter) {
+        return aliasesByAdapter.get(adapter);
+    }
+
+    @Override
+    public String aliasPrefixedAs(final String prefix, final ObjectAdapter adapter) {
+        int[] aliasCountForPrefix = aliasCountsByPrefix.get(prefix);
+        if (aliasCountForPrefix == null) {
+            aliasCountForPrefix = new int[1];
+            aliasCountsByPrefix.put(prefix, aliasCountForPrefix);
+        }
+        final String nextAliasForPrefix = nextAlias(prefix, aliasCountForPrefix);
+        adaptersByAlias.put(nextAliasForPrefix, adapter);
+        return nextAliasForPrefix;
+    }
+
+    private String nextAlias(final String prefix, final int[] heldAsCount) {
+        return prefix + "#" + (++heldAsCount[0]);
+    }
+
+    @Override
+    public Iterator<Entry<String, ObjectAdapter>> iterator() {
+        final Set<Entry<String, ObjectAdapter>> entrySet = adaptersByAlias.entrySet();
+        return Collections.unmodifiableSet(entrySet).iterator();
+    }
+
+    @Override
+    public void aliasService(final String aliasAs, final String className) throws ScenarioValueException {
+        final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
+        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
+            if (serviceAdapter.getSpecification().getFullIdentifier().equals(className)) {
+                adaptersByAlias.put(aliasAs, serviceAdapter);
+                return;
+            }
+        }
+        throw new ScenarioValueException("no such service");
+    }
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+    @Override
+    public void clear() {
+        this.adaptersByAlias.clear();
+        this.aliasesByAdapter.clear();
+        this.aliasCountsByPrefix.clear();
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/ServiceRegistrySpi.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/ServiceRegistrySpi.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/ServiceRegistrySpi.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/story/registries/ServiceRegistrySpi.java Tue May  3 07:18:19 2011
@@ -20,7 +20,6 @@ package org.apache.isis.viewer.bdd.commo
 
 import org.apache.isis.viewer.bdd.common.ServiceRegistry;
 
-
 public interface ServiceRegistrySpi extends ServiceRegistry {
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/util/Strings.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/util/Strings.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/util/Strings.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/util/Strings.java Tue May  3 07:18:19 2011
@@ -16,13 +16,11 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.common.util;
-
-
-
-public final class Strings {
-
-    private Strings() {
-    }
-
-}
+package org.apache.isis.viewer.bdd.common.util;
+
+public final class Strings {
+
+    private Strings() {
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/parsers/DateParserTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/parsers/DateParserTest.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/parsers/DateParserTest.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/parsers/DateParserTest.java Tue May  3 07:18:19 2011
@@ -16,35 +16,33 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.common.parsers;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.util.Date;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-
-public class DateParserTest {
-
-    /**
-     * Tracking down problem in ISIS-18...
-     * <p>
-     * This fails because 'MMM' is gonna be different in different languages.
-     */
-    @Ignore
-    @Test
-    public void parsesUnder_enUK_butNotUnder_deDE() throws Exception {
-        DateParser dateParser = new DateParser();
-        dateParser.setDateFormat("dd-MMM-yyyy");
-        dateParser.setTimeFormat("hh:mm");
-        Date parse = dateParser.parse("02-May-2010 09:20");
-        assertThat(parse, is(not(nullValue())));
-    }
-
-
-}
+package org.apache.isis.viewer.bdd.common.parsers;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.Date;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class DateParserTest {
+
+    /**
+     * Tracking down problem in ISIS-18...
+     * <p>
+     * This fails because 'MMM' is gonna be different in different languages.
+     */
+    @Ignore
+    @Test
+    public void parsesUnder_enUK_butNotUnder_deDE() throws Exception {
+        final DateParser dateParser = new DateParser();
+        dateParser.setDateFormat("dd-MMM-yyyy");
+        dateParser.setTimeFormat("hh:mm");
+        final Date parse = dateParser.parse("02-May-2010 09:20");
+        assertThat(parse, is(not(nullValue())));
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/registries/AliasesRegistryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/registries/AliasesRegistryTest.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/registries/AliasesRegistryTest.java (original)
+++ incubator/isis/trunk/viewer/bdd/common/src/test/java/org/apache/isis/viewer/bdd/common/registries/AliasesRegistryTest.java Tue May  3 07:18:19 2011
@@ -16,59 +16,59 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.common.registries;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.bdd.common.story.registries.AliasRegistryDefault;
-import org.hamcrest.CoreMatchers;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(JMock.class)
-public class AliasesRegistryTest {
-
-    private final Mockery mockery = new JUnit4Mockery();
-
-    private AliasRegistryDefault registry;
-
-    private ObjectAdapter mockAdapter1;
-    private ObjectAdapter mockAdapter2;
-    @SuppressWarnings("unused")
-    private ObjectAdapter mockAdapter3;
-
-    @Before
-    public void setUp() throws Exception {
-        mockAdapter1 = mockery.mock(ObjectAdapter.class, "adapter1");
-        mockAdapter2 = mockery.mock(ObjectAdapter.class, "adapter2");
-        mockAdapter3 = mockery.mock(ObjectAdapter.class, "adapter3");
-        registry = new AliasRegistryDefault();
-    }
-
-    @Test
-    public void registerOneAdapter() {
-        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
-        Assert.assertThat(heldAs1, CoreMatchers.is("Foo#1"));
-    }
-
-    @Test
-    public void registerTwoAdaptersOfSamePrefix() {
-        @SuppressWarnings("unused")
-        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
-        final String heldAs2 = registry.aliasPrefixedAs("Foo", mockAdapter2);
-        Assert.assertThat(heldAs2, CoreMatchers.is("Foo#2"));
-    }
-
-    @Test
-    public void registerAdaptersOfDiffereingPrefixes() {
-        @SuppressWarnings("unused")
-        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
-        final String heldAs2 = registry.aliasPrefixedAs("Bar", mockAdapter2);
-        Assert.assertThat(heldAs2, CoreMatchers.is("Bar#1"));
-    }
-
-}
+package org.apache.isis.viewer.bdd.common.registries;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.bdd.common.story.registries.AliasRegistryDefault;
+import org.hamcrest.CoreMatchers;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(JMock.class)
+public class AliasesRegistryTest {
+
+    private final Mockery mockery = new JUnit4Mockery();
+
+    private AliasRegistryDefault registry;
+
+    private ObjectAdapter mockAdapter1;
+    private ObjectAdapter mockAdapter2;
+    @SuppressWarnings("unused")
+    private ObjectAdapter mockAdapter3;
+
+    @Before
+    public void setUp() throws Exception {
+        mockAdapter1 = mockery.mock(ObjectAdapter.class, "adapter1");
+        mockAdapter2 = mockery.mock(ObjectAdapter.class, "adapter2");
+        mockAdapter3 = mockery.mock(ObjectAdapter.class, "adapter3");
+        registry = new AliasRegistryDefault();
+    }
+
+    @Test
+    public void registerOneAdapter() {
+        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
+        Assert.assertThat(heldAs1, CoreMatchers.is("Foo#1"));
+    }
+
+    @Test
+    public void registerTwoAdaptersOfSamePrefix() {
+        @SuppressWarnings("unused")
+        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
+        final String heldAs2 = registry.aliasPrefixedAs("Foo", mockAdapter2);
+        Assert.assertThat(heldAs2, CoreMatchers.is("Foo#2"));
+    }
+
+    @Test
+    public void registerAdaptersOfDiffereingPrefixes() {
+        @SuppressWarnings("unused")
+        final String heldAs1 = registry.aliasPrefixedAs("Foo", mockAdapter1);
+        final String heldAs2 = registry.aliasPrefixedAs("Bar", mockAdapter2);
+        Assert.assertThat(heldAs2, CoreMatchers.is("Bar#1"));
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionScenario.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionScenario.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionScenario.java (original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/AbstractIsisConcordionScenario.java Tue May  3 07:18:19 2011
@@ -16,551 +16,572 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.concordion;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.isis.core.commons.lang.IoUtils;
-import org.apache.isis.core.commons.lang.StringUtils;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
-import org.apache.isis.viewer.bdd.common.Scenario;
-import org.apache.isis.viewer.bdd.common.ScenarioValueException;
-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.concordion.internal.concordion.IsisExecuteCommandWithHeader;
-import org.apache.isis.viewer.bdd.concordion.internal.fixtures.AliasItemsInListForConcordion;
-import org.apache.isis.viewer.bdd.concordion.internal.fixtures.CheckCollectionContentsForConcordion;
-import org.apache.isis.viewer.bdd.concordion.internal.fixtures.CheckListForConcordion;
-import org.apache.isis.viewer.bdd.concordion.internal.fixtures.SetUpObjectsForConcordion;
-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;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
-
-public abstract class AbstractIsisConcordionScenario {
-
-    public static final String DEFAULT_CONCORDION_CSS = "concordion.css";
-    
-    /**
-     * The system property that is searched for to use as the {@link #outputDir() target directory}.
-     */
-    public static final String DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY = "concordion.output.dir";
-    
-    /**
-     * The directory used by default if the {@link #DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY default property}
-     * for the {@link #outputDir() target directory} is not specified (and the {@link #outputDir()} method
-     * has not been overridden). 
-     */
-    public static final String DEFAULT_OUTPUT_DIR = "/tmp/concordion";
-
-    public static final String NS_URI = "http://isis.apache.org/2010/concordion";
-    private static final String CMD_EXECUTE = "execute";
-    
-    private static ThreadLocal<Scenario> scenarioThreadLocal = new ThreadLocal<Scenario>() {
-        @Override
-        protected Scenario initialValue() {
-            return new Scenario();
-        }
-    };
-
-    public static Scenario getScenario() {
-        return scenarioThreadLocal.get();
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // @Test
-    // ////////////////////////////////////////////////////////////////////////
-
-    @Test
-    public void runScenario() throws Throwable {
-        try {
-            Concordion concordion = createConcordion();
-            ResultSummary resultSummary = concordion.process(this);
-            resultSummary.print(System.out, this);
-            resultSummary.assertIsSatisfied(this);
-        } finally {
-            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 = StringUtils.combinePaths(outputDir(), 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);
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // Hooks
-    // ////////////////////////////////////////////////////////////////////////
-
-    /**
-     * The directory to which the processed HTML should be copied.
-     * 
-     * <p>
-     * Defaults to the value of the {@value #DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY} system property,
-     * or {@value #DEFAULT_OUTPUT_DIR} if that property is not specified.
-     * 
-     * <p>
-     * Can either be overridden if wish to specify some other mechanism for determining where
-     * the output is generated.
-     */
-    protected String outputDir() {
-        String concordionOutputDir = System
-                .getProperty(DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY);
-        return StringUtils.isNullOrEmpty(concordionOutputDir)  ? DEFAULT_OUTPUT_DIR
-                : concordionOutputDir;
-    }
-
-    /**
-     * 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 Concordion createConcordion() {
-        String targetDir = outputDir();
-        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 IsisExecuteCommandWithHeader());
-        return builder.build();
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // bootstrapIsis / shutdownIsis
-    // ////////////////////////////////////////////////////////////////////////
-
-    /**
-     * For calling within a <tt>#setUp()</tt> method.
-     * 
-     * @see {@link #bootstrapIsis(String, String)}
-     */
-    public void bootstrapIsis(String configDirectory, DeploymentType deploymentType) {
-        getScenario().bootstrapIsis(StringUtils.normalized(configDirectory), deploymentType);
-    }
-
-    /**
-     * For calling from XHTML script.
-     * 
-     * @see #bootstrapIsis(String, DeploymentType)
-     * @return <tt>boolean</tt> so that XHTML can assert on it.
-     */
-    public boolean bootstrapIsis(String configDirectory, String deploymentTypeStr) {
-        bootstrapIsis(configDirectory, DeploymentType.lookup(StringUtils.normalized(deploymentTypeStr)));
-        return true; // any runtime exception will propagate
-    }
-
-    public void shutdownIsis() {
-        getScenario().shutdownIsis();
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // logon as / switch user
-    // ////////////////////////////////////////////////////////////////////////
-
-    public boolean logonAs(String userName) {
-        getScenario().logonAsOrSwitchUserTo(StringUtils.normalized(userName));
-        return true;
-    }
-
-    public boolean logonAsWithRoles(String userName, String roleListStr) {
-        List<String> roleList = StringUtils.splitOnCommas(StringUtils.normalized(roleListStr));
-        getScenario().logonAsOrSwitchUserTo(userName, roleList);
-        return true;
-    }
-
-    public void switchUser(String userName) {
-        logonAs(userName);
-    }
-
-    public void switchUserWithRoles(String userName, String roleListStr) {
-        logonAsWithRoles(userName, roleListStr);
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // date is / time is
-    // ////////////////////////////////////////////////////////////////////////
-
-    public boolean usingDateFormat(String dateFormatStr)  {
-        getScenario().usingDateFormat(dateFormatStr);
-        return true;
-    }
-
-    public boolean usingTimeFormat(String timeFormatStr)  {
-        getScenario().usingTimeFormat(timeFormatStr);
-        return true;
-    }
-
-    public boolean dateIs(String dateAndTimeStr) throws ScenarioValueException {
-        return dateAndTimeIs(dateAndTimeStr);
-    }
-
-    public boolean timeIs(String dateAndTimeStr) throws ScenarioValueException {
-        return dateAndTimeIs(dateAndTimeStr);
-    }
-
-    private boolean dateAndTimeIs(String dateAndTimeStr) throws ScenarioValueException {
-        return getScenario().dateAndTimeIs(dateAndTimeStr);
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // alias service
-    // ////////////////////////////////////////////////////////////////////////
-
-    public boolean aliasService(String aliasAs, String className) {
-        try {
-            getScenario().getAliasRegistry().aliasService(StringUtils.normalized(aliasAs), StringUtils.normalized(className));
-            return true;
-        } catch (ScenarioValueException e) {
-            return false;
-        }
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // setup object
-    // ////////////////////////////////////////////////////////////////////////
-
-    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.
-     */
-    protected String setUpObjectsVarargs(String className, String alias, String... propertyValues) {
-        return setUpObjectsVarargsNormalized(StringUtils.normalized(className), StringUtils.normalized(alias), StringUtils.normalized(propertyValues));
-    }
-
-    private String setUpObjectsVarargsNormalized(String className, String alias, String... propertyValues) {
-        if (executingInline()) {
-            setUpObjects = new SetUpObjectsForConcordion(getScenario().getAliasRegistry(), className, Mode.PERSIST);
-            setUpObjects.executeHeader(alias, propertyValues);
-            return setUpObjects.executeRow(alias, propertyValues);
-        } else {
-            if (executingTableHeader()) {
-                setUpObjects = new SetUpObjectsForConcordion(getScenario().getAliasRegistry(), className, Mode.PERSIST);
-                return setUpObjects.executeHeader(alias, propertyValues);
-            } else {
-                return setUpObjects.executeRow(alias, propertyValues);
-            }
-        }
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // using isis viewer
-    // ////////////////////////////////////////////////////////////////////////
-
-    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);
-    }
-
-    /**
-     * With <tt>protected</tt> visibility so that it can be called by custom methods if required.
-     */
-    protected String usingIsisViewerThatArgsVarargs(String onObject, String aliasResultAs, String perform,
-        String usingMember, String thatIt, String arg0, String... remainingArgs) {
-        return usingIsisViewerThatArgsVarargsNormalized(StringUtils.normalized(onObject), StringUtils.normalized(aliasResultAs), StringUtils.normalized(perform), StringUtils.normalized(usingMember), StringUtils.normalized(thatIt), StringUtils.normalized(arg0),
-            StringUtils.normalized(remainingArgs));
-    }
-
-    private String usingIsisViewerThatArgsVarargsNormalized(String onObject, String aliasResultAs, String perform,
-        String usingMember, String thatIt, String arg0, String... remainingArgs) {
-        if (executingInline()) {
-            usingIsisViewer = new UsingIsisViewerForConcordion(getScenario().getAliasRegistry(), getScenario().getDeploymentType(), getScenario().getDateParser(), 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(getScenario().getAliasRegistry(), getScenario().getDeploymentType(), getScenario().getDateParser(), Perform.Mode.TEST);
-                return usingIsisViewer.executeHeader(onObject, aliasResultAs, perform, usingMember, thatIt, arg0,
-                    remainingArgs);
-            } else {
-                return usingIsisViewer.executeRow(onObject, aliasResultAs, perform, usingMember, thatIt, arg0,
-                    remainingArgs);
-            }
-        }
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // check collection
-    // ////////////////////////////////////////////////////////////////////////
-
-
-    public String checkCollectionIsEmpty(String listAlias) {
-        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)).isEmpty();
-    }
-
-    public String checkCollectionIsNotEmpty(String listAlias) {
-        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)).isNotEmpty();
-    }
-    
-    public String checkCollectionContains(String listAlias, String alias) {
-        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)).contains(StringUtils.normalized(alias));
-    }
-    
-    public String checkCollectionDoesNotContain(String listAlias, String alias) {
-        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)).doesNotContain(StringUtils.normalized(alias));
-    }
-    
-    public String checkCollectionSize(String listAlias, int size) {
-        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)).assertSize(size);
-    }
-    
-    
-
-    // ////////////////////////////////////////////////////////////////////////
-    // check list
-    // ////////////////////////////////////////////////////////////////////////
-
-    private CheckListForConcordion checkList;
-    
-    public String checkList(String listAlias, String title) {
-        if(executingTable()) {
-            if(executingTableHeader()) {
-                checkList = new CheckListForConcordion(getScenario().getAliasRegistry(), listAlias);
-                return checkList.executeHeader(title);
-            } else {
-                return checkList.executeRow(title);
-            }
-        } else {
-            checkList = new CheckListForConcordion(getScenario().getAliasRegistry(), listAlias);
-            checkList.executeHeader(title);
-            return checkList.executeRow(title);
-        }
-    }
-
-
-    // ////////////////////////////////////////////////////////////////////////
-    // getListContents() (for verifyRow)
-    // ////////////////////////////////////////////////////////////////////////
-    
-    public Iterable<Object> getListContents(String listAlias) {
-        ObjectAdapter listAdapter = getScenario().getAliasRegistry().getAliased(StringUtils.normalized(listAlias));
-        if(listAdapter == null) {
-            return Collections.emptyList();
-        }
-        CollectionFacet facet = listAdapter.getSpecification().getFacet(CollectionFacet.class);
-        if(facet==null){
-            return Collections.emptyList();
-        }
-        Iterable<ObjectAdapter> objectAdapters = facet.iterable(listAdapter);
-        return Iterables.transform(objectAdapters, new Function<ObjectAdapter, Object>(){
-
-            @Override
-            public Object apply(ObjectAdapter from) {
-                return from.getObject();
-            }});
-    }
-
-
-    // ////////////////////////////////////////////////////////////////////////
-    // alias items in list
-    // ////////////////////////////////////////////////////////////////////////
-
-    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(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias));
-        return aliasItemsInList.execute(StringUtils.normalized(aliasAs), StringUtils.normalized(title), StringUtils.normalized(type));
-    }
-
-    private boolean executingTableHeader() {
-        return executingTable() && IsisExecuteCommandWithHeader.tableRow.get() == IsisExecuteCommandWithHeader.TableRow.HEADER;
-    }
-
-    private boolean executingTable() {
-        IsisExecuteCommandWithHeader.Context context = IsisExecuteCommandWithHeader.context.get();
-        return context == IsisExecuteCommandWithHeader.Context.TABLE;
-    }
-
-    private boolean executingInline() {
-        return !executingTable();
-    }
-
-    // ////////////////////////////////////////////////////////////////////////
-    // run viewer
-    // ////////////////////////////////////////////////////////////////////////
-
-    public void runViewer() {
-        getScenario().runViewer();
-    }
-
-}
+package org.apache.isis.viewer.bdd.concordion;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.commons.lang.IoUtils;
+import org.apache.isis.core.commons.lang.StringUtils;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.viewer.bdd.common.Scenario;
+import org.apache.isis.viewer.bdd.common.ScenarioValueException;
+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.concordion.internal.concordion.IsisExecuteCommandWithHeader;
+import org.apache.isis.viewer.bdd.concordion.internal.fixtures.AliasItemsInListForConcordion;
+import org.apache.isis.viewer.bdd.concordion.internal.fixtures.CheckCollectionContentsForConcordion;
+import org.apache.isis.viewer.bdd.concordion.internal.fixtures.CheckListForConcordion;
+import org.apache.isis.viewer.bdd.concordion.internal.fixtures.SetUpObjectsForConcordion;
+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;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+public abstract class AbstractIsisConcordionScenario {
+
+    public static final String DEFAULT_CONCORDION_CSS = "concordion.css";
+
+    /**
+     * The system property that is searched for to use as the {@link #outputDir() target directory}.
+     */
+    public static final String DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY = "concordion.output.dir";
+
+    /**
+     * The directory used by default if the {@link #DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY default property} for the
+     * {@link #outputDir() target directory} is not specified (and the {@link #outputDir()} method has not been
+     * overridden).
+     */
+    public static final String DEFAULT_OUTPUT_DIR = "/tmp/concordion";
+
+    public static final String NS_URI = "http://isis.apache.org/2010/concordion";
+    private static final String CMD_EXECUTE = "execute";
+
+    private static ThreadLocal<Scenario> scenarioThreadLocal = new ThreadLocal<Scenario>() {
+        @Override
+        protected Scenario initialValue() {
+            return new Scenario();
+        }
+    };
+
+    public static Scenario getScenario() {
+        return scenarioThreadLocal.get();
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // @Test
+    // ////////////////////////////////////////////////////////////////////////
+
+    @Test
+    public void runScenario() throws Throwable {
+        try {
+            final Concordion concordion = createConcordion();
+            final ResultSummary resultSummary = concordion.process(this);
+            resultSummary.print(System.out, this);
+            resultSummary.assertIsSatisfied(this);
+        } finally {
+            copyCustomCssIfDefined();
+        }
+    }
+
+    private void copyCustomCssIfDefined() {
+        final Class<?> cssClass = customCssPackage();
+        final String customCss = customCss();
+        if (cssClass == null || customCss == null) {
+            return;
+        }
+        final InputStream cssInputFile = cssClass.getResourceAsStream(customCss);
+        final String cssPackageName = cssClass.getPackage().getName();
+        final String cssPackagePath = asPath(cssPackageName);
+        final String cssOutputFileName = StringUtils.combinePaths(outputDir(), cssPackagePath, customCss);
+        try {
+            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            IoUtils.copy(cssInputFile, baos);
+            if (baos.size() > 0) {
+                IoUtils.copy(new ByteArrayInputStream(baos.toByteArray()), new FileOutputStream(cssOutputFileName));
+            }
+        } catch (final IllegalArgumentException e) {
+            System.err.printf("failed to copy custom CSS to '%s'\n", customCss, cssOutputFileName);
+            return;
+        } catch (final IOException e) {
+            System.err.printf("failed to copy custom CSS '%s' to '%s'\n", customCss, cssOutputFileName);
+            return;
+        }
+    }
+
+    private String asPath(final String name) {
+        return name.replace('.', File.separatorChar);
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // Hooks
+    // ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * The directory to which the processed HTML should be copied.
+     * 
+     * <p>
+     * Defaults to the value of the {@value #DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY} system property, or
+     * {@value #DEFAULT_OUTPUT_DIR} if that property is not specified.
+     * 
+     * <p>
+     * Can either be overridden if wish to specify some other mechanism for determining where the output is generated.
+     */
+    protected String outputDir() {
+        final String concordionOutputDir = System.getProperty(DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY);
+        return StringUtils.isNullOrEmpty(concordionOutputDir) ? DEFAULT_OUTPUT_DIR : concordionOutputDir;
+    }
+
+    /**
+     * 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 Concordion createConcordion() {
+        final String targetDir = outputDir();
+        if (targetDir == null) {
+            throw new IllegalStateException("targetDir() cannot be null");
+        }
+        final ConcordionBuilder builder =
+            new ConcordionBuilder() {
+            }.withTarget(new FileTarget(new File(targetDir))).withCommand(NS_URI, CMD_EXECUTE,
+                new IsisExecuteCommandWithHeader());
+        return builder.build();
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // bootstrapIsis / shutdownIsis
+    // ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * For calling within a <tt>#setUp()</tt> method.
+     * 
+     * @see {@link #bootstrapIsis(String, String)}
+     */
+    public void bootstrapIsis(final String configDirectory, final DeploymentType deploymentType) {
+        getScenario().bootstrapIsis(StringUtils.normalized(configDirectory), deploymentType);
+    }
+
+    /**
+     * For calling from XHTML script.
+     * 
+     * @see #bootstrapIsis(String, DeploymentType)
+     * @return <tt>boolean</tt> so that XHTML can assert on it.
+     */
+    public boolean bootstrapIsis(final String configDirectory, final String deploymentTypeStr) {
+        bootstrapIsis(configDirectory, DeploymentType.lookup(StringUtils.normalized(deploymentTypeStr)));
+        return true; // any runtime exception will propagate
+    }
+
+    public void shutdownIsis() {
+        getScenario().shutdownIsis();
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // logon as / switch user
+    // ////////////////////////////////////////////////////////////////////////
+
+    public boolean logonAs(final String userName) {
+        getScenario().logonAsOrSwitchUserTo(StringUtils.normalized(userName));
+        return true;
+    }
+
+    public boolean logonAsWithRoles(final String userName, final String roleListStr) {
+        final List<String> roleList = StringUtils.splitOnCommas(StringUtils.normalized(roleListStr));
+        getScenario().logonAsOrSwitchUserTo(userName, roleList);
+        return true;
+    }
+
+    public void switchUser(final String userName) {
+        logonAs(userName);
+    }
+
+    public void switchUserWithRoles(final String userName, final String roleListStr) {
+        logonAsWithRoles(userName, roleListStr);
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // date is / time is
+    // ////////////////////////////////////////////////////////////////////////
+
+    public boolean usingDateFormat(final String dateFormatStr) {
+        getScenario().usingDateFormat(dateFormatStr);
+        return true;
+    }
+
+    public boolean usingTimeFormat(final String timeFormatStr) {
+        getScenario().usingTimeFormat(timeFormatStr);
+        return true;
+    }
+
+    public boolean dateIs(final String dateAndTimeStr) throws ScenarioValueException {
+        return dateAndTimeIs(dateAndTimeStr);
+    }
+
+    public boolean timeIs(final String dateAndTimeStr) throws ScenarioValueException {
+        return dateAndTimeIs(dateAndTimeStr);
+    }
+
+    private boolean dateAndTimeIs(final String dateAndTimeStr) throws ScenarioValueException {
+        return getScenario().dateAndTimeIs(dateAndTimeStr);
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // alias service
+    // ////////////////////////////////////////////////////////////////////////
+
+    public boolean aliasService(final String aliasAs, final String className) {
+        try {
+            getScenario().getAliasRegistry().aliasService(StringUtils.normalized(aliasAs),
+                StringUtils.normalized(className));
+            return true;
+        } catch (final ScenarioValueException e) {
+            return false;
+        }
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // setup object
+    // ////////////////////////////////////////////////////////////////////////
+
+    public String setUpObject(final String className, final String alias, final String arg0) {
+        return setUpObjectsVarargs(className, alias, arg0);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4, final String arg5) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4, final String arg5, final String arg6) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4, final String arg5, final String arg6, final String arg7) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4, final String arg5, final String arg6,
+        final String arg7, final String arg8) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+    }
+
+    public String setUpObject(final String className, final String alias, final String arg0, final String arg1,
+        final String arg2, final String arg3, final String arg4, final String arg5, final String arg6,
+        final String arg7, final String arg8, final String arg9) {
+        return setUpObjectsVarargs(className, alias, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+    }
+
+    private SetUpObjectsForConcordion setUpObjects;
+
+    /**
+     * Workaround for OGNL defect.
+     */
+    protected String setUpObjectsVarargs(final String className, final String alias, final String... propertyValues) {
+        return setUpObjectsVarargsNormalized(StringUtils.normalized(className), StringUtils.normalized(alias),
+            StringUtils.normalized(propertyValues));
+    }
+
+    private String setUpObjectsVarargsNormalized(final String className, final String alias,
+        final String... propertyValues) {
+        if (executingInline()) {
+            setUpObjects = new SetUpObjectsForConcordion(getScenario().getAliasRegistry(), className, Mode.PERSIST);
+            setUpObjects.executeHeader(alias, propertyValues);
+            return setUpObjects.executeRow(alias, propertyValues);
+        } else {
+            if (executingTableHeader()) {
+                setUpObjects = new SetUpObjectsForConcordion(getScenario().getAliasRegistry(), className, Mode.PERSIST);
+                return setUpObjects.executeHeader(alias, propertyValues);
+            } else {
+                return setUpObjects.executeRow(alias, propertyValues);
+            }
+        }
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // using isis viewer
+    // ////////////////////////////////////////////////////////////////////////
+
+    private UsingIsisViewerForConcordion usingIsisViewer;
+
+    public String usingIsisViewer(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, null, null, null);
+    }
+
+    public String usingIsisViewerThat(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, null, null, null);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0, final String arg1) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0, arg1);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0, final String arg1, final String arg2) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0, arg1, arg2);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0, final String arg1, final String arg2, final String arg3) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0, arg1, arg2,
+            arg3);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0, final String arg1, final String arg2, final String arg3,
+        final String arg4) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0, arg1, arg2,
+            arg3, arg4);
+    }
+
+    public String usingIsisViewerArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String arg0, final String arg1, final String arg2, final String arg3,
+        final String arg4, final String arg5) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, null, arg0, arg1, arg2,
+            arg3, arg4, arg5);
+    }
+
+    public String usingIsisViewerThatArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt, final String arg0) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, arg0);
+    }
+
+    public String usingIsisViewerThatArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt, final String arg0, final String arg1) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, arg0, arg1);
+    }
+
+    public String usingIsisViewerThatArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt, final String arg0, final String arg1, final String arg2) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, arg0, arg1, arg2);
+    }
+
+    public String usingIsisViewerThatArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt, final String arg0, final String arg1, final String arg2,
+        final String arg3) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, arg0, arg1, arg2,
+            arg3);
+    }
+
+    public String usingIsisViewerThatArgs(final String onObject, final String aliasResultAs, final String perform,
+        final String usingMember, final String thatIt, final String arg0, final String arg1, final String arg2,
+        final String arg3, final String arg4) {
+        return usingIsisViewerThatArgsVarargs(onObject, aliasResultAs, perform, usingMember, thatIt, arg0, arg1, arg2,
+            arg3, arg4);
+    }
+
+    /**
+     * With <tt>protected</tt> visibility so that it can be called by custom methods if required.
+     */
+    protected String usingIsisViewerThatArgsVarargs(final String onObject, final String aliasResultAs,
+        final String perform, final String usingMember, final String thatIt, final String arg0,
+        final String... remainingArgs) {
+        return usingIsisViewerThatArgsVarargsNormalized(StringUtils.normalized(onObject),
+            StringUtils.normalized(aliasResultAs), StringUtils.normalized(perform),
+            StringUtils.normalized(usingMember), StringUtils.normalized(thatIt), StringUtils.normalized(arg0),
+            StringUtils.normalized(remainingArgs));
+    }
+
+    private String usingIsisViewerThatArgsVarargsNormalized(final String onObject, final String aliasResultAs,
+        final String perform, final String usingMember, final String thatIt, final String arg0,
+        final String... remainingArgs) {
+        if (executingInline()) {
+            usingIsisViewer =
+                new UsingIsisViewerForConcordion(getScenario().getAliasRegistry(), getScenario().getDeploymentType(),
+                    getScenario().getDateParser(), 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(getScenario().getAliasRegistry(), getScenario()
+                        .getDeploymentType(), getScenario().getDateParser(), Perform.Mode.TEST);
+                return usingIsisViewer.executeHeader(onObject, aliasResultAs, perform, usingMember, thatIt, arg0,
+                    remainingArgs);
+            } else {
+                return usingIsisViewer.executeRow(onObject, aliasResultAs, perform, usingMember, thatIt, arg0,
+                    remainingArgs);
+            }
+        }
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // check collection
+    // ////////////////////////////////////////////////////////////////////////
+
+    public String checkCollectionIsEmpty(final String listAlias) {
+        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(),
+            StringUtils.normalized(listAlias)).isEmpty();
+    }
+
+    public String checkCollectionIsNotEmpty(final String listAlias) {
+        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(),
+            StringUtils.normalized(listAlias)).isNotEmpty();
+    }
+
+    public String checkCollectionContains(final String listAlias, final String alias) {
+        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(),
+            StringUtils.normalized(listAlias)).contains(StringUtils.normalized(alias));
+    }
+
+    public String checkCollectionDoesNotContain(final String listAlias, final String alias) {
+        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(),
+            StringUtils.normalized(listAlias)).doesNotContain(StringUtils.normalized(alias));
+    }
+
+    public String checkCollectionSize(final String listAlias, final int size) {
+        return new CheckCollectionContentsForConcordion(getScenario().getAliasRegistry(),
+            StringUtils.normalized(listAlias)).assertSize(size);
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // check list
+    // ////////////////////////////////////////////////////////////////////////
+
+    private CheckListForConcordion checkList;
+
+    public String checkList(final String listAlias, final String title) {
+        if (executingTable()) {
+            if (executingTableHeader()) {
+                checkList = new CheckListForConcordion(getScenario().getAliasRegistry(), listAlias);
+                return checkList.executeHeader(title);
+            } else {
+                return checkList.executeRow(title);
+            }
+        } else {
+            checkList = new CheckListForConcordion(getScenario().getAliasRegistry(), listAlias);
+            checkList.executeHeader(title);
+            return checkList.executeRow(title);
+        }
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // getListContents() (for verifyRow)
+    // ////////////////////////////////////////////////////////////////////////
+
+    public Iterable<Object> getListContents(final String listAlias) {
+        final ObjectAdapter listAdapter =
+            getScenario().getAliasRegistry().getAliased(StringUtils.normalized(listAlias));
+        if (listAdapter == null) {
+            return Collections.emptyList();
+        }
+        final CollectionFacet facet = listAdapter.getSpecification().getFacet(CollectionFacet.class);
+        if (facet == null) {
+            return Collections.emptyList();
+        }
+        final Iterable<ObjectAdapter> objectAdapters = facet.iterable(listAdapter);
+        return Iterables.transform(objectAdapters, new Function<ObjectAdapter, Object>() {
+
+            @Override
+            public Object apply(final ObjectAdapter from) {
+                return from.getObject();
+            }
+        });
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // alias items in list
+    // ////////////////////////////////////////////////////////////////////////
+
+    private AliasItemsInListForConcordion aliasItemsInList;
+
+    public String aliasItemsInList(final String listAlias, final String title, final String aliasAs) {
+        return aliasItemsInList(listAlias, title, null, aliasAs);
+    }
+
+    public String aliasItemsInList(final String listAlias, final String title, final String type, final String aliasAs) {
+        aliasItemsInList =
+            new AliasItemsInListForConcordion(getScenario().getAliasRegistry(), StringUtils.normalized(listAlias));
+        return aliasItemsInList.execute(StringUtils.normalized(aliasAs), StringUtils.normalized(title),
+            StringUtils.normalized(type));
+    }
+
+    private boolean executingTableHeader() {
+        return executingTable()
+            && IsisExecuteCommandWithHeader.tableRow.get() == IsisExecuteCommandWithHeader.TableRow.HEADER;
+    }
+
+    private boolean executingTable() {
+        final IsisExecuteCommandWithHeader.Context context = IsisExecuteCommandWithHeader.context.get();
+        return context == IsisExecuteCommandWithHeader.Context.TABLE;
+    }
+
+    private boolean executingInline() {
+        return !executingTable();
+    }
+
+    // ////////////////////////////////////////////////////////////////////////
+    // run viewer
+    // ////////////////////////////////////////////////////////////////////////
+
+    public void runViewer() {
+        getScenario().runViewer();
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/concordion/IsisExecuteCommandWithHeader.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/concordion/IsisExecuteCommandWithHeader.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/concordion/IsisExecuteCommandWithHeader.java (original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/concordion/IsisExecuteCommandWithHeader.java Tue May  3 07:18:19 2011
@@ -29,95 +29,92 @@ import org.concordion.internal.command.E
  * Handles tables slightly differently from Concordion's usual strategy.
  * 
  * <p>
- * Specifically, it will call execute for the header row as well as for the
- * body rows.  This is required in order to set up the bindings of the
- * column names to the positions.
+ * Specifically, it will call execute for the header row as well as for the body rows. This is required in order to set
+ * up the bindings of the column names to the positions.
  */
 public class IsisExecuteCommandWithHeader extends ExecuteCommand {
 
-	public static enum Context {
-		TABLE, INLINE
-	}
-
-	public static enum TableRow {
-		HEADER, BODY
-	}
-
-	/**
-	 * Provides a mechanism for the fixture to determine whether the command is
-	 * being executed in the context of a table or inline.
-	 */
-	public static ThreadLocal<Context> context = new ThreadLocal<Context>() {
-		@Override
-		protected Context initialValue() {
-			return null;
-		}
-	};
-
-	/**
-	 * When executing in a {@link Context#TABLE table context}, provides a
-	 * mechanism for the fixture to determine whether the header of a table or
-	 * the body is being processed.
-	 */
-	public static ThreadLocal<TableRow> tableRow = new ThreadLocal<TableRow>() {
-		@Override
-		protected TableRow initialValue() {
-			return TableRow.BODY;
-		}
-	};
-
-	
-	@Override
-	public void execute(org.concordion.api.CommandCall commandCall, Evaluator evaluator,
-			ResultRecorder resultRecorder) {
-		if (commandCall.getElement().isNamed("table")) {
-		    // special handling for tables
-			Context contextIfAny = context.get();
-			boolean setContext = contextIfAny == null; 
-			if (setContext) {
-				context.set(Context.TABLE);
-			}
-			executeTable(commandCall, evaluator, resultRecorder);
-			if (setContext) {
-				context.set(null);
-			}
-		} else {
-		    // basically the same as Concordion's original ExecuteCommand 
-			Context contextIfAny = context.get();
-			boolean setContext = contextIfAny == null;
-			if (setContext) {
-				context.set(Context.INLINE);
-			}
-			super.execute(commandCall, evaluator, resultRecorder);
-			if (setContext) {
-				context.set(null);
-			}
-		}
-	}
-
-	private void executeTable(CommandCall commandCall, Evaluator evaluator,
-			ResultRecorder resultRecorder) {
-		TableSupport tableSupport = new TableSupport(commandCall);
-
-		// this is the bit that's different: also execute on the header
-		tableRow.set(TableRow.HEADER);
-		Row headerRow = tableSupport.getLastHeaderRow();
-		commandCall.setElement(headerRow.getElement());
-		commandCall.execute(evaluator, resultRecorder);
-
-		// the rest is copied from Concordion's original implementation
-		tableRow.set(TableRow.BODY);
-		Row[] detailRows = tableSupport.getDetailRows();
-		for (Row detailRow : detailRows) {
-			if (detailRow.getCells().length != tableSupport.getColumnCount()) {
-				throw new RuntimeException(
-						"The <table> 'execute' command only supports rows with an equal number of columns.");
-			}
-			commandCall.setElement(detailRow.getElement());
-			tableSupport.copyCommandCallsTo(detailRow);
-			commandCall.execute(evaluator, resultRecorder);
-		}
-		tableRow.set(null);
-	}
+    public static enum Context {
+        TABLE, INLINE
+    }
+
+    public static enum TableRow {
+        HEADER, BODY
+    }
+
+    /**
+     * Provides a mechanism for the fixture to determine whether the command is being executed in the context of a table
+     * or inline.
+     */
+    public static ThreadLocal<Context> context = new ThreadLocal<Context>() {
+        @Override
+        protected Context initialValue() {
+            return null;
+        }
+    };
+
+    /**
+     * When executing in a {@link Context#TABLE table context}, provides a mechanism for the fixture to determine
+     * whether the header of a table or the body is being processed.
+     */
+    public static ThreadLocal<TableRow> tableRow = new ThreadLocal<TableRow>() {
+        @Override
+        protected TableRow initialValue() {
+            return TableRow.BODY;
+        }
+    };
+
+    @Override
+    public void execute(final org.concordion.api.CommandCall commandCall, final Evaluator evaluator,
+        final ResultRecorder resultRecorder) {
+        if (commandCall.getElement().isNamed("table")) {
+            // special handling for tables
+            final Context contextIfAny = context.get();
+            final boolean setContext = contextIfAny == null;
+            if (setContext) {
+                context.set(Context.TABLE);
+            }
+            executeTable(commandCall, evaluator, resultRecorder);
+            if (setContext) {
+                context.set(null);
+            }
+        } else {
+            // basically the same as Concordion's original ExecuteCommand
+            final Context contextIfAny = context.get();
+            final boolean setContext = contextIfAny == null;
+            if (setContext) {
+                context.set(Context.INLINE);
+            }
+            super.execute(commandCall, evaluator, resultRecorder);
+            if (setContext) {
+                context.set(null);
+            }
+        }
+    }
+
+    private void executeTable(final CommandCall commandCall, final Evaluator evaluator,
+        final ResultRecorder resultRecorder) {
+        final TableSupport tableSupport = new TableSupport(commandCall);
+
+        // this is the bit that's different: also execute on the header
+        tableRow.set(TableRow.HEADER);
+        final Row headerRow = tableSupport.getLastHeaderRow();
+        commandCall.setElement(headerRow.getElement());
+        commandCall.execute(evaluator, resultRecorder);
+
+        // the rest is copied from Concordion's original implementation
+        tableRow.set(TableRow.BODY);
+        final Row[] detailRows = tableSupport.getDetailRows();
+        for (final Row detailRow : detailRows) {
+            if (detailRow.getCells().length != tableSupport.getColumnCount()) {
+                throw new RuntimeException(
+                    "The <table> 'execute' command only supports rows with an equal number of columns.");
+            }
+            commandCall.setElement(detailRow.getElement());
+            tableSupport.copyCommandCallsTo(detailRow);
+            commandCall.execute(evaluator, resultRecorder);
+        }
+        tableRow.set(null);
+    }
 
 }

Modified: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AbstractFixture.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AbstractFixture.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AbstractFixture.java (original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AbstractFixture.java Tue May  3 07:18:19 2011
@@ -16,18 +16,18 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.concordion.internal.fixtures;
-
-public abstract class AbstractFixture<T>  {
-
-	private final T peer;
-
-    protected AbstractFixture(final T fixturePeer) {
-    	this.peer = fixturePeer;
-    }
-    
-    public T getPeer() {
-		return peer;
-	}
-    
-}
+package org.apache.isis.viewer.bdd.concordion.internal.fixtures;
+
+public abstract class AbstractFixture<T> {
+
+    private final T peer;
+
+    protected AbstractFixture(final T fixturePeer) {
+        this.peer = fixturePeer;
+    }
+
+    public T getPeer() {
+        return peer;
+    }
+
+}

Modified: incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AliasItemsInListForConcordion.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AliasItemsInListForConcordion.java?rev=1098945&r1=1098944&r2=1098945&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AliasItemsInListForConcordion.java (original)
+++ incubator/isis/trunk/viewer/bdd/concordion/src/main/java/org/apache/isis/viewer/bdd/concordion/internal/fixtures/AliasItemsInListForConcordion.java Tue May  3 07:18:19 2011
@@ -16,88 +16,87 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.apache.isis.viewer.bdd.concordion.internal.fixtures;
-
-import org.apache.isis.viewer.bdd.common.AliasRegistry;
-import org.apache.isis.viewer.bdd.common.CellBinding;
-import org.apache.isis.viewer.bdd.common.CellBindingDefault;
-import org.apache.isis.viewer.bdd.common.IsisViewerConstants;
-import org.apache.isis.viewer.bdd.common.ScenarioBoundValueException;
-import org.apache.isis.viewer.bdd.common.ScenarioCellDefault;
-import org.apache.isis.viewer.bdd.common.ScenarioValueException;
-import org.apache.isis.viewer.bdd.common.fixtures.AliasItemsInListPeer;
-
-public class AliasItemsInListForConcordion extends AbstractFixture<AliasItemsInListPeer> {
-
-    public AliasItemsInListForConcordion(final AliasRegistry aliasRegistry, final String listAlias) {
-        this(aliasRegistry, listAlias, 
-            CellBindingDefault.builder(IsisViewerConstants.TITLE_NAME,
-            IsisViewerConstants.TITLE_HEAD).build(), CellBindingDefault
-            .builder(IsisViewerConstants.TYPE_NAME, IsisViewerConstants.TYPE_HEAD).optional().build(),
-            CellBindingDefault
-                .builder(IsisViewerConstants.ALIAS_RESULT_NAME, IsisViewerConstants.ALIAS_RESULT_HEAD_SET).autoCreate()
-                .build());
-    }
-
-    private AliasItemsInListForConcordion(final AliasRegistry aliasRegistry, final String listAlias,
-        final CellBinding titleBinding, final CellBinding typeBinding, final CellBinding aliasBinding) {
-        super(new AliasItemsInListPeer(aliasRegistry, listAlias, titleBinding, typeBinding, aliasBinding));
-    }
-
-    public String execute(String aliasAs, String title, String type) {
-        String header = executeHeader(aliasAs, title, type);
-        if (header != null) {
-            return header;
-        }
-
-        String row = executeRow(aliasAs, title, type);
-        if (row != null) {
-            return row;
-        }
-
-        return "ok"; // ok
-    }
-
-    private String executeHeader(String alias, String title, String type) {
-        try {
-            getPeer().assertIsList();
-        } catch (ScenarioValueException e) {
-            return e.getMessage();
-        }
-
-        // create bindings
-        getPeer().getTitleBinding().setHeadColumn(0);
-        getPeer().getAliasBinding().setHeadColumn(1);
-
-        if (type != null) {
-            getPeer().getTypeBinding().setHeadColumn(2, new ScenarioCellDefault(type));
-        }
-
-        return null;
-    }
-
-    private String executeRow(String aliasAs, String title, String type) {
-        if (!getPeer().isList()) {
-            return null; // skip
-        }
-
-        captureCurrent(aliasAs, title, type);
-
-        try {
-            getPeer().findAndAlias();
-        } catch (ScenarioBoundValueException e) {
-            return e.getMessage();
-        }
-
-        return null;
-    }
-
-    private void captureCurrent(String aliasAs, String title, String type) {
-        getPeer().getAliasBinding().captureCurrent(new ScenarioCellDefault(aliasAs));
-        getPeer().getTitleBinding().captureCurrent(new ScenarioCellDefault(title));
-        if (type != null) {
-            getPeer().getTitleBinding().captureCurrent(new ScenarioCellDefault(type));
-        }
-    }
-
-}
+package org.apache.isis.viewer.bdd.concordion.internal.fixtures;
+
+import org.apache.isis.viewer.bdd.common.AliasRegistry;
+import org.apache.isis.viewer.bdd.common.CellBinding;
+import org.apache.isis.viewer.bdd.common.CellBindingDefault;
+import org.apache.isis.viewer.bdd.common.IsisViewerConstants;
+import org.apache.isis.viewer.bdd.common.ScenarioBoundValueException;
+import org.apache.isis.viewer.bdd.common.ScenarioCellDefault;
+import org.apache.isis.viewer.bdd.common.ScenarioValueException;
+import org.apache.isis.viewer.bdd.common.fixtures.AliasItemsInListPeer;
+
+public class AliasItemsInListForConcordion extends AbstractFixture<AliasItemsInListPeer> {
+
+    public AliasItemsInListForConcordion(final AliasRegistry aliasRegistry, final String listAlias) {
+        this(aliasRegistry, listAlias, CellBindingDefault.builder(IsisViewerConstants.TITLE_NAME,
+            IsisViewerConstants.TITLE_HEAD).build(), CellBindingDefault
+            .builder(IsisViewerConstants.TYPE_NAME, IsisViewerConstants.TYPE_HEAD).optional().build(),
+            CellBindingDefault
+                .builder(IsisViewerConstants.ALIAS_RESULT_NAME, IsisViewerConstants.ALIAS_RESULT_HEAD_SET).autoCreate()
+                .build());
+    }
+
+    private AliasItemsInListForConcordion(final AliasRegistry aliasRegistry, final String listAlias,
+        final CellBinding titleBinding, final CellBinding typeBinding, final CellBinding aliasBinding) {
+        super(new AliasItemsInListPeer(aliasRegistry, listAlias, titleBinding, typeBinding, aliasBinding));
+    }
+
+    public String execute(final String aliasAs, final String title, final String type) {
+        final String header = executeHeader(aliasAs, title, type);
+        if (header != null) {
+            return header;
+        }
+
+        final String row = executeRow(aliasAs, title, type);
+        if (row != null) {
+            return row;
+        }
+
+        return "ok"; // ok
+    }
+
+    private String executeHeader(final String alias, final String title, final String type) {
+        try {
+            getPeer().assertIsList();
+        } catch (final ScenarioValueException e) {
+            return e.getMessage();
+        }
+
+        // create bindings
+        getPeer().getTitleBinding().setHeadColumn(0);
+        getPeer().getAliasBinding().setHeadColumn(1);
+
+        if (type != null) {
+            getPeer().getTypeBinding().setHeadColumn(2, new ScenarioCellDefault(type));
+        }
+
+        return null;
+    }
+
+    private String executeRow(final String aliasAs, final String title, final String type) {
+        if (!getPeer().isList()) {
+            return null; // skip
+        }
+
+        captureCurrent(aliasAs, title, type);
+
+        try {
+            getPeer().findAndAlias();
+        } catch (final ScenarioBoundValueException e) {
+            return e.getMessage();
+        }
+
+        return null;
+    }
+
+    private void captureCurrent(final String aliasAs, final String title, final String type) {
+        getPeer().getAliasBinding().captureCurrent(new ScenarioCellDefault(aliasAs));
+        getPeer().getTitleBinding().captureCurrent(new ScenarioCellDefault(title));
+        if (type != null) {
+            getPeer().getTitleBinding().captureCurrent(new ScenarioCellDefault(type));
+        }
+    }
+
+}



Mime
View raw message