You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/07/01 00:20:09 UTC
svn commit: r418394 - in
/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry: ./
components/ engine/ enhance/ form/ form/translator/ junit/parse/ listener/
record/ resolver/ valid/
Author: jkuhnert
Date: Fri Jun 30 15:20:07 2006
New Revision: 418394
URL: http://svn.apache.org/viewvc?rev=418394&view=rev
Log:
Fixed more unit tests.
Modified:
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/BaseComponentTestCase.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/TapestryUtilsTest.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/components/TestRenderBlock.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/ServiceTestCase.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/BaseEnhancementTestCase.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectEventInvokerWorker.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectScriptWorker.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/TestTextField.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/translator/TestStringTranslator.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/listener/TestListenerMapSource.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java
tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/valid/TestValidField.java
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/BaseComponentTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/BaseComponentTestCase.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/BaseComponentTestCase.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/BaseComponentTestCase.java Fri Jun 30 15:20:07 2006
@@ -226,7 +226,8 @@
protected IBinding newBinding(Location location)
{
IBinding binding = newBinding();
-
+ checkOrder(binding, false);
+
trainGetLocation(binding, location);
return binding;
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/TapestryUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/TapestryUtilsTest.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/TapestryUtilsTest.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/TapestryUtilsTest.java Fri Jun 30 15:20:07 2006
@@ -142,15 +142,17 @@
public void testGetPageRenderSupportFailure()
{
- Location l = newLocation();
IComponent component = newMock(IComponent.class);
-
+
+ IRequestCycle cycle = newCycle(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE, null);
+
expect(component.getExtendedId()).andReturn("Foo/bar").anyTimes();
+ Location l = newLocation();
expect(component.getLocation()).andReturn(l);
-
- IRequestCycle cycle = newCycle(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE, null);
-
+
+ expect(component.getExtendedId()).andReturn("Foo/bar").anyTimes();
+
replay();
try
@@ -171,13 +173,15 @@
{
Location l = newLocation();
IComponent component = newMock(IComponent.class);
-
+
+ IRequestCycle cycle = newCycle(TapestryUtils.FORM_ATTRIBUTE, null);
+
expect(component.getExtendedId()).andReturn("Foo/bar").anyTimes();
expect(component.getLocation()).andReturn(l);
- IRequestCycle cycle = newCycle(TapestryUtils.FORM_ATTRIBUTE, null);
-
+ expect(component.getExtendedId()).andReturn("Foo/bar").anyTimes();
+
replay();
try
@@ -196,37 +200,37 @@
public void testSplitBlank()
{
- assertEquals(new String[0], TapestryUtils.split(null));
- assertEquals(new String[0], TapestryUtils.split(""));
+ assertListEquals(new String[0], TapestryUtils.split(null));
+ assertListEquals(new String[0], TapestryUtils.split(""));
}
public void testSplitWithDelimiter()
{
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "fred", "barney" }, TapestryUtils.split("fred|barney", '|'));
}
public void testSplitNormal()
{
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "fred", "barney" }, TapestryUtils.split("fred,barney"));
}
public void testSplitNoDelimiter()
{
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "no-delimiter" }, TapestryUtils.split("no-delimiter"));
}
public void testTrailingDelimiter()
{
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "fred", "barney", "" }, TapestryUtils.split("fred,barney,"));
}
public void testEveryDelimiterCounts()
{
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "", "fred", "", "barney", "", "" }, TapestryUtils.split(",fred,,barney,,"));
}
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/components/TestRenderBlock.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/components/TestRenderBlock.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/components/TestRenderBlock.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/components/TestRenderBlock.java Fri Jun 30 15:20:07 2006
@@ -44,7 +44,7 @@
public void testNonNullBlock()
{
- Block b = newMock(Block.class);
+ Block b = (Block)newInstance(Block.class);
RenderBlock rb = newInstance(RenderBlock.class, new Object[]
{ "block", b });
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java Fri Jun 30 15:20:07 2006
@@ -14,6 +14,7 @@
package org.apache.tapestry.engine;
+import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.testng.AssertJUnit.assertEquals;
@@ -46,7 +47,7 @@
@Test
public class DirectEventServiceTest extends ServiceTestCase
{
- protected IDirectEvent newDirect()
+ private IDirectEvent newDirect()
{
return newMock(IDirectEvent.class);
}
@@ -228,7 +229,7 @@
cycle.setListenerParameters(isA(Object[].class));
- d.triggerEvent(cycle, isA(BrowserEvent.class));
+ d.triggerEvent(eq(cycle), isA(BrowserEvent.class));
rr.renderResponse(cycle);
@@ -276,7 +277,7 @@
cycle.setListenerParameters(isA(Object[].class));
- d.triggerEvent(cycle, isA(BrowserEvent.class));
+ d.triggerEvent(eq(cycle), isA(BrowserEvent.class));
rr.renderResponse(cycle);
@@ -338,16 +339,15 @@
IRequestCycle cycle = newCycle();
IPage page = newPage();
IDirectEvent d = newDirect();
- WebSession session = newWebSession(false);
- WebRequest request = newWebRequest(session);
+
LinkFactory lf = newLinkFactory();
ResponseRenderer rr = newResponseRenderer();
-
+
trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
trainGetParameter(cycle, ServiceConstants.SESSION, "T");
-
+
trainGetPage(cycle, "ActivePage", page);
cycle.activate(page);
@@ -355,13 +355,16 @@
trainIsStateful(d, true);
+ WebSession session = newWebSession(false);
+ WebRequest request = newWebRequest(session);
+
trainExtractListenerParameters(lf, cycle, parameters);
trainExtractBrowserEvent(cycle);
cycle.setListenerParameters(isA(Object[].class));
- d.triggerEvent(cycle, isA(BrowserEvent.class));
+ d.triggerEvent(eq(cycle), isA(BrowserEvent.class));
rr.renderResponse(cycle);
@@ -382,7 +385,7 @@
IRequestCycle cycle = newCycle();
IPage page = newPage();
IDirectEvent d = newDirect();
- WebRequest request = newWebRequest(null);
+
Location l = newLocation();
trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
@@ -397,6 +400,8 @@
trainIsStateful(d, true);
+ WebRequest request = newWebRequest(null);
+
trainGetExtendedId(d, "ActivePage/fred.barney");
trainGetLocation(page, l);
trainGetPageName(page, "ActivePage");
@@ -464,7 +469,7 @@
verify();
}
- protected void trainIsStateful(IDirectEvent direct, boolean isStateful)
+ private void trainIsStateful(IDirectEvent direct, boolean isStateful)
{
expect(direct.isStateful()).andReturn(isStateful);
}
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/EngineServiceLinkTest.java Fri Jun 30 15:20:07 2006
@@ -69,7 +69,7 @@
verify();
- assertEquals(new String[]
+ assertListEquals(new String[]
{ ServiceConstants.SERVICE, ServiceConstants.PARAMETER }, l.getParameterNames());
}
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/ServiceTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/ServiceTestCase.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/ServiceTestCase.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/engine/ServiceTestCase.java Fri Jun 30 15:20:07 2006
@@ -14,7 +14,8 @@
package org.apache.tapestry.engine;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.expect;
import java.util.Map;
@@ -30,7 +31,6 @@
import org.apache.tapestry.services.ResponseRenderer;
import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebSession;
-import org.testng.annotations.Test;
/**
* Common utilities for building tests for {@link org.apache.tapestry.engine.IEngineService}s.
@@ -38,7 +38,6 @@
* @author Howard M. Lewis Ship
* @since 4.0
*/
-@Test
public abstract class ServiceTestCase extends BaseComponentTestCase
{
@@ -99,7 +98,8 @@
protected WebSession newWebSession(boolean isNew)
{
WebSession session = newWebSession();
-
+ checkOrder(session, false);
+
expect(session.isNew()).andReturn(isNew);
return session;
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/BaseEnhancementTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/BaseEnhancementTestCase.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/BaseEnhancementTestCase.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/BaseEnhancementTestCase.java Fri Jun 30 15:20:07 2006
@@ -14,6 +14,7 @@
package org.apache.tapestry.enhance;
+import static org.easymock.EasyMock.checkOrder;
import static org.easymock.EasyMock.expect;
import org.apache.hivemind.Location;
@@ -32,7 +33,8 @@
public IComponentSpecification newSpec(Location location)
{
IComponentSpecification spec = newSpec();
-
+ checkOrder(spec, false);
+
expect(spec.getLocation()).andReturn(location);
return spec;
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectEventInvokerWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectEventInvokerWorker.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectEventInvokerWorker.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectEventInvokerWorker.java Fri Jun 30 15:20:07 2006
@@ -39,11 +39,10 @@
public void testSuccess() throws Exception
{
- Location l = newLocation();
-
EnhancementOperation op = newOp();
ComponentEventInvoker invoker = new ComponentEventInvoker();
+ Location l = newLocation();
IComponentSpecification spec = newSpec(l);
op.claimReadonlyProperty("eventInvoker");
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectScriptWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectScriptWorker.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectScriptWorker.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectScriptWorker.java Fri Jun 30 15:20:07 2006
@@ -14,6 +14,8 @@
package org.apache.tapestry.enhance;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import java.lang.reflect.Modifier;
@@ -40,39 +42,26 @@
{
EnhancementOperation op = newMock(EnhancementOperation.class);
- Location componentSpecLocation = newLocation();
- final Resource scriptResource = componentSpecLocation.getResource().getRelativeResource(
- "bar.script");
-
final Location injectSpecLocation = newLocation();
final IScriptSource source = newMock(IScriptSource.class);
+
+ // Location componentSpecLocation = newLocation();
+ Resource scriptResource = newResource();
op.claimReadonlyProperty("foo");
expect(op.getPropertyType("foo")).andReturn(IScript.class);
expect(op.getAccessorMethodName("foo")).andReturn("getFoo");
-
- expect(op.addInjectedField("_$script", DeferredScript.class, new DeferredScriptImpl(scriptResource,
- source, injectSpecLocation)))
- .andReturn("_script");
- /* opc.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
- { null, null, new ArgumentMatcher()
- {
-
- public boolean compareArguments(Object expected, Object actual)
- {
- DeferredScriptImpl ds = (DeferredScriptImpl) actual;
-
- return ds._location == injectSpecLocation && ds._scriptSource == source
- && ds._scriptResource.equals(scriptResource);
- }
-
- }
-
- }));*/
-
+
+ expect(injectSpecLocation.getResource()).andReturn(scriptResource);
+
+ expect(scriptResource.getRelativeResource("bar.script")).andReturn(scriptResource);
+
+ expect(op.addInjectedField(eq("_$script"), eq(DeferredScript.class), anyObject()))
+ .andReturn("_script");
+
MethodSignature sig = new MethodSignature(IScript.class, "getFoo", null, null);
op.addMethod(Modifier.PUBLIC, sig, "return _script.getScript();", injectSpecLocation);
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java Fri Jun 30 15:20:07 2006
@@ -96,19 +96,19 @@
trainStoreForm(cycle, form);
- trainIsRewinding(support, true);
-
trainGetNextActionId(cycle, "7");
-
+
+ trainIsRewinding(support, true);
+
expect(support.rewind()).andReturn(FormConstants.SUBMIT_NORMAL);
expect(delegate.getHasErrors()).andReturn(false);
invoker.invokeListener(listener, form, cycle);
-
- delegate.setFormComponent(null);
-
+
TapestryUtils.removeForm(cycle);
+
+ delegate.setFormComponent(null);
replay();
@@ -147,14 +147,14 @@
trainStoreForm(cycle, form);
- trainIsRewinding(support, false);
-
trainGetNextActionId(cycle, "7");
-
+
+ trainIsRewinding(support, false);
+
trainGetUniqueId(cycle, "myform", "myform_1");
trainGetNamespace(response, "$ns");
-
+
trainGetLinkCheckIgnoreParameter(
direct,
cycle,
@@ -164,10 +164,10 @@
trainRender(support, link, render, null, null);
- delegate.setFormComponent(null);
-
TapestryUtils.removeForm(cycle);
+ delegate.setFormComponent(null);
+
replay();
form.render(writer, cycle);
@@ -182,23 +182,24 @@
FormSupport support = newFormSupport();
WebResponse response = newResponse();
IEngineService direct = newEngineService();
+
ILink link = newLink();
IRender render = newRender();
IValidationDelegate delegate = newDelegate();
-
+
Form form = newInstance(FormFixture.class, new Object[]
{ "id", "myform", "direct", true, "expectedWriter", writer, "expectedRequestCycle", cycle,
"formSupport", support, "response", response, "directService", direct, "method",
"post", "delegate", delegate, "scheme", "https", "port", new Integer(443) });
-
+
trainStoreForm(cycle, form);
-
- trainIsRewinding(support, false);
-
+
trainGetNextActionId(cycle, "7");
-
+
+ trainIsRewinding(support, false);
+
trainGetUniqueId(cycle, "myform", "myform_1");
-
+
trainGetNamespace(response, "$ns");
trainGetLinkCheckIgnoreParameter(
@@ -207,13 +208,13 @@
true,
new DirectServiceParameter(form),
link);
-
+
trainRender(support, link, render, "https", new Integer(443));
-
- delegate.setFormComponent(null);
-
+
TapestryUtils.removeForm(cycle);
-
+
+ delegate.setFormComponent(null);
+
replay();
form.render(writer, cycle);
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/TestTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/TestTextField.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/TestTextField.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/TestTextField.java Fri Jun 30 15:20:07 2006
@@ -289,24 +289,27 @@
trainGetForm(cycle, form);
trainWasPrerendered(form, writer, component, false);
trainGetDelegate(form, delegate);
-
+
delegate.setFormComponent(component);
trainGetElementId(form, component, "fred");
trainIsRewinding(form, false);
trainIsRewinding(cycle, false);
-
+
delegate.setFormComponent(component);
-
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
-
+
expect(tfs.format(component, new Integer(10))).andReturn("10");
+ trainGetDelegate(form, delegate);
+
tfs.renderContributions(component, writer, cycle);
+
+ trainGetDelegate(form, delegate);
+
vfs.renderContributions(component, writer, cycle);
+ trainGetDelegate(form, delegate);
+
replay();
component.render(writer, cycle);
@@ -345,14 +348,19 @@
delegate.setFormComponent(component);
trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
expect(tfs.format(component, new Integer(10))).andReturn("10");
+ trainGetDelegate(form, delegate);
+
tfs.renderContributions(component, writer, cycle);
+
+ trainGetDelegate(form, delegate);
+
vfs.renderContributions(component, writer, cycle);
+ trainGetDelegate(form, delegate);
+
replay();
component.render(writer, cycle);
@@ -391,14 +399,19 @@
delegate.setFormComponent(component);
trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
expect(tfs.format(component, new Integer(10))).andReturn("10");
+ trainGetDelegate(form, delegate);
+
tfs.renderContributions(component, writer, cycle);
+
+ trainGetDelegate(form, delegate);
+
vfs.renderContributions(component, writer, cycle);
+ trainGetDelegate(form, delegate);
+
replay();
component.render(writer, cycle);
@@ -431,24 +444,18 @@
trainGetForm(cycle, form);
trainWasPrerendered(form, writer, component, false);
trainGetDelegate(form, delegate);
-
+
delegate.setFormComponent(component);
trainGetElementId(form, component, "fred");
trainIsRewinding(form, false);
trainIsRewinding(cycle, false);
-
- delegate.setFormComponent(component);
-
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
-
+
expect(tfs.format(component, new Integer(10))).andReturn("10");
tfs.renderContributions(component, writer, cycle);
vfs.renderContributions(component, writer, cycle);
-
+
replay();
component.render(writer, cycle);
@@ -486,15 +493,18 @@
delegate.setFormComponent(component);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
-
expect(tfs.format(component, null)).andReturn("");
+ trainGetDelegate(form, delegate);
+
tfs.renderContributions(component, writer, cycle);
+
+ trainGetDelegate(form, delegate);
+
vfs.renderContributions(component, writer, cycle);
+ trainGetDelegate(form, delegate);
+
replay();
component.render(writer, cycle);
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/translator/TestStringTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/translator/TestStringTranslator.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/translator/TestStringTranslator.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/translator/TestStringTranslator.java Fri Jun 30 15:20:07 2006
@@ -21,6 +21,7 @@
import org.apache.tapestry.form.FormComponentContributorContext;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.valid.ValidatorException;
+import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
/**
@@ -34,6 +35,14 @@
{
private StringTranslator _translator = new StringTranslator();
+ @Configuration(afterTestMethod = true)
+ public void reset()
+ {
+ _translator.setTrim(false);
+ _translator.setEmpty(null);
+ _translator.setMessage(null);
+ }
+
public void testFormat()
{
replay();
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java Fri Jun 30 15:20:07 2006
@@ -1032,7 +1032,7 @@
assertEquals(false, ps.getCache());
ps = spec.getParameter("withAliases");
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "fred", "barney" }, ps.getAliasNames().toArray());
assertSame(ps, spec.getParameter("fred"));
@@ -1064,7 +1064,7 @@
assertEquals("http://myexternal/asset", as.getPath());
- assertEquals(new String[]
+ assertListEquals(new String[]
{ "mycontext", "myexternal", "myprivate" }, cs.getAssetNames());
}
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/listener/TestListenerMapSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/listener/TestListenerMapSource.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/listener/TestListenerMapSource.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/listener/TestListenerMapSource.java Fri Jun 30 15:20:07 2006
@@ -199,12 +199,12 @@
public void testReturnLink()
{
- ILink link = newLink("http://foo/bar");
-
IRequestCycle cycle = newLCycle(null);
-
+
+ ILink link = newLink("http://foo/bar");
+
cycle.sendRedirect("http://foo/bar");
-
+
ListenerMethodHolder holder = new ListenerMethodHolder(link);
replay();
@@ -372,6 +372,6 @@
private ListenerMethodHolder newHolder()
{
- return newMock(ListenerMethodHolder.class);
+ return (ListenerMethodHolder)newInstance(ListenerMethodHolder.class);
}
}
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/SessionPropertyPersistenceStrategyTest.java Fri Jun 30 15:20:07 2006
@@ -14,7 +14,7 @@
package org.apache.tapestry.record;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;
@@ -61,7 +61,8 @@
private WebSession newSession(String attributeName, boolean remove)
{
WebSession session = newSession();
-
+ checkOrder(session, false);
+
trainGetAttributeNames(session, Collections.singletonList(attributeName));
if (remove)
@@ -73,7 +74,8 @@
private WebSession newSession(String attributeName, Object value)
{
WebSession session = newMock(WebSession.class);
-
+ checkOrder(session, false);
+
expect(session.getAttributeNames()).andReturn(Collections.singletonList(attributeName));
if (value != null)
@@ -117,8 +119,10 @@
public void testDiscardChangesNoMatch()
{
WebSession session = newSession("session,myapp,Home,foo", false);
- WebRequest request = newRequest(false, session);
-
+
+ WebRequest request = newRequest();
+ expect(request.getSession(false)).andReturn(session);
+
replay();
SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
@@ -146,8 +150,10 @@
public void testDiscardChangesWithMatch()
{
WebSession session = newSession("session,myapp,Home,foo", true);
- WebRequest request = newRequest(false, session);
-
+
+ WebRequest request = newRequest();
+ expect(request.getSession(false)).andReturn(session);
+
replay();
SessionPropertyPersistenceStrategy s = new SessionPropertyPersistenceStrategy();
@@ -162,7 +168,8 @@
public void testGetStoreChangesNoMatch()
{
WebSession session = newSession("session,myapp,Home,foo,bar", null);
- WebRequest request = newRequest(false, session);
+ WebRequest request = newRequest();
+ expect(request.getSession(false)).andReturn(session);
replay();
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/record/TestPageRecorder.java Fri Jun 30 15:20:07 2006
@@ -14,7 +14,7 @@
package org.apache.tapestry.record;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;
@@ -76,7 +76,8 @@
IComponentSpecification spec = newSpec();
IPropertySpecification ps = newMock(IPropertySpecification.class);
-
+ checkOrder(ps, false);
+
expect(spec.getPropertySpecification(propertyName)).andReturn(ps);
expect(ps.getPersistence()).andReturn(persistence);
@@ -91,7 +92,7 @@
IPage page = newPage();
IComponentSpecification spec = newSpec("foobar", "session");
-
+
expect(page.getSpecification()).andReturn(spec);
expect(page.getIdPath()).andReturn(null);
@@ -236,7 +237,8 @@
public void testChangeToNonSpecifiedProperty()
{
- Resource r = fabricateLocation(99).getResource();
+ Resource r = newResource();
+
ErrorLog log = newErrorLog();
IPage page = newPage();
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java Fri Jun 30 15:20:07 2006
@@ -14,7 +14,7 @@
package org.apache.tapestry.resolver;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertSame;
@@ -67,7 +67,8 @@
String type, IComponentSpecification spec)
{
ISpecificationResolverDelegate delegate = newMock(ISpecificationResolverDelegate.class);
-
+ checkOrder(delegate, false);
+
expect(delegate.findComponentSpecification(cycle, namespace, type)).andReturn(spec);
return delegate;
@@ -115,8 +116,8 @@
Log log = newMock(Log.class);
- log
- .warn("Component 'MyComponent' (at classpath:/org/apache/tapestry/resolver/TestComponentSpecificationResolver, line 1) is deprecated, and will likely be removed in a later release. Consult its documentation to find a replacement component.");
+ log.warn(startsWith("Component 'MyComponent' ("));
+ // at classpath:/org/apache/tapestry/resolver/TestComponentSpecificationResolver, line 1) is deprecated, and will likely be removed in a later release. Consult its documentation to find a replacement component.");
replay();
@@ -173,8 +174,6 @@
Resource namespaceLocation = newResource("LibraryStandin.library");
Resource specLocation = namespaceLocation.getRelativeResource("MyComponent.jwc");
- ISpecificationSource source = newSource(specLocation, spec);
-
expect(namespace.containsComponentType("MyComponent")).andReturn(false);
train(log, ResolverMessages.resolvingComponent("MyComponent", namespace));
@@ -182,6 +181,9 @@
expect(namespace.getSpecificationLocation()).andReturn(namespaceLocation);
train(log, ResolverMessages.checkingResource(specLocation));
+
+ ISpecificationSource source = newSource(specLocation, spec);
+
train(log, ResolverMessages.installingComponent("MyComponent", namespace, spec));
namespace.installComponentSpecification("MyComponent", spec);
@@ -226,8 +228,9 @@
expect(namespace.isApplicationNamespace()).andReturn(false);
- ClassFinder finder = newClassFinder("org.foo", "FrameworkComponent", null);
trainGetPackages(namespace, "org.foo");
+
+ ClassFinder finder = newClassFinder("org.foo", "FrameworkComponent", null);
ISpecificationSource source = newSource(framework);
@@ -272,13 +275,13 @@
namespace,
"DelegateComponent",
spec);
-
- Resource namespaceLocation = newResource("LibraryStandin.library");
-
+
expect(namespace.containsComponentType("DelegateComponent")).andReturn(false);
train(log, ResolverMessages.resolvingComponent("DelegateComponent", namespace));
+ Resource namespaceLocation = newResource("LibraryStandin.library");
+
expect(namespace.getSpecificationLocation()).andReturn(namespaceLocation);
train(log, ResolverMessages.checkingResource(namespaceLocation
@@ -286,15 +289,15 @@
expect(namespace.isApplicationNamespace()).andReturn(false);
- ISpecificationSource source = newSource(framework);
-
expect(framework.containsComponentType("DelegateComponent")).andReturn(false);
expect(log.isDebugEnabled()).andReturn(false);
ClassFinder finder = newClassFinder("org.foo", "DelegateComponent", null);
trainGetPackages(namespace, "org.foo");
-
+
+ ISpecificationSource source = newSource(framework);
+
namespace.installComponentSpecification("DelegateComponent", spec);
trainIsDeprecated(spec, false);
@@ -410,8 +413,6 @@
Resource namespaceLocation = newResource("LibraryStandin.library");
Resource specLocation = contextRoot.getRelativeResource("WEB-INF/myapp/MyAppComponent.jwc");
- ISpecificationSource source = newSource(specLocation, spec);
-
expect(namespace.containsComponentType("MyAppComponent")).andReturn(false);
train(log, ResolverMessages.resolvingComponent("MyAppComponent", namespace));
@@ -420,12 +421,15 @@
train(log, ResolverMessages.checkingResource(namespaceLocation
.getRelativeResource("MyAppComponent.jwc")));
-
+
expect(namespace.isApplicationNamespace()).andReturn(true);
train(log, ResolverMessages.checkingResource(specLocation));
+
+ ISpecificationSource source = newSource(specLocation, spec);
+
train(log, ResolverMessages.installingComponent("MyAppComponent", namespace, spec));
-
+
namespace.installComponentSpecification("MyAppComponent", spec);
trainIsDeprecated(spec, false);
@@ -461,11 +465,9 @@
Resource namespaceLocation = newResource("LibraryStandin.library");
Resource specLocation = contextRoot.getRelativeResource("WEB-INF/MyWebInfComponent.jwc");
-
- ISpecificationSource source = newSource(specLocation, spec);
-
+
expect(namespace.containsComponentType("MyWebInfComponent")).andReturn(false);
-
+
train(log, ResolverMessages.resolvingComponent("MyWebInfComponent", namespace));
expect(namespace.getSpecificationLocation()).andReturn(namespaceLocation);
@@ -478,12 +480,15 @@
train(log, ResolverMessages.checkingResource(contextRoot
.getRelativeResource("WEB-INF/myapp/MyWebInfComponent.jwc")));
train(log, ResolverMessages.checkingResource(specLocation));
+
+ ISpecificationSource source = newSource(specLocation, spec);
+
train(log, ResolverMessages.installingComponent("MyWebInfComponent", namespace, spec));
namespace.installComponentSpecification("MyWebInfComponent", spec);
-
+
trainIsDeprecated(spec, false);
-
+
replay();
ComponentSpecificationResolverImpl resolver = new ComponentSpecificationResolverImpl();
@@ -510,39 +515,43 @@
Log log = newLog();
Resource contextRoot = newResource("context/");
-
+
INamespace namespace = newMock(INamespace.class);
-
+
Resource namespaceLocation = newResource("LibraryStandin.library");
Resource specLocation = contextRoot.getRelativeResource("ContextRootComponent.jwc");
-
- ISpecificationSource source = newSource(specLocation, spec);
+
+
expect(namespace.containsComponentType("ContextRootComponent")).andReturn(false);
train(log, ResolverMessages.resolvingComponent("ContextRootComponent", namespace));
-
+
expect(namespace.getSpecificationLocation()).andReturn(namespaceLocation);
train(log, ResolverMessages.checkingResource(namespaceLocation
.getRelativeResource("ContextRootComponent.jwc")));
-
+
expect(namespace.isApplicationNamespace()).andReturn(true);
train(log, ResolverMessages.checkingResource(contextRoot
.getRelativeResource("WEB-INF/myapp/ContextRootComponent.jwc")));
train(log, ResolverMessages.checkingResource(contextRoot
.getRelativeResource("WEB-INF/ContextRootComponent.jwc")));
+
train(log, ResolverMessages.checkingResource(specLocation));
+
+ ISpecificationSource source = newSource(specLocation, spec);
+
train(log, ResolverMessages.installingComponent(
"ContextRootComponent",
namespace,
spec));
- trainIsDeprecated(spec, false);
-
namespace.installComponentSpecification("ContextRootComponent", spec);
+ trainIsDeprecated(spec, false);
+
replay();
ComponentSpecificationResolverImpl resolver = new ComponentSpecificationResolverImpl();
@@ -561,15 +570,15 @@
}
public void testFoundComponentClass()
- {
- Resource componentResource = newResource();
- Resource namespaceResource = newResource("folder/MyComponent.jwc", componentResource);
-
+ {
INamespace namespace = newMock(INamespace.class);
trainGetPackages(namespace, "org.foo");
ClassFinder finder = newClassFinder("org.foo", "folder.MyComponent", BaseComponent.class);
+ Resource componentResource = newResource();
+ Resource namespaceResource = newResource("folder/MyComponent.jwc", componentResource);
+
trainGetResource(namespace, namespaceResource);
replay();
@@ -596,7 +605,8 @@
private Resource newResource(String relativePath, Resource relativeResource)
{
Resource resource = newMock(Resource.class);
-
+ checkOrder(resource, false);
+
expect(resource.getRelativeResource(relativePath)).andReturn(relativeResource);
return resource;
Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/valid/TestValidField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/valid/TestValidField.java?rev=418394&r1=418393&r2=418394&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/valid/TestValidField.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/valid/TestValidField.java Fri Jun 30 15:20:07 2006
@@ -14,7 +14,7 @@
package org.apache.tapestry.valid;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertSame;
@@ -141,35 +141,35 @@
}
public void testRewindNoValidator()
- {
- Location l = newLocation();
-
- IBinding binding = newBinding(l);
-
+ {
IPage page = (IPage) newInstance(BasePage.class);
page.setPageName("Barney");
-
+
ValidField component = newInstance(ValidField.class, new Object[]
{ "page", page, "id", "inputFred", "container", page });
-
- component.setBinding("validator", binding);
-
+
IRequestCycle cycle = newCycle();
IForm form = newMock(IForm.class);
-
+
IMarkupWriter writer = newWriter();
IValidationDelegate delegate = newDelegate();
trainGetForm(cycle, form);
+
+ Location l = newLocation();
+ IBinding binding = newBinding(l);
+
+ component.setBinding("validator", binding);
+
trainWasPrerendered(form, writer, component, false);
trainGetDelegate(form, delegate);
-
+
delegate.setFormComponent(component);
-
+
trainGetElementId(form, component, "fred");
trainIsRewinding(form, true);
-
+
trainGetParameter(cycle, "fred", "fred-value");
replay();
@@ -202,7 +202,8 @@
IRequestCycle cycle = newCycle();
IForm form = newMock(IForm.class);
-
+ checkOrder(form, false);
+
IMarkupWriter writer = newBufferWriter();
MockDelegate delegate = new MockDelegate();
@@ -215,9 +216,6 @@
trainIsRewinding(form, false);
trainIsRewinding(cycle, false);
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
-
trainToString(validator, component, value, "fred value");
expect(validator.isRequired()).andReturn(false);
@@ -255,6 +253,7 @@
page.attach(null, cycle);
IForm form = newMock(IForm.class);
+ checkOrder(form, false);
IMarkupWriter writer = newBufferWriter();
@@ -267,10 +266,7 @@
trainGetElementId(form, component, "fred");
trainIsRewinding(form, false);
trainIsRewinding(cycle, false);
-
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
-
+
trainToString(validator, component, null, null);
expect(validator.isRequired()).andReturn(false);
@@ -300,7 +296,8 @@
IRequestCycle cycle = newCycle();
IForm form = newMock(IForm.class);
-
+ checkOrder(form, false);
+
ValidField component = newInstance(ValidField.class, new Object[]
{ "value", value, "validator", validator, "form", form, "name", "fred" });
@@ -312,13 +309,10 @@
trainGetForm(cycle, form);
trainWasPrerendered(form, writer, component, false);
trainGetDelegate(form, delegate);
-
+
trainGetElementId(form, component, "fred");
trainIsRewinding(form, false);
trainIsRewinding(cycle, false);
-
- trainGetDelegate(form, delegate);
- trainGetDelegate(form, delegate);
expect(validator.isRequired()).andReturn(true);