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/03/11 21:55:35 UTC
svn commit: r385164 [27/32] - in /jakarta/tapestry/trunk: ./ .settings/
annotations/src/java/org/apache/tapestry/annotations/
annotations/src/test/org/apache/tapestry/annotations/ config/
contrib/src/documentation/content/xdocs/tapestry-contrib/Compone...
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestEnhancementOperation.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestEnhancementOperation.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestEnhancementOperation.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestEnhancementOperation.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -51,19 +51,15 @@
*/
public class TestEnhancementOperation extends HiveMindTestCase
{
-
- protected void setUp()
- throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
EnhancementOperationImpl._uid = 97;
}
- /** Test fixture. */
public abstract static class Fixture
{
-
public abstract String getStringProperty();
public abstract boolean isBooleanProperty();
@@ -71,32 +67,26 @@
public abstract boolean getFlagProperty();
}
- /** Test fixture. */
- public abstract static class ValidatingComponent extends AbstractComponent implements PageValidateListener
+ public abstract static class ValidatingComponent extends AbstractComponent implements
+ PageValidateListener
{
}
- /** Test fixture. */
public abstract static class GetClassReferenceFixture
{
-
public abstract Class getClassReference();
}
- /** Test fixture. */
public static class MissingConstructorFixture
{
-
public MissingConstructorFixture(String foo)
{
//
}
}
- /** Test fixture. */
public abstract static class UnclaimedAbstractPropertiesFixture
{
-
public abstract String getReadOnly();
public abstract void setWriteOnly(String value);
@@ -137,8 +127,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
eo.claimReadonlyProperty("foo");
@@ -152,8 +142,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
eo.claimReadonlyProperty("foo");
eo.claimReadonlyProperty("bar");
@@ -178,8 +168,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
try
{
@@ -210,7 +200,7 @@
private ClassFactory newClassFactory(Class baseClass, ClassFab classFab)
{
MockControl control = newControl(ClassFactory.class);
- ClassFactory factory = (ClassFactory)control.getMock();
+ ClassFactory factory = (ClassFactory) control.getMock();
String className = baseClass.getName();
int dotx = className.lastIndexOf('.');
@@ -224,12 +214,12 @@
private ClassFab newClassFab()
{
- return (ClassFab)newMock(ClassFab.class);
+ return (ClassFab) newMock(ClassFab.class);
}
private IComponentSpecification newSpec()
{
- return (IComponentSpecification)newMock(IComponentSpecification.class);
+ return (IComponentSpecification) newMock(IComponentSpecification.class);
}
public void testConstructorAndAccessors()
@@ -239,8 +229,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
assertSame(BaseComponent.class, eo.getBaseClass());
@@ -254,8 +244,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
assertEquals(false, eo.implementsInterface(PageValidateListener.class));
@@ -282,10 +272,10 @@
IComponentSpecification spec = newSpec();
MockControl factoryc = newControl(ClassFactory.class);
- ClassFactory factory = (ClassFactory)factoryc.getMock();
+ ClassFactory factory = (ClassFactory) factoryc.getMock();
MockControl classfabc = newControl(ClassFab.class);
- ClassFab classfab = (ClassFab)classfabc.getMock();
+ ClassFab classfab = (ClassFab) classfabc.getMock();
factory.newClass("$BaseComponent_97", BaseComponent.class);
factoryc.setReturnValue(classfab);
@@ -294,10 +284,13 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- factory, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, factory, null);
- eo.extendMethodImplementation(PageDetachListener.class, EnhanceUtils.PAGE_DETACHED_SIGNATURE, "foo();");
+ eo.extendMethodImplementation(
+ PageDetachListener.class,
+ EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+ "foo();");
assertEquals(false, eo.implementsInterface(PageValidateListener.class));
@@ -309,10 +302,10 @@
IComponentSpecification spec = newSpec();
MockControl factoryc = newControl(ClassFactory.class);
- ClassFactory factory = (ClassFactory)factoryc.getMock();
+ ClassFactory factory = (ClassFactory) factoryc.getMock();
MockControl classfabc = newControl(ClassFab.class);
- ClassFab classfab = (ClassFab)classfabc.getMock();
+ ClassFab classfab = (ClassFab) classfabc.getMock();
factory.newClass("$BaseComponent_97", BaseComponent.class);
factoryc.setReturnValue(classfab);
@@ -321,10 +314,13 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- factory, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, factory, null);
- eo.extendMethodImplementation(PageDetachListener.class, EnhanceUtils.PAGE_DETACHED_SIGNATURE, "foo();");
+ eo.extendMethodImplementation(
+ PageDetachListener.class,
+ EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+ "foo();");
assertEquals(true, eo.implementsInterface(PageDetachListener.class));
@@ -338,8 +334,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
// Validates because BaseComponent doesn't have such a property.
@@ -355,11 +351,10 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
- // Validates because BaseComponent inherits a page property of type
- // IPage
+ // Validates because BaseComponent inherits a page property of type IPage
eo.validateProperty("page", IPage.class);
@@ -373,11 +368,10 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
- // Validates because BaseComponent inherits a page property of type
- // IPage
+ // Validates because BaseComponent inherits a page property of type IPage
try
{
@@ -386,8 +380,11 @@
}
catch (ApplicationRuntimeException ex)
{
- assertEquals(EnhanceMessages.propertyTypeMismatch(BaseComponent.class, "page", IPage.class, String.class),
- ex.getMessage());
+ assertEquals(EnhanceMessages.propertyTypeMismatch(
+ BaseComponent.class,
+ "page",
+ IPage.class,
+ String.class), ex.getMessage());
}
verifyControls();
@@ -400,8 +397,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
assertSame(boolean.class, eo.convertTypeName("boolean"));
assertSame(float[].class, eo.convertTypeName("float[]"));
@@ -430,9 +427,9 @@
IComponentSpecification spec = newSpec();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
- ClassFab fab = (ClassFab)newMock(ClassFab.class);
+ ClassFab fab = (ClassFab) newMock(ClassFab.class);
cf.newClass("$BaseComponent_97", BaseComponent.class);
@@ -442,8 +439,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
eo.addField("fred", String.class);
@@ -455,10 +452,10 @@
IComponentSpecification spec = newSpec();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
cf.newClass("$BaseComponent_97", BaseComponent.class);
@@ -470,8 +467,8 @@
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
- BaseComponent.class, cf, null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(),
+ spec, BaseComponent.class, cf, null);
assertEquals("fred", eo.addInjectedField("fred", String.class, "FRED_VALUE"));
@@ -493,7 +490,8 @@
body.addln("fred_0 = $2;");
body.end();
- fab.addConstructor(new Class[] { String.class, Map.class }, null, body.toString());
+ fab.addConstructor(new Class[]
+ { String.class, Map.class }, null, body.toString());
fabc.setMatcher(new ArrayMatcher());
replayControls();
@@ -513,10 +511,10 @@
IComponentSpecification spec = newSpec();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
// We force the uid to 97 in setUp()
@@ -529,7 +527,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, baseClass, cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ baseClass, cf, null);
eo.addMethod(Modifier.PUBLIC, sig, "method body", l);
@@ -547,10 +546,10 @@
IComponentSpecification spec = newSpec();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
// We force the uid to 97 in setUp()
@@ -563,7 +562,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, baseClass, cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ baseClass, cf, null);
eo.addMethod(Modifier.PUBLIC, sig, "method body", firstLocation);
@@ -574,8 +574,9 @@
}
catch (ApplicationRuntimeException ex)
{
- assertEquals("A new implementation of method 'void frob()' conflicts with an existing "
- + "implementation (at classpath:/org/apache/tapestry/enhance/TestEnhancementOperation, line 1).",
+ assertEquals(
+ "A new implementation of method 'void frob()' conflicts with an existing "
+ + "implementation (at classpath:/org/apache/tapestry/enhance/TestEnhancementOperation, line 1).",
ex.getMessage());
assertSame(secondLocation, ex.getLocation());
}
@@ -590,8 +591,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, Fixture.class, cf,
- null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ Fixture.class, cf, null);
assertEquals("getStringProperty", eo.getAccessorMethodName("stringProperty"));
assertEquals("isBooleanProperty", eo.getAccessorMethodName("booleanProperty"));
@@ -602,41 +603,37 @@
}
/**
- * On this test, instead of mocking up everything, we actually use the raw
- * implementations to construct a new class; the class gets a class
- * reference passed to it in its constructor.
+ * On this test, instead of mocking up everything, we actually use the raw implementations to
+ * construct a new class; the class gets a class reference passed to it in its constructor.
*/
- public void testGetClassReference()
- throws Exception
+ public void testGetClassReference() throws Exception
{
Location l = newLocation();
MockControl specControl = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specControl.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specControl.getMock();
spec.getLocation();
specControl.setReturnValue(l);
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
- GetClassReferenceFixture.class, new ClassFactoryImpl(), null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(),
+ spec, GetClassReferenceFixture.class, new ClassFactoryImpl(), null);
- // This does two things; it creates a new field, and it sets up a new
- // constructor
- // parameter to inject the class value (Map.class) into each new
- // instance.
+ // This does two things; it creates a new field, and it sets up a new constructor
+ // parameter to inject the class value (Map.class) into each new instance.
String ref = eo.getClassReference(Map.class);
String ref2 = eo.getClassReference(Map.class);
- eo.addMethod(Modifier.PUBLIC, new MethodSignature(Class.class, "getClassReference", null, null), "return "
- + ref + ";", l);
+ eo.addMethod(Modifier.PUBLIC, new MethodSignature(Class.class, "getClassReference", null,
+ null), "return " + ref + ";", l);
ComponentConstructor cc = eo.getConstructor();
- GetClassReferenceFixture f = (GetClassReferenceFixture)cc.newInstance();
+ GetClassReferenceFixture f = (GetClassReferenceFixture) cc.newInstance();
assertSame(Map.class, f.getClassReference());
@@ -645,17 +642,16 @@
assertSame(ref, ref2);
}
- public void testGetArrayClassReference()
- throws Exception
+ public void testGetArrayClassReference() throws Exception
{
MockControl specControl = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specControl.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specControl.getMock();
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
- GetClassReferenceFixture.class, new ClassFactoryImpl(), null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(),
+ spec, GetClassReferenceFixture.class, new ClassFactoryImpl(), null);
String ref = eo.getClassReference(int[].class);
@@ -665,18 +661,17 @@
}
/**
- * Really a test for
- * {@link org.apache.tapestry.enhance.ComponentConstructorImpl};
- * {@link #testGetClassReference()}tests the success case, just want to
- * fill in the failure.
+ * Really a test for {@link org.apache.tapestry.enhance.ComponentConstructorImpl};
+ * {@link #testGetClassReference()}tests the success case, just want to fill in the failure.
*/
public void testComponentConstructorFailure()
{
Location l = newLocation();
- ComponentConstructor cc = new ComponentConstructorImpl(BaseComponent.class.getConstructors()[0],
- new Object[] { "unexpected" }, "<classfab>", l);
+ ComponentConstructor cc = new ComponentConstructorImpl(BaseComponent.class
+ .getConstructors()[0], new Object[]
+ { "unexpected" }, "<classfab>", l);
try
{
@@ -685,7 +680,9 @@
}
catch (ApplicationRuntimeException ex)
{
- assertExceptionSubstring(ex, "Unable to instantiate instance of class org.apache.tapestry.BaseComponent");
+ assertExceptionSubstring(
+ ex,
+ "Unable to instantiate instance of class org.apache.tapestry.BaseComponent");
assertSame(l, ex.getLocation());
}
}
@@ -697,8 +694,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, BaseComponent.class,
- cf, null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ BaseComponent.class, cf, null);
assertEquals(Map.class, eo.getPropertyType("assets"));
assertEquals(IPage.class, eo.getPropertyType("page"));
@@ -712,14 +709,14 @@
public void testFindUnclaimedAbstractProperties()
{
- ClassResolver cr = (ClassResolver)newMock(ClassResolver.class);
+ ClassResolver cr = (ClassResolver) newMock(ClassResolver.class);
IComponentSpecification spec = newSpec();
ClassFactory cf = newClassFactory(UnclaimedAbstractPropertiesFixture.class);
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(cr, spec, UnclaimedAbstractPropertiesFixture.class, cf,
- null);
+ EnhancementOperation eo = new EnhancementOperationImpl(cr, spec,
+ UnclaimedAbstractPropertiesFixture.class, cf, null);
List l = eo.findUnclaimedAbstractProperties();
@@ -747,12 +744,12 @@
{
ClassResolver cr = new DefaultClassResolver();
MockControl specc = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specc.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specc.getMock();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
fab.addInterface(PageDetachListener.class);
@@ -761,7 +758,8 @@
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class, cf, null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class,
+ cf, null);
MethodSignature sig = EnhanceUtils.PAGE_DETACHED_SIGNATURE;
@@ -798,19 +796,20 @@
{
ClassResolver cr = new DefaultClassResolver();
MockControl specc = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specc.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specc.getMock();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
cf.newClass("$BaseComponent_97", BaseComponent.class);
cfc.setReturnValue(fab);
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class, cf, null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class,
+ cf, null);
MethodSignature sig = EnhanceUtils.FINISH_LOAD_SIGNATURE;
@@ -838,19 +837,20 @@
{
ClassResolver cr = new DefaultClassResolver();
MockControl specc = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specc.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specc.getMock();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
cf.newClass("$BaseComponent_97", BaseComponent.class);
cfc.setReturnValue(fab);
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class, cf, null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, BaseComponent.class,
+ cf, null);
// A protected method
MethodSignature sig = EnhanceUtils.CLEANUP_AFTER_RENDER_SIGNATURE;
@@ -859,7 +859,10 @@
verifyControls();
- fab.addMethod(Modifier.PUBLIC, sig, "{\n super.cleanupAfterRender($$);\n some-code();\n}\n");
+ fab.addMethod(
+ Modifier.PUBLIC,
+ sig,
+ "{\n super.cleanupAfterRender($$);\n some-code();\n}\n");
fabc.setReturnValue(null);
fab.createClass();
@@ -875,8 +878,8 @@
verifyControls();
}
- /** Test fixture. */
- public abstract static class ExistingAbstractMethodFixture extends BaseComponent implements PageDetachListener
+ public static abstract class ExistingAbstractMethodFixture extends BaseComponent implements
+ PageDetachListener
{
//
}
@@ -885,20 +888,20 @@
{
ClassResolver cr = new DefaultClassResolver();
MockControl specc = newControl(IComponentSpecification.class);
- IComponentSpecification spec = (IComponentSpecification)specc.getMock();
+ IComponentSpecification spec = (IComponentSpecification) specc.getMock();
MockControl cfc = newControl(ClassFactory.class);
- ClassFactory cf = (ClassFactory)cfc.getMock();
+ ClassFactory cf = (ClassFactory) cfc.getMock();
MockControl fabc = newControl(ClassFab.class);
- ClassFab fab = (ClassFab)fabc.getMock();
+ ClassFab fab = (ClassFab) fabc.getMock();
cf.newClass("$ExitingAbstractMethodFixture_97", ExistingAbstractMethodFixture.class);
cfc.setReturnValue(fab);
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec, ExistingAbstractMethodFixture.class, cf,
- null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(cr, spec,
+ ExistingAbstractMethodFixture.class, cf, null);
MethodSignature sig = EnhanceUtils.PAGE_DETACHED_SIGNATURE;
@@ -923,11 +926,10 @@
}
/**
- * This seems to pass on the command line, but fail inside Eclipse. I think
- * Eclipse's Java compiler works a little different from Java's ... in this
- * example (TODO: Create test fixture classes for this test) the getTarget()
- * method doesn't show up as a declared public method when Eclipse compiles
- * the code, but does when JDK compiles the code.
+ * This seems to pass on the command line, but fail inside Eclipse. I think Eclipse's Java
+ * compiler works a little different from Java's ... in this example (TODO: Create test fixture
+ * classes for this test) the getTarget() method doesn't show up as a declared public method
+ * when Eclipse compiles the code, but does when JDK compiles the code.
*/
public void testPropertyInheritedFromInterface()
{
@@ -936,8 +938,8 @@
replayControls();
- EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, ServiceLink.class, cf,
- null);
+ EnhancementOperation eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec,
+ ServiceLink.class, cf, null);
assertEquals(String.class, eo.getPropertyType("target"));
@@ -949,7 +951,7 @@
IComponentSpecification spec = newSpec();
MockControl control = newControl(ClassFab.class);
- ClassFab classFab = (ClassFab)control.getMock();
+ ClassFab classFab = (ClassFab) control.getMock();
Throwable t = new RuntimeException("Inconceivable!");
@@ -960,8 +962,8 @@
replayControls();
- EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(), spec, ServiceLink.class,
- cf, null);
+ EnhancementOperationImpl eo = new EnhancementOperationImpl(new DefaultClassResolver(),
+ spec, ServiceLink.class, cf, null);
try
{
@@ -970,12 +972,13 @@
}
catch (ApplicationRuntimeException ex)
{
- assertEquals("Failure enhancing class org.apache.tapestry.link.ServiceLink: Inconceivable!", ex
- .getMessage());
+ assertEquals(
+ "Failure enhancing class org.apache.tapestry.link.ServiceLink: Inconceivable!",
+ ex.getMessage());
assertSame(classFab, ex.getComponent());
assertSame(t, ex.getRootCause());
}
verifyControls();
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectMessagesWorker.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectMessagesWorker.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectMessagesWorker.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestInjectMessagesWorker.java Sat Mar 11 12:54:27 2006
@@ -50,7 +50,7 @@
MockControl control = newControl(EnhancementOperation.class);
EnhancementOperation op = (EnhancementOperation) control.getMock();
- op.claimReadonlyProperty(w._messagesProperty);
+ op.claimReadonlyProperty(w.MESSAGES_PROPERTY);
op.addInjectedField("_$componentMessagesSource", ComponentMessagesSource.class, source);
control.setReturnValue("fred");
@@ -62,7 +62,7 @@
builder.end();
op.addField("_$messages", Messages.class);
- op.addMethod(Modifier.PUBLIC, w._methodSignature, builder.toString(), l);
+ op.addMethod(Modifier.PUBLIC, w.METHOD_SIGNATURE, builder.toString(), l);
replayControls();
@@ -79,14 +79,14 @@
InjectMessagesWorker w = new InjectMessagesWorker();
Throwable ex = new ApplicationRuntimeException(EnhanceMessages
- .claimedProperty(w._messagesProperty));
+ .claimedProperty(w.MESSAGES_PROPERTY));
IComponentSpecification spec = newSpec(l);
MockControl control = newControl(EnhancementOperation.class);
EnhancementOperation op = (EnhancementOperation) control.getMock();
- op.claimReadonlyProperty(w._messagesProperty);
+ op.claimReadonlyProperty(w.MESSAGES_PROPERTY);
control.setThrowable(ex);
op.getBaseClass();
@@ -95,7 +95,7 @@
ErrorLog log = (ErrorLog) newMock(ErrorLog.class);
log.error(
- EnhanceMessages.errorAddingProperty(w._messagesProperty, BaseComponent.class, ex),
+ EnhanceMessages.errorAddingProperty(w.MESSAGES_PROPERTY, BaseComponent.class, ex),
l,
ex);
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/enhance/TestSpecifiedPropertyWorker.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -44,13 +44,13 @@
*/
public class TestSpecifiedPropertyWorker extends HiveMindTestCase
{
-
private List buildPropertySpecs(String name, String type, boolean persistent)
{
return buildPropertySpecs(name, type, persistent, null, null);
}
- private List buildPropertySpecs(String name, String type, boolean persistent, Location location, String initialValue)
+ private List buildPropertySpecs(String name, String type, boolean persistent,
+ Location location, String initialValue)
{
PropertySpecification ps = new PropertySpecification();
ps.setName(name);
@@ -66,23 +66,23 @@
{
List names = new ArrayList();
Iterator i = propertySpecs.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- IPropertySpecification ps = (IPropertySpecification)i.next();
+ IPropertySpecification ps = (IPropertySpecification) i.next();
names.add(ps.getName());
}
MockControl c = newControl(IComponentSpecification.class);
- IComponentSpecification result = (IComponentSpecification)c.getMock();
+ IComponentSpecification result = (IComponentSpecification) c.getMock();
result.getPropertySpecificationNames();
c.setReturnValue(names);
i = propertySpecs.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- IPropertySpecification ps = (IPropertySpecification)i.next();
+ IPropertySpecification ps = (IPropertySpecification) i.next();
result.getPropertySpecification(ps.getName());
c.setReturnValue(ps);
@@ -91,22 +91,27 @@
return result;
}
- private IComponentSpecification buildComponentSpecification(String name, String type, boolean persistent)
+ private IComponentSpecification buildComponentSpecification(String name, String type,
+ boolean persistent)
{
return buildComponentSpecification(buildPropertySpecs(name, type, persistent));
}
- public void testAddNormal()
- throws Exception
+ public void testAddNormal() throws Exception
{
Location l = newLocation();
- IComponentSpecification spec = buildComponentSpecification(buildPropertySpecs("fred", "boolean", false, l, null));
+ IComponentSpecification spec = buildComponentSpecification(buildPropertySpecs(
+ "fred",
+ "boolean",
+ false,
+ l,
+ null));
// Training
MockControl opc = newControl(EnhancementOperation.class);
- EnhancementOperation op = (EnhancementOperation)opc.getMock();
+ EnhancementOperation op = (EnhancementOperation) opc.getMock();
op.convertTypeName("boolean");
opc.setReturnValue(boolean.class);
@@ -118,16 +123,25 @@
op.getAccessorMethodName("fred");
opc.setReturnValue("isFred");
- op.addMethod(Modifier.PUBLIC, new MethodSignature(boolean.class, "isFred", null, null), "return _$fred;", l);
+ op.addMethod(
+ Modifier.PUBLIC,
+ new MethodSignature(boolean.class, "isFred", null, null),
+ "return _$fred;",
+ l);
- op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setFred", new Class[] { boolean.class }, null),
- "{\n _$fred = $1;\n}\n", l);
+ op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setFred", new Class[]
+ { boolean.class }, null), "{\n _$fred = $1;\n}\n", l);
op.addField("_$fred$default", boolean.class);
- op.extendMethodImplementation(IComponent.class, EnhanceUtils.FINISH_LOAD_SIGNATURE, "_$fred$default = _$fred;");
-
- op.extendMethodImplementation(PageDetachListener.class, EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+ op.extendMethodImplementation(
+ IComponent.class,
+ EnhanceUtils.FINISH_LOAD_SIGNATURE,
+ "_$fred$default = _$fred;");
+
+ op.extendMethodImplementation(
+ PageDetachListener.class,
+ EnhanceUtils.PAGE_DETACHED_SIGNATURE,
"_$fred = _$fred$default;");
replayControls();
@@ -139,22 +153,25 @@
verifyControls();
}
- public void testAddWithInitialValue()
- throws Exception
+ public void testAddWithInitialValue() throws Exception
{
- BindingSource bs = (BindingSource)newMock(BindingSource.class);
+ BindingSource bs = (BindingSource) newMock(BindingSource.class);
Location l = fabricateLocation(12);
- IComponentSpecification spec = buildComponentSpecification(buildPropertySpecs("fred", "java.util.List", false,
- l, "ognl:foo()"));
+ IComponentSpecification spec = buildComponentSpecification(buildPropertySpecs(
+ "fred",
+ "java.util.List",
+ false,
+ l,
+ "ognl:foo()"));
- InitialValueBindingCreator expectedCreator = new InitialValueBindingCreator(bs, EnhanceMessages
- .initialValueForProperty("fred"), "ognl:foo()", l);
+ InitialValueBindingCreator expectedCreator = new InitialValueBindingCreator(bs,
+ EnhanceMessages.initialValueForProperty("fred"), "ognl:foo()", l);
// Training
MockControl opc = newControl(EnhancementOperation.class);
- EnhancementOperation op = (EnhancementOperation)opc.getMock();
+ EnhancementOperation op = (EnhancementOperation) opc.getMock();
op.convertTypeName("java.util.List");
opc.setReturnValue(List.class);
@@ -166,16 +183,26 @@
op.getAccessorMethodName("fred");
opc.setReturnValue("getFred");
- op.addMethod(Modifier.PUBLIC, new MethodSignature(List.class, "getFred", null, null), "return _$fred;", l);
-
- op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setFred", new Class[] { List.class }, null),
- "{\n _$fred = $1;\n}\n", l);
-
- op.addInjectedField("_$fred$initialValueBindingCreator", InitialValueBindingCreator.class, expectedCreator);
+ op.addMethod(
+ Modifier.PUBLIC,
+ new MethodSignature(List.class, "getFred", null, null),
+ "return _$fred;",
+ l);
+
+ op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setFred", new Class[]
+ { List.class }, null), "{\n _$fred = $1;\n}\n", l);
+
+ op.addInjectedField(
+ "_$fred$initialValueBindingCreator",
+ InitialValueBindingCreator.class,
+ expectedCreator);
opc.setReturnValue("_$fred$initialValueBindingCreator");
op.addField("_$fred$initialValueBinding", IBinding.class);
- op.extendMethodImplementation(IComponent.class, EnhanceUtils.FINISH_LOAD_SIGNATURE,
- "_$fred$initialValueBinding = _$fred$initialValueBindingCreator.createBinding(this);\n");
+ op
+ .extendMethodImplementation(
+ IComponent.class,
+ EnhanceUtils.FINISH_LOAD_SIGNATURE,
+ "_$fred$initialValueBinding = _$fred$initialValueBindingCreator.createBinding(this);\n");
op.getClassReference(List.class);
opc.setReturnValue("_$class$java$util$List");
@@ -183,7 +210,10 @@
String code = "_$fred = (java.util.List) _$fred$initialValueBinding.getObject(_$class$java$util$List);\n";
op.extendMethodImplementation(IComponent.class, EnhanceUtils.FINISH_LOAD_SIGNATURE, code);
- op.extendMethodImplementation(PageDetachListener.class, EnhanceUtils.PAGE_DETACHED_SIGNATURE, code);
+ op.extendMethodImplementation(
+ PageDetachListener.class,
+ EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+ code);
replayControls();
@@ -195,15 +225,17 @@
verifyControls();
}
- public void testAddPersistent()
- throws Exception
+ public void testAddPersistent() throws Exception
{
- IComponentSpecification spec = buildComponentSpecification("barney", "java.lang.String", true);
+ IComponentSpecification spec = buildComponentSpecification(
+ "barney",
+ "java.lang.String",
+ true);
// Training
MockControl opc = newControl(EnhancementOperation.class);
- EnhancementOperation op = (EnhancementOperation)opc.getMock();
+ EnhancementOperation op = (EnhancementOperation) opc.getMock();
op.convertTypeName("java.lang.String");
opc.setReturnValue(String.class);
@@ -215,7 +247,10 @@
op.getAccessorMethodName("barney");
opc.setReturnValue("getBarney");
- op.addMethod(Modifier.PUBLIC, new MethodSignature(String.class, "getBarney", null, null), "return _$barney;",
+ op.addMethod(
+ Modifier.PUBLIC,
+ new MethodSignature(String.class, "getBarney", null, null),
+ "return _$barney;",
null);
BodyBuilder b = new BodyBuilder();
@@ -224,15 +259,19 @@
b.addln("_$barney = $1;");
b.end();
- op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setBarney", new Class[] { String.class }, null),
- b.toString(), null);
+ op.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "setBarney", new Class[]
+ { String.class }, null), b.toString(), null);
op.addField("_$barney$default", String.class);
- op.extendMethodImplementation(IComponent.class, EnhanceUtils.FINISH_LOAD_SIGNATURE,
+ op.extendMethodImplementation(
+ IComponent.class,
+ EnhanceUtils.FINISH_LOAD_SIGNATURE,
"_$barney$default = _$barney;");
- op.extendMethodImplementation(PageDetachListener.class, EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+ op.extendMethodImplementation(
+ PageDetachListener.class,
+ EnhanceUtils.PAGE_DETACHED_SIGNATURE,
"_$barney = _$barney$default;");
replayControls();
@@ -244,8 +283,7 @@
verifyControls();
}
- public void testFailure()
- throws Exception
+ public void testFailure() throws Exception
{
Location l = fabricateLocation(207);
// Should be "java.lang.Long"
@@ -253,7 +291,7 @@
IComponentSpecification spec = buildComponentSpecification(propertySpecs);
MockControl opc = newControl(EnhancementOperation.class);
- EnhancementOperation op = (EnhancementOperation)opc.getMock();
+ EnhancementOperation op = (EnhancementOperation) opc.getMock();
op.convertTypeName("Long");
Throwable ex = new ApplicationRuntimeException("Simulated error.");
@@ -262,9 +300,13 @@
op.getBaseClass();
opc.setReturnValue(BaseComponent.class);
- ErrorLog log = (ErrorLog)newMock(ErrorLog.class);
+ ErrorLog log = (ErrorLog) newMock(ErrorLog.class);
- log.error("Error adding property wilma to class org.apache.tapestry.BaseComponent: Simulated error.", l, ex);
+ log
+ .error(
+ "Error adding property wilma to class org.apache.tapestry.BaseComponent: Simulated error.",
+ l,
+ ex);
replayControls();
@@ -276,4 +318,4 @@
verifyControls();
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/error/TestExceptionPresenter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/error/TestExceptionPresenter.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/error/TestExceptionPresenter.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/error/TestExceptionPresenter.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -28,16 +28,12 @@
*/
public class TestExceptionPresenter extends BaseErrorTestCase
{
-
- /** Test fixture. */
public abstract static class ExceptionFixture extends BasePage
{
-
public abstract void setException(Throwable exception);
}
- public void testSuccess()
- throws Exception
+ public void testSuccess() throws Exception
{
Throwable cause = new IllegalArgumentException();
IPage page = newPage();
@@ -60,8 +56,7 @@
assertSame(cause, page.getProperty("exception"));
}
- public void testFailure()
- throws Exception
+ public void testFailure() throws Exception
{
Throwable cause = new IllegalArgumentException();
Throwable renderCause = new ApplicationRuntimeException("Some failure.");
@@ -75,7 +70,9 @@
cycle.activate(page);
reporter.reportRequestException(ErrorMessages.unableToProcessClientRequest(cause), cause);
- reporter.reportRequestException(ErrorMessages.unableToPresentExceptionPage(renderCause), renderCause);
+ reporter.reportRequestException(
+ ErrorMessages.unableToPresentExceptionPage(renderCause),
+ renderCause);
replayControls();
@@ -98,4 +95,4 @@
assertSame(cause, page.getProperty("exception"));
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/event/ReportStatusEventTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/event/ReportStatusEventTest.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/event/ReportStatusEventTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/event/ReportStatusEventTest.java Sat Mar 11 12:54:27 2006
@@ -57,7 +57,7 @@
receiver.property("boolean-false", false);
receiver.property("byte", (byte) 37);
receiver.property("char", 'z');
- receiver.property("double", 3.14);
+ receiver.property("double", (double) 3.14);
receiver.property("float", (float) 9.99);
receiver.property("int", -373);
receiver.property("long", 373737l);
@@ -76,7 +76,7 @@
event.property("boolean-false", false);
event.property("byte", (byte) 37);
event.property("char", 'z');
- event.property("double", 3.14);
+ event.property("double", (double) 3.14);
event.property("float", (float) 9.99);
event.property("int", -373);
event.property("long", 373737l);
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormSupportTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormSupportTest.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormSupportTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormSupportTest.java Sat Mar 11 12:54:27 2006
@@ -206,7 +206,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -320,7 +320,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -390,7 +390,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -520,7 +520,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -573,7 +573,7 @@
try
{
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
unreachable();
}
catch (ApplicationRuntimeException ex)
@@ -696,7 +696,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -771,7 +771,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -1051,7 +1051,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -1140,7 +1140,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -1154,9 +1154,9 @@
IValidationDelegate delegate = newDelegate();
ILink link = newLink();
IRender render = newRender();
-
+
MockForm form = new MockForm(delegate);
-
+
trainIsRewound(cycle, form, false);
trainGetEngine(cycle, engine);
@@ -1186,7 +1186,7 @@
trainGetNestedWriter(writer, nested);
- trainGetURL(link, "https", "https://foo.bar/app");
+ trainGetURL(link, "https", "https://foo.bar/app", 443);
writer.begin("form");
writer.attribute("method", "post");
@@ -1213,7 +1213,7 @@
replayControls();
- fs.render("post", render, link, "https");
+ fs.render("post", render, link, "https", new Integer(443));
verifyControls();
}
@@ -1376,7 +1376,7 @@
replayControls();
- fs.render("post", render, link, null);
+ fs.render("post", render, link, null, null);
verifyControls();
}
@@ -1417,12 +1417,17 @@
setReturnValue(delegate, fieldName);
}
- private void trainGetURL(ILink link, String scheme, String URL)
+ private void trainGetURL(ILink link, String scheme, String URL, int port)
{
// This will change shortly, with the new scheme parameter passed into FormSupport.render()
- link.getURL(scheme, null, 0, null, false);
+ link.getURL(scheme, null, port, null, false);
setReturnValue(link, URL);
+ }
+
+ private void trainGetURL(ILink link, String scheme, String URL)
+ {
+ trainGetURL(link, scheme, URL, 0);
}
private void trainHidden(IMarkupWriter writer, String name, String value)
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/FormTest.java Sat Mar 11 12:54:27 2006
@@ -165,7 +165,7 @@
new DirectServiceParameter(form),
link);
- trainRender(support, link, render, null);
+ trainRender(support, link, render, null, null);
delegate.setFormComponent(null);
@@ -192,7 +192,7 @@
Form 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" });
+ "post", "delegate", delegate, "scheme", "https", "port", new Integer(443) });
trainStoreForm(cycle, form);
@@ -211,7 +211,7 @@
new DirectServiceParameter(form),
link);
- trainRender(support, link, render, "https");
+ trainRender(support, link, render, "https", new Integer(443));
delegate.setFormComponent(null);
@@ -231,9 +231,9 @@
cycle.setAttribute(TapestryUtils.FORM_ATTRIBUTE, form);
}
- private void trainRender(FormSupport support, ILink link, IRender render, String scheme)
+ private void trainRender(FormSupport support, ILink link, IRender render, String scheme, Integer port)
{
- support.render("post", render, link, scheme);
+ support.render("post", render, link, scheme, port);
getControl(support).setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
{ null, new IgnoreMatcher(), null, null }));
}
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -40,7 +40,6 @@
*/
public class LinkSubmitTest extends BaseComponentTestCase
{
- /** Test fixture. */
private class ScriptFixture implements IScript
{
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/MockDelegate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/MockDelegate.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/MockDelegate.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/MockDelegate.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,19 +26,17 @@
import org.apache.tapestry.valid.ValidatorException;
/**
- * Mock implementation of {@link org.apache.tapestry.valid.IValidationDelegate}
- * used for testing (particularily, to test how the delegate decorates fields
- * and field labels.
+ * Mock implementation of {@link org.apache.tapestry.valid.IValidationDelegate} used for testing
+ * (particularily, to test how the delegate decorates fields and field labels.
*
* @author Howard M. Lewis Ship
* @since 4.0
*/
public class MockDelegate implements IValidationDelegate
{
-
private static final long serialVersionUID = -1940135823929783031L;
- private IFormComponent _component;
+ private IFormComponent _component;
private String _input;
@@ -108,19 +106,21 @@
{
}
- public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
+ public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator)
{
writer.begin("span");
writer.attribute("class", "prefix");
}
- public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
- IValidator validator)
+ public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
+ IFormComponent component, IValidator validator)
{
writer.attribute("class", "validation-delegate");
}
- public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
+ public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator)
{
writer.end();
}
@@ -128,12 +128,12 @@
public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
{
}
-
- public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component)
+
+ public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component)
{
- }
+ }
- public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
+ public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
{
}
@@ -164,7 +164,7 @@
public void record(IFormComponent field, String message)
{
// TODO Auto-generated method stub
-
+
}
}
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestButton.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestButton.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestButton.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestButton.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,18 +20,12 @@
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.spec.ComponentSpecification;
-/**
- * Tests the {@link org.apache.tapestry.form.Button} component.
- *
- * @author Howard M. Lewis Ship
- * @since 4.0
- */
public class TestButton extends BaseComponentTestCase
{
-
public void testRender()
{
- Button b = (Button)newInstance(Button.class, new Object[] { "name", "assignedName" });
+ Button b = (Button) newInstance(Button.class, new Object[]
+ { "name", "assignedName" });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -47,7 +41,8 @@
public void testRenderLabel()
{
- Button b = (Button)newInstance(Button.class, new Object[] { "name", "assignedName", "label", "Label" });
+ Button b = (Button) newInstance(Button.class, new Object[]
+ { "name", "assignedName", "label", "Label" });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -63,8 +58,8 @@
public void testRenderInformalParameters()
{
- Button b = (Button)newInstance(Button.class, new Object[] { "name", "assignedName", "specification",
- new ComponentSpecification() });
+ Button b = (Button) newInstance(Button.class, new Object[]
+ { "name", "assignedName", "specification", new ComponentSpecification() });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -84,7 +79,8 @@
public void testRenderWithId()
{
- Button b = (Button)newInstance(Button.class, new Object[] { "idParameter", "foo", "name", "assignedName" });
+ Button b = (Button) newInstance(Button.class, new Object[]
+ { "idParameter", "foo", "name", "assignedName" });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycleGetUniqueId("foo", "foo$unique");
@@ -100,7 +96,7 @@
public void testSubmit()
{
- Button b = (Button)newInstance(Button.class);
+ Button b = (Button) newInstance(Button.class);
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestCheckbox.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestCheckbox.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestCheckbox.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestCheckbox.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -31,11 +31,10 @@
*/
public class TestCheckbox extends BaseFormComponentTestCase
{
-
public void testRenderChecked()
{
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "name", "assignedName", "value",
- Boolean.TRUE });
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "name", "assignedName", "value", Boolean.TRUE });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -51,8 +50,8 @@
public void testRenderDisabled()
{
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "name", "assignedName", "disabled",
- Boolean.TRUE });
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "name", "assignedName", "disabled", Boolean.TRUE });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -68,8 +67,9 @@
public void testRenderInformalParameters()
{
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "name", "assignedName", "value",
- Boolean.TRUE, "specification", new ComponentSpecification() });
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "name", "assignedName", "value", Boolean.TRUE, "specification",
+ new ComponentSpecification() });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycle();
@@ -89,8 +89,8 @@
public void testRenderWithId()
{
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "idParameter", "foo", "name",
- "assignedName", "value", Boolean.TRUE });
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "idParameter", "foo", "name", "assignedName", "value", Boolean.TRUE });
IMarkupWriter writer = newBufferWriter();
IRequestCycle cycle = newCycleGetUniqueId("foo", "foo$unique");
@@ -106,27 +106,27 @@
public void testSubmitNull()
{
- ValidatableFieldSupport vfs = (ValidatableFieldSupport)newMock(ValidatableFieldSupport.class);
-
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "value", Boolean.TRUE, "name", "checkbox",
- "validatableFieldSupport", vfs });
+ ValidatableFieldSupport vfs = (ValidatableFieldSupport) newMock(ValidatableFieldSupport.class);
+
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "value", Boolean.TRUE, "name", "checkbox", "validatableFieldSupport", vfs });
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycleGetParameter("checkbox", null);
try
{
- vfs.validate(cb, writer, cycle, null);
+ vfs.validate(cb, writer, cycle, null);
}
catch (ValidatorException e)
{
- unreachable();
+ unreachable();
}
-
+
replayControls();
cb.rewindFormComponent(writer, cycle);
-
+
verifyControls();
assertEquals(false, cb.getValue());
@@ -135,64 +135,64 @@
public void testSubmitValidateFailed()
{
MockControl vfsc = newControl(ValidatableFieldSupport.class);
- ValidatableFieldSupport vfs = (ValidatableFieldSupport)vfsc.getMock();
-
+ ValidatableFieldSupport vfs = (ValidatableFieldSupport) vfsc.getMock();
+
MockControl formc = newControl(IForm.class);
- IForm form = (IForm)formc.getMock();
-
+ IForm form = (IForm) formc.getMock();
+
IValidationDelegate delegate = newDelegate();
-
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "form", form, "value", Boolean.FALSE,
- "name", "checkbox", "validatableFieldSupport", vfs });
+
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "form", form, "value", Boolean.FALSE, "name", "checkbox", "validatableFieldSupport", vfs });
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycleGetParameter("checkbox", "foo");
ValidatorException exception = new ValidatorException("failed");
-
+
try
{
- vfs.validate(cb, writer, cycle, "foo");
- vfsc.setThrowable(exception);
- }
+ vfs.validate(cb, writer, cycle, "foo");
+ vfsc.setThrowable(exception);
+ }
catch (ValidatorException e)
{
- unreachable();
+ unreachable();
}
form.getDelegate();
formc.setReturnValue(delegate);
-
+
delegate.record(exception);
replayControls();
cb.rewindFormComponent(writer, cycle);
-
+
verifyControls();
-
+
assertEquals(false, cb.getValue());
}
public void testSubmitNonNull()
{
- ValidatableFieldSupport vfs = (ValidatableFieldSupport)newMock(ValidatableFieldSupport.class);
-
- Checkbox cb = (Checkbox)newInstance(Checkbox.class, new Object[] { "value", Boolean.FALSE, "name", "checkbox",
- "validatableFieldSupport", vfs });
+ ValidatableFieldSupport vfs = (ValidatableFieldSupport) newMock(ValidatableFieldSupport.class);
+
+ Checkbox cb = (Checkbox) newInstance(Checkbox.class, new Object[]
+ { "value", Boolean.FALSE, "name", "checkbox", "validatableFieldSupport", vfs });
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycleGetParameter("checkbox", "foo");
try
{
- vfs.validate(cb, writer, cycle, "foo");
+ vfs.validate(cb, writer, cycle, "foo");
}
catch (ValidatorException e)
{
- unreachable();
+ unreachable();
}
-
+
replayControls();
cb.rewindFormComponent(writer, cycle);
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestListEditMap.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestListEditMap.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestListEditMap.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/TestListEditMap.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@
package org.apache.tapestry.form;
+import org.apache.tapestry.form.ListEditMap;
import org.apache.tapestry.junit.TapestryTestCase;
import org.apache.tapestry.spec.BeanLifecycle;
@@ -44,11 +45,12 @@
assertEquals("render", m.getKey());
- checkList("keys", new Object[] { "request", "page", "render" }, m.getKeys());
- checkList("all values", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m
- .getAllValues());
- checkList("all values", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m
- .getValues());
+ checkList("keys", new Object[]
+ { "request", "page", "render" }, m.getKeys());
+ checkList("all values", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getAllValues());
+ checkList("all values", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getValues());
assertTrue(m.getDeletedKeys().isEmpty());
}
@@ -84,12 +86,14 @@
assertEquals(true, m.isDeleted());
- checkList("all values", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m
- .getAllValues());
+ checkList("all values", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getAllValues());
- checkList("undeleted values", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.RENDER }, m.getValues());
+ checkList("undeleted values", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.RENDER }, m.getValues());
- checkList("deleted keys", new Object[] { "page" }, m.getDeletedKeys());
+ checkList("deleted keys", new Object[]
+ { "page" }, m.getDeletedKeys());
}
public void testMarkAlreadyDeleted()
@@ -118,7 +122,8 @@
assertEquals(true, m.isDeleted());
- checkList("undeleted values", new Object[] { BeanLifecycle.REQUEST }, m.getValues());
+ checkList("undeleted values", new Object[]
+ { BeanLifecycle.REQUEST }, m.getValues());
}
public void testDeleteUndelete()
@@ -132,7 +137,8 @@
m.setKey("render");
m.setDeleted(true);
- checkList("undeleted values", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m.getValues());
+ checkList("undeleted values", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m.getValues());
}
/** @since 4.0 */
@@ -144,21 +150,24 @@
m.setKey("render");
m.setDeleted(true);
- checkList("deleted keys before purge", new Object[] { "render" }, m.getDeletedKeys());
+ checkList("deleted keys before purge", new Object[]
+ { "render" }, m.getDeletedKeys());
m.purgeDeletedKeys();
- checkList("all values after purge", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m
- .getAllValues());
- checkList("keys after purge", new Object[] { "request", "page" }, m.getKeys());
+ checkList("all values after purge", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m.getAllValues());
+ checkList("keys after purge", new Object[]
+ { "request", "page" }, m.getKeys());
assertTrue(m.getDeletedKeys().isEmpty());
m.purgeDeletedKeys();
- checkList("all values after second purge", new Object[] { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m
- .getAllValues());
- checkList("keys after second purge", new Object[] { "request", "page" }, m.getKeys());
+ checkList("all values after second purge", new Object[]
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m.getAllValues());
+ checkList("keys after second purge", new Object[]
+ { "request", "page" }, m.getKeys());
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TestNumberTranslator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TestNumberTranslator.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TestNumberTranslator.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TestNumberTranslator.java Sat Mar 11 12:54:27 2006
@@ -28,14 +28,13 @@
import org.easymock.MockControl;
/**
- * Tests for {@link org.apache.tapestry.form.translator.NumberTranslator}.
+ * Tests for {@link org.apache.tapestry.form.translator.NumberTranslator}
*
* @author Howard Lewis Ship
* @since 4.0
*/
public class TestNumberTranslator extends FormComponentContributorTestCase
{
-
public void testDefaultFormat()
{
NumberTranslator translator = new NumberTranslator();
@@ -95,16 +94,14 @@
verify();
}
- public void testDefaultParse()
- throws Exception
+ public void testDefaultParse() throws Exception
{
NumberTranslator translator = new NumberTranslator();
testParse(translator, "0.1", new Double(0.1));
}
- public void testCustomParse()
- throws Exception
+ public void testCustomParse() throws Exception
{
NumberTranslator translator = new NumberTranslator();
@@ -113,8 +110,7 @@
testParse(translator, "10%", new Double(0.1));
}
- public void testTrimmedParse()
- throws Exception
+ public void testTrimmedParse() throws Exception
{
NumberTranslator translator = new NumberTranslator();
@@ -123,19 +119,18 @@
testParse(translator, " 100 ", new Long(100));
}
- private void testParse(Translator translator, String number, Number expected)
- throws Exception
+ private void testParse(Translator translator, String number, Number expected) throws Exception
{
IFormComponent field = newField();
MockControl messagesc = newControl(ValidationMessages.class);
- ValidationMessages messages = (ValidationMessages)messagesc.getMock();
+ ValidationMessages messages = (ValidationMessages) messagesc.getMock();
trainGetLocale(messagesc, messages, Locale.ENGLISH);
replayControls();
- Number result = (Number)translator.parse(field, messages, number);
+ Number result = (Number) translator.parse(field, messages, number);
assertEquals(expected, result);
@@ -166,13 +161,19 @@
IFormComponent field = newField("Number Field");
MockControl messagesc = newControl(ValidationMessages.class);
- ValidationMessages messages = (ValidationMessages)messagesc.getMock();
+ ValidationMessages messages = (ValidationMessages) messagesc.getMock();
trainGetLocale(messagesc, messages, Locale.ENGLISH);
trainGetLocale(messagesc, messages, Locale.ENGLISH);
- trainBuildMessage(messagesc, messages, messageOverride, ValidationStrings.INVALID_NUMBER, new Object[] {
- "Number Field", "#" }, "invalid number");
+ trainBuildMessage(
+ messagesc,
+ messages,
+ messageOverride,
+ ValidationStrings.INVALID_NUMBER,
+ new Object[]
+ { "Number Field", "#" },
+ "invalid number");
replayControls();
@@ -199,14 +200,15 @@
IRequestCycle cycle = newCycle();
MockControl contextc = newControl(FormComponentContributorContext.class);
- FormComponentContributorContext context = (FormComponentContributorContext)contextc.getMock();
+ FormComponentContributorContext context = (FormComponentContributorContext) contextc
+ .getMock();
context.includeClasspathScript(translator.defaultScript());
trainGetLocale(contextc, context, Locale.ENGLISH);
- trainBuildMessage(contextc, context, null, ValidationStrings.INVALID_NUMBER,
- new Object[] { "Number Field", "#" }, "invalid number message");
+ trainBuildMessage(contextc, context, null, ValidationStrings.INVALID_NUMBER, new Object[]
+ { "Number Field", "#" }, "invalid number message");
context
.addSubmitHandler("function(event) { Tapestry.validate_number(event, 'numberField', 'invalid number message'); }");
@@ -230,14 +232,21 @@
IRequestCycle cycle = newCycle();
MockControl contextc = newControl(FormComponentContributorContext.class);
- FormComponentContributorContext context = (FormComponentContributorContext)contextc.getMock();
+ FormComponentContributorContext context = (FormComponentContributorContext) contextc
+ .getMock();
context.includeClasspathScript(translator.defaultScript());
trainGetLocale(contextc, context, Locale.ENGLISH);
- trainBuildMessage(contextc, context, messageOverride, ValidationStrings.INVALID_NUMBER, new Object[] {
- "Number Field", "#" }, "Blah Blah 'Field Name' Blah.");
+ trainBuildMessage(
+ contextc,
+ context,
+ messageOverride,
+ ValidationStrings.INVALID_NUMBER,
+ new Object[]
+ { "Number Field", "#" },
+ "Blah Blah 'Field Name' Blah.");
context
.addSubmitHandler("function(event) { Tapestry.validate_number(event, 'myfield', 'Blah Blah \\'Field Name\\' Blah.'); }");
@@ -264,7 +273,8 @@
IRequestCycle cycle = newCycle();
MockControl contextc = newControl(FormComponentContributorContext.class);
- FormComponentContributorContext context = (FormComponentContributorContext)contextc.getMock();
+ FormComponentContributorContext context = (FormComponentContributorContext) contextc
+ .getMock();
context.includeClasspathScript(translator.defaultScript());
@@ -272,8 +282,8 @@
trainGetLocale(contextc, context, Locale.ENGLISH);
- trainBuildMessage(contextc, context, null, ValidationStrings.INVALID_NUMBER,
- new Object[] { "Number Field", "#" }, "invalid number message");
+ trainBuildMessage(contextc, context, null, ValidationStrings.INVALID_NUMBER, new Object[]
+ { "Number Field", "#" }, "invalid number message");
context
.addSubmitHandler("function(event) { Tapestry.validate_number(event, 'myfield', 'invalid number message'); }");
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TranslatorTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TranslatorTestCase.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TranslatorTestCase.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/translator/TranslatorTestCase.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,8 +14,8 @@
package org.apache.tapestry.form.translator;
-import org.apache.tapestry.form.FormComponentContributorTestCase;
import org.apache.tapestry.form.FormEventType;
+import org.apache.tapestry.form.FormComponentContributorTestCase;
/**
* Abstract test case for {@link Translator}.
@@ -25,18 +25,17 @@
*/
public abstract class TranslatorTestCase extends FormComponentContributorTestCase
{
-
protected void trim()
{
_component.getForm();
_componentControl.setReturnValue(_form);
-
+
_form.getName();
_formControl.setReturnValue("formName");
-
+
_component.getName();
_componentControl.setReturnValue("fieldName");
-
+
_form.addEventHandler(FormEventType.SUBMIT, "trim(document.formName.fieldName)");
_formControl.setVoidCallable();
}
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxDate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxDate.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxDate.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxDate.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,18 +26,16 @@
import org.apache.tapestry.valid.ValidatorException;
/**
- * Tests for {@link org.apache.tapestry.form.validator.MaxDate}.
+ * Tests for {@link org.apache.tapestry.form.validator.MaxDate}
*
* @author Howard Lewis Ship
* @since 4.0
*/
public class TestMaxDate extends BaseValidatorTestCase
{
+ private static final long ONE_DAY = 24 * 60 * 60 * 1000l;
- private static final long ONE_DAY = 24 * 60 * 60 * 1000L;
-
- public void testOK()
- throws Exception
+ public void testOK() throws Exception
{
long now = System.currentTimeMillis();
@@ -57,8 +55,7 @@
verifyControls();
}
- public void testFail()
- throws Exception
+ public void testFail() throws Exception
{
long now = System.currentTimeMillis();
@@ -66,7 +63,11 @@
Date tomorrow = new Date(now + ONE_DAY);
IFormComponent field = newField("Fred");
- ValidationMessages message = newMessages(null, ValidationStrings.DATE_TOO_LATE, new Object[] { "Fred", today },
+ ValidationMessages message = newMessages(
+ null,
+ ValidationStrings.DATE_TOO_LATE,
+ new Object[]
+ { "Fred", today },
"default message");
replayControls();
@@ -88,8 +89,7 @@
verifyControls();
}
- public void testFailCustomMessage()
- throws Exception
+ public void testFailCustomMessage() throws Exception
{
long now = System.currentTimeMillis();
@@ -97,8 +97,12 @@
Date tomorrow = new Date(now + ONE_DAY);
IFormComponent field = newField("Fred");
- ValidationMessages message = newMessages("custom", ValidationStrings.DATE_TOO_LATE, new Object[] { "Fred",
- today }, "custom message");
+ ValidationMessages message = newMessages(
+ "custom",
+ ValidationStrings.DATE_TOO_LATE,
+ new Object[]
+ { "Fred", today },
+ "custom message");
replayControls();
Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxLength.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxLength.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxLength.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/form/validator/TestMaxLength.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -24,17 +24,10 @@
import org.apache.tapestry.valid.ValidatorException;
import org.easymock.MockControl;
-/**
- * Tests for {@link org.apache.tapestry.form.validator.MaxLength}.
- *
- * @author Howard M. Lewis Ship
- * @since 4.0
- */
public class TestMaxLength extends BaseValidatorTestCase
{
- public void testOK()
- throws Exception
+ public void testOK() throws Exception
{
IFormComponent field = newField();
ValidationMessages messages = newMessages();
@@ -51,14 +44,19 @@
public void testFail()
{
IFormComponent field = newField("My Field");
- ValidationMessages messages = newMessages(null, ValidationStrings.VALUE_TOO_LONG, new Object[] {
- new Integer(10), "My Field" }, "Exception!");
+ ValidationMessages messages = newMessages(
+ null,
+ ValidationStrings.VALUE_TOO_LONG,
+ new Object[]
+ { new Integer(10), "My Field" },
+ "Exception!");
replayControls();
try
{
- new MaxLength("maxLength=10").validate(field, messages, "brevity is the essence of wit");
+ new MaxLength("maxLength=10")
+ .validate(field, messages, "brevity is the essence of wit");
}
catch (ValidatorException ex)
{
@@ -70,14 +68,20 @@
public void testFailCustomMessage()
{
IFormComponent field = newField("My Field");
- ValidationMessages messages = newMessages("Too Long", ValidationStrings.VALUE_TOO_LONG, new Object[] {
- new Integer(10), "My Field" }, "Exception!");
+ ValidationMessages messages = newMessages(
+ "Too Long",
+ ValidationStrings.VALUE_TOO_LONG,
+ new Object[]
+ { new Integer(10), "My Field" },
+ "Exception!");
replayControls();
try
{
- new MaxLength("maxLength=10,message=Too Long").validate(field, messages,
+ new MaxLength("maxLength=10,message=Too Long").validate(
+ field,
+ messages,
"this should be more than ten characters");
}
catch (ValidatorException ex)
@@ -93,12 +97,13 @@
IRequestCycle cycle = newCycle();
IFormComponent field = newField("My Field", "myfield");
MockControl contextc = newControl(FormComponentContributorContext.class);
- FormComponentContributorContext context = (FormComponentContributorContext)contextc.getMock();
+ FormComponentContributorContext context = (FormComponentContributorContext) contextc
+ .getMock();
context.includeClasspathScript("/org/apache/tapestry/form/validator/StringValidator.js");
- trainFormatMessage(contextc, context, null, ValidationStrings.VALUE_TOO_LONG, new Object[] { new Integer(20),
- "My Field" }, "default\\message");
+ trainFormatMessage(contextc, context, null, ValidationStrings.VALUE_TOO_LONG, new Object[]
+ { new Integer(20), "My Field" }, "default\\message");
context
.addSubmitHandler("function(event) { Tapestry.validate_max_length(event, 'myfield', 20, 'default\\\\message'); }");
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org