You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2004/12/19 16:36:13 UTC
cvs commit: jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/form TestListEditMap.java
hlship 2004/12/19 07:36:13
Modified: framework/src/test/org/apache/tapestry/junit
TapestryTestCase.java
framework/src/test/org/apache/tapestry/junit/parse
TestSpecificationParser.java
framework/src/test/org/apache/tapestry/binding
TestAssetBinding.java TestExpressionBinding.java
BindingTestCase.java TestMessageBinding.java
TestBeanBinding.java
framework/src/test/org/apache/tapestry/junit/utils
TestDataSqueezer.java TestEnum.java
framework/src/test/org/apache/tapestry/junit/form
TestListEditMap.java
Added: framework/src/test/org/apache/tapestry/junit/parse
Assets_3_0.page BeanSet.page
ExpressionBeanInitializer_3_0.page Assets.page
framework/src/test/org/apache/tapestry/html TestShell.java
framework/src/test/org/apache/tapestry/binding
TestLiteralBinding.java
framework/src/test/org/apache/tapestry/services/impl
TestEngineServiceObjectProvider.java
TestBaseTagWriter.java
framework/src/test/org/apache/tapestry/asset
TestAssetSource.java
Removed: framework/src/test/org/apache/tapestry/binding
TestStaticBinding.java
Log:
Consoliated <context-asset>, <private-asset> and <external-asset> into <asset>
Consolidated <set-property> and <set-message-property> into <set>
More flexibility on the order of elements
Revision Changes Path
1.3 +28 -0 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TapestryTestCase.java
Index: TapestryTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TapestryTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TapestryTestCase.java 12 Dec 2004 13:51:16 -0000 1.2
+++ TapestryTestCase.java 19 Dec 2004 15:36:13 -0000 1.3
@@ -20,12 +20,18 @@
import junit.framework.AssertionFailedError;
import org.apache.hivemind.ClassResolver;
+import org.apache.hivemind.Location;
import org.apache.hivemind.Resource;
import org.apache.hivemind.impl.DefaultClassResolver;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.hivemind.util.ClasspathResource;
+import org.apache.tapestry.IBinding;
+import org.apache.tapestry.IComponent;
import org.apache.tapestry.Tapestry;
+import org.apache.tapestry.binding.LiteralBinding;
+import org.apache.tapestry.coerce.ValueConverter;
import org.apache.tapestry.parse.SpecificationParser;
+import org.apache.tapestry.services.BindingSource;
import org.apache.tapestry.services.ExpressionCache;
import org.apache.tapestry.services.ExpressionEvaluator;
import org.apache.tapestry.services.impl.ExpressionCacheImpl;
@@ -49,6 +55,26 @@
private ClassResolver _resolver = new DefaultClassResolver();
+ /** @since 3.1 */
+ private ValueConverter _valueConverter = new ValueConverter()
+ {
+ public Object coerceValue(Object value, Class desiredType)
+ {
+ return value;
+ }
+ };
+
+ /** @since 3.1 */
+ private class BindingSourceFixture implements BindingSource
+ {
+
+ public IBinding createBinding(IComponent component, String description, String locator,
+ Location location)
+ {
+ return new LiteralBinding(description, locator, _valueConverter, location);
+ }
+ }
+
protected IComponentSpecification parseComponent(String simpleName) throws Exception
{
SpecificationParser parser = new SpecificationParser(_resolver);
@@ -61,6 +87,8 @@
protected IComponentSpecification parsePage(String simpleName) throws Exception
{
SpecificationParser parser = new SpecificationParser(_resolver);
+
+ parser.setBindingSource(new BindingSourceFixture());
Resource location = getSpecificationResourceLocation(simpleName);
1.7 +77 -2 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java
Index: TestSpecificationParser.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/TestSpecificationParser.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestSpecificationParser.java 20 Nov 2004 21:21:29 -0000 1.6
+++ TestSpecificationParser.java 19 Dec 2004 15:36:13 -0000 1.7
@@ -18,10 +18,12 @@
import java.util.Map;
import org.apache.hivemind.Locatable;
+import org.apache.tapestry.bean.BindingBeanInitializer;
import org.apache.tapestry.bean.MessageBeanInitializer;
import org.apache.tapestry.junit.TapestryTestCase;
import org.apache.tapestry.spec.BindingType;
import org.apache.tapestry.spec.IApplicationSpecification;
+import org.apache.tapestry.spec.IAssetSpecification;
import org.apache.tapestry.spec.IBeanSpecification;
import org.apache.tapestry.spec.IBindingSpecification;
import org.apache.tapestry.spec.IComponentSpecification;
@@ -581,13 +583,50 @@
IBeanSpecification bs = spec.getBeanSpecification("fred");
checkLine(bs, 24);
- MessageBeanInitializer i = (MessageBeanInitializer) bs.getInitializers().get(0);
+ BindingBeanInitializer i = (BindingBeanInitializer) bs.getInitializers().get(0);
assertEquals("barney", i.getPropertyName());
- assertEquals("rubble", i.getKey());
+ assertEquals("message:rubble", i.getBindingReference());
checkLine(i, 25);
}
+ /**
+ * Tests the DTD 3.0 <set-property>element
+ *
+ * @since 3.1
+ */
+
+ public void testExpressionBeanInitializer() throws Exception
+ {
+ IComponentSpecification spec = parsePage("ExpressionBeanInitializer_3_0.page");
+
+ IBeanSpecification bs = spec.getBeanSpecification("zebean");
+
+ BindingBeanInitializer i = (BindingBeanInitializer) bs.getInitializers().get(0);
+
+ assertEquals("barney", i.getPropertyName());
+ assertEquals("ognl:rubble", i.getBindingReference());
+
+ i = (BindingBeanInitializer) bs.getInitializers().get(1);
+
+ assertEquals("fred", i.getPropertyName());
+ assertEquals("ognl:flintstone", i.getBindingReference());
+ }
+
+ /** @since 3.1 */
+
+ public void testBeanSet() throws Exception
+ {
+ IComponentSpecification spec = parsePage("BeanSet.page");
+ IBeanSpecification bs = spec.getBeanSpecification("target");
+
+ BindingBeanInitializer i = (BindingBeanInitializer) bs.getInitializers().get(0);
+
+ assertEquals("literal", i.getPropertyName());
+ assertEquals("literal-string", i.getBindingReference());
+
+ }
+
public void testInheritInformalParameters() throws Exception
{
IComponentSpecification spec = parseComponent("TestInheritInformal.jwc");
@@ -960,4 +999,40 @@
assertEquals("ognl:an.expression", ps.getDefaultValue());
}
+ /**
+ * Tests that assets read using the 3.0 DTD are converted properly into paths with the proper
+ * prefix.
+ *
+ * @since 3.1
+ */
+ public void testAssets_3_0() throws Exception
+ {
+ IComponentSpecification cs = parsePage("Assets_3_0.page");
+
+ IAssetSpecification as = cs.getAsset("mycontext");
+
+ assertEquals("context:path/to/context", as.getPath());
+
+ as = cs.getAsset("myprivate");
+
+ assertEquals("classpath:path/to/private", as.getPath());
+
+ as = cs.getAsset("myexternal");
+
+ assertEquals("http://myexternal/asset", as.getPath());
+
+ assertListsEqual(new String[]
+ { "mycontext", "myexternal", "myprivate" }, cs.getAssetNames());
+ }
+
+ /** @since 3.1 */
+
+ public void testAssets() throws Exception
+ {
+ IComponentSpecification cs = parsePage("Assets.page");
+
+ IAssetSpecification as = cs.getAsset("myasset");
+
+ assertEquals("path/to/asset", as.getPath());
+ }
}
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/Assets_3_0.page
Index: Assets_3_0.page
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<page-specification>
<context-asset name="mycontext" path="path/to/context"/>
<private-asset name="myprivate" resource-path="path/to/private"/>
<external-asset name="myexternal" URL="http://myexternal/asset"/>
</page-specification>
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/BeanSet.page
Index: BeanSet.page
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.1//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
<page-specification>
<bean name="target" class="java.util.HashMap">
<set name="literal" value="literal-string"/>
<set name="expression" value="ognl:an-expression"/>
<set name="wrapped">
wrapped-literal
</set>
</bean>
</page-specification>
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/ExpressionBeanInitializer_3_0.page
Index: ExpressionBeanInitializer_3_0.page
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<page-specification>
<bean name="zebean" class="java.util.HashMap">
<set-property name="barney" expression="rubble"/>
<set-property name="fred">
flintstone
</set-property>
</bean>
</page-specification>
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/parse/Assets.page
Index: Assets.page
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.1//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
<page-specification>
<asset name="myasset" path="path/to/asset"/>
</page-specification>
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/html/TestShell.java
Index: TestShell.java
===================================================================
package org.apache.tapestry.html;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IPage;
import org.apache.tapestry.IRender;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.spec.ApplicationSpecification;
import org.apache.tapestry.spec.IApplicationSpecification;
import org.apache.tapestry.test.Creator;
import org.easymock.MockControl;
/**
* Tests for the {@link org.apache.tapestry.html.Shell} component.
*
* @author Howard M. Lewis Ship
* @since 3.1
*/
public class TestShell extends HiveMindTestCase
{
private Creator _creator = new Creator();
private IMarkupWriter newMarkupWriter()
{
return (IMarkupWriter) newMock(IMarkupWriter.class);
}
private IRequestCycle newRequestCycle(boolean rewinding)
{
MockControl control = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) control.getMock();
cycle.isRewinding();
control.setReturnValue(rewinding);
return cycle;
}
private IRender newRender()
{
return (IRender) newMock(IRender.class);
}
private IApplicationSpecification newSpec()
{
ApplicationSpecification spec = new ApplicationSpecification();
spec.setName("TestShell");
return spec;
}
private IPage newPage(String name)
{
MockControl control = newControl(IPage.class);
IPage page = (IPage) control.getMock();
page.getPageName();
control.setReturnValue(name);
return page;
}
/**
* Test that Shell does very little when the entire page is rewinding (which itself is a
* holdback to the action service).
*/
public void testRewinding()
{
IMarkupWriter writer = newMarkupWriter();
IRequestCycle cycle = newRequestCycle(true);
IRender body = newRender();
body.render(writer, cycle);
replayControls();
Shell shell = (Shell) _creator.newInstance(Shell.class);
shell.addBody(body);
shell.render(writer, cycle);
verifyControls();
}
}
1.3 +1 -1 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java
Index: TestAssetBinding.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestAssetBinding.java 12 Dec 2004 13:51:17 -0000 1.2
+++ TestAssetBinding.java 19 Dec 2004 15:36:13 -0000 1.3
@@ -50,7 +50,7 @@
assertSame(asset, b.getObject());
assertSame(l, b.getLocation());
- assertEquals("parameterName", b.getParameterName());
+ assertEquals("parameterName", b.getDescription());
assertSame(component, b.getComponent());
1.2 +5 -3 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
Index: TestExpressionBinding.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestExpressionBinding.java 12 Dec 2004 13:51:17 -0000 1.1
+++ TestExpressionBinding.java 19 Dec 2004 15:36:13 -0000 1.2
@@ -168,7 +168,7 @@
MockControl ecc = newControl(ExpressionCache.class);
ExpressionCache ec = (ExpressionCache) ecc.getMock();
- IComponent component = newComponent();
+ IComponent component = newComponent("Foo/bar.baz");
Object compiled = new Object();
ValueConverter vc = newValueConverter();
@@ -181,7 +181,7 @@
replayControls();
- ExpressionBinding b = new ExpressionBinding(component, "param", "exp", vc,
+ ExpressionBinding b = new ExpressionBinding(component, "parameter foo", "exp", vc,
fabricateLocation(1), ev, ec);
try
@@ -191,7 +191,9 @@
}
catch (BindingException ex)
{
- assertEquals("Binding value may not be updated.", ex.getMessage());
+ assertEquals(
+ "Binding for parameter foo (ExpressionBinding[Foo/bar.baz exp]) may not be updated.",
+ ex.getMessage());
}
verifyControls();
1.2 +12 -0 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/BindingTestCase.java
Index: BindingTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/BindingTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BindingTestCase.java 12 Dec 2004 13:51:16 -0000 1.1
+++ BindingTestCase.java 19 Dec 2004 15:36:13 -0000 1.2
@@ -17,6 +17,7 @@
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.coerce.ValueConverter;
+import org.easymock.MockControl;
/**
* Base class for building tests for {@link org.apache.tapestry.IBinding}implementations.
@@ -30,6 +31,17 @@
protected IComponent newComponent()
{
return (IComponent) newMock(IComponent.class);
+ }
+
+ protected IComponent newComponent(String extendedId)
+ {
+ MockControl control = newControl(IComponent.class);
+ IComponent component = (IComponent) control.getMock();
+
+ component.getExtendedId();
+ control.setReturnValue(extendedId);
+
+ return component;
}
protected ValueConverter newValueConverter()
1.2 +4 -4 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java
Index: TestMessageBinding.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestMessageBinding.java 12 Dec 2004 13:51:16 -0000 1.1
+++ TestMessageBinding.java 19 Dec 2004 15:36:13 -0000 1.2
@@ -20,7 +20,7 @@
import org.easymock.MockControl;
/**
- * Tests for {@link org.apache.tapestry.binding.StringBinding}(yes, another name snafu).
+ * Tests for {@link org.apache.tapestry.binding.MessageBinding}.
*
* @author Howard M. Lewis Ship
* @since 3.1
@@ -35,7 +35,7 @@
replayControls();
- StringBinding b = new StringBinding(component, "param", "key", vc, fabricateLocation(12));
+ MessageBinding b = new MessageBinding(component, "param", "key", vc, fabricateLocation(12));
assertSame(component, b.getComponent());
assertEquals("key", b.getKey());
@@ -54,7 +54,7 @@
replayControls();
- StringBinding b = new StringBinding(component, "param", "key", vc, fabricateLocation(12));
+ MessageBinding b = new MessageBinding(component, "param", "key", vc, fabricateLocation(12));
assertEquals("StringBinding[Foo/bar.baz key]", b.toString());
@@ -78,7 +78,7 @@
mc.setReturnValue("value");
replayControls();
- StringBinding b = new StringBinding(component, "param", "key", vc, fabricateLocation(12));
+ MessageBinding b = new MessageBinding(component, "param", "key", vc, fabricateLocation(12));
assertEquals("value", b.getObject());
1.2 +1 -1 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestBeanBinding.java
Index: TestBeanBinding.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestBeanBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestBeanBinding.java 9 Dec 2004 16:29:31 -0000 1.1
+++ TestBeanBinding.java 19 Dec 2004 15:36:13 -0000 1.2
@@ -56,7 +56,7 @@
assertSame(component, binding.getComponent());
assertSame(l, binding.getLocation());
- assertEquals("param", binding.getParameterName());
+ assertEquals("param", binding.getDescription());
}
}
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java
Index: TestLiteralBinding.java
===================================================================
// Copyright 2004 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry.binding;
import java.util.Date;
import org.apache.hivemind.Location;
import org.apache.tapestry.BindingException;
import org.apache.tapestry.coerce.ValueConverter;
import org.easymock.MockControl;
/**
* Tests for {@link org.apache.tapestry.binding.LiteralBinding}. It also tests some common
* behaviors provided by {@link org.apache.tapestry.binding.AbstractBinding}.
*
* @author Howard M. Lewis Ship
* @since 3.1
*/
public class TestLiteralBinding extends BindingTestCase
{
public void testGetObject()
{
Location l = fabricateLocation(22);
ValueConverter vc = newValueConverter();
replayControls();
LiteralBinding b = new LiteralBinding("parameter foo", "literal-value", vc, l);
assertSame(l, b.getLocation());
assertEquals("parameter foo", b.getDescription());
assertEquals("literal-value", b.getObject());
assertEquals(true, b.isInvariant());
assertNull(b.getComponent());
verifyControls();
}
public void testToString()
{
Location l = fabricateLocation(22);
ValueConverter vc = newValueConverter();
replayControls();
LiteralBinding b = new LiteralBinding("parameter foo", "literal-value", vc, l);
assertEquals("StaticBinding[literal-value]", b.toString());
verifyControls();
}
public void testGetObjectWithClass()
{
MockControl control = newControl(ValueConverter.class);
ValueConverter vc = (ValueConverter) control.getMock();
Date date = new Date();
vc.coerceValue("my-literal", Date.class);
control.setReturnValue(date);
replayControls();
LiteralBinding b = new LiteralBinding("parameter foo", "my-literal", vc,
fabricateLocation(99));
assertSame(date, b.getObject(Date.class));
verifyControls();
}
public void testGetObjectException()
{
MockControl control = newControl(ValueConverter.class);
ValueConverter vc = (ValueConverter) control.getMock();
Exception innerException = new RuntimeException("Failure");
vc.coerceValue("my-literal", Date.class);
control.setThrowable(innerException);
replayControls();
Location location = fabricateLocation(99);
LiteralBinding b = new LiteralBinding("parameter foo", "my-literal", vc, location);
try
{
b.getObject(Date.class);
unreachable();
}
catch (BindingException ex)
{
assertEquals("Error converting value for parameter foo: Failure", ex.getMessage());
assertSame(innerException, ex.getRootCause());
assertSame(location, ex.getLocation());
assertSame(b, ex.getBinding());
}
verifyControls();
}
public void testSetObject()
{
Location l = fabricateLocation(22);
ValueConverter vc = newValueConverter();
replayControls();
LiteralBinding b = new LiteralBinding("parameter foo", "literal-value", vc, l);
try
{
b.setObject("fred");
unreachable();
}
catch (BindingException ex)
{
assertEquals(
"Binding for parameter foo (StaticBinding[literal-value]) may not be updated.",
ex.getMessage());
assertSame(b, ex.getBinding());
assertSame(l, ex.getLocation());
}
}
}
1.3 +2 -3 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/utils/TestDataSqueezer.java
Index: TestDataSqueezer.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/utils/TestDataSqueezer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestDataSqueezer.java 9 Dec 2004 17:08:05 -0000 1.2
+++ TestDataSqueezer.java 19 Dec 2004 15:36:13 -0000 1.3
@@ -29,7 +29,6 @@
import org.apache.hivemind.impl.DefaultClassResolver;
import org.apache.hivemind.util.PropertyUtils;
import org.apache.tapestry.services.DataSqueezer;
-import org.apache.tapestry.spec.AssetType;
import org.apache.tapestry.spec.BeanLifecycle;
import org.apache.tapestry.util.ComponentAddress;
import org.apache.tapestry.util.io.DataSqueezerImpl;
@@ -138,7 +137,7 @@
public void testEnum() throws IOException
{
- attempt(AssetType.PRIVATE, "Eorg.apache.tapestry.spec.AssetType@PRIVATE");
+ attempt(BeanLifecycle.PAGE, "Eorg.apache.tapestry.spec.BeanLifecycle@PAGE");
}
public void testComponentAddress() throws IOException
@@ -413,4 +412,4 @@
assertEquals("Stored string.", stringValue, outStringValue);
}
-}
+}
\ No newline at end of file
1.3 +4 -4 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/utils/TestEnum.java
Index: TestEnum.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/utils/TestEnum.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestEnum.java 19 Nov 2004 16:44:11 -0000 1.2
+++ TestEnum.java 19 Dec 2004 15:36:13 -0000 1.3
@@ -20,7 +20,7 @@
import java.io.ObjectOutputStream;
import org.apache.tapestry.junit.TapestryTestCase;
-import org.apache.tapestry.spec.AssetType;
+import org.apache.tapestry.spec.BeanLifecycle;
/**
* Tests the ability of an {@link org.apache.tapestry.util.Enum}to be serialized and deserialized
@@ -35,7 +35,7 @@
public void testSerialization() throws Exception
{
- AssetType start = AssetType.EXTERNAL;
+ BeanLifecycle start = BeanLifecycle.RENDER;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
@@ -47,7 +47,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
- AssetType result = (AssetType) ois.readObject();
+ BeanLifecycle result = (BeanLifecycle) ois.readObject();
assertEquals(start, result);
assertSame(start, result);
@@ -55,7 +55,7 @@
public void testToString()
{
- assertEquals("AssetType[EXTERNAL]", AssetType.EXTERNAL.toString());
+ assertEquals("BeanLifecycle[RENDER]", BeanLifecycle.RENDER.toString());
}
}
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestEngineServiceObjectProvider.java
Index: TestEngineServiceObjectProvider.java
===================================================================
package org.apache.tapestry.services.impl;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.tapestry.engine.IEngineService;
import org.apache.tapestry.services.ServiceMap;
import org.easymock.MockControl;
/**
* Tests for {@link org.apache.tapestry.services.impl.EngineServiceObjectProvider}.
*
* @author Howard M. Lewis Ship
*/
public class TestEngineServiceObjectProvider extends HiveMindTestCase
{
public void testProvideObject()
{
MockControl mapControl = newControl(ServiceMap.class);
ServiceMap map = (ServiceMap) mapControl.getMock();
IEngineService service = (IEngineService) newMock(IEngineService.class);
map.getService("page");
mapControl.setReturnValue(service);
replayControls();
EngineServiceObjectProvider p = new EngineServiceObjectProvider();
p.setServiceMap(map);
assertSame(service, p.provideObject(null, null, "page", null));
verifyControls();
}
}
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestBaseTagWriter.java
Index: TestBaseTagWriter.java
===================================================================
package org.apache.tapestry.services.impl;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.INamespace;
import org.apache.tapestry.IPage;
import org.apache.tapestry.IRequestCycle;
import org.easymock.MockControl;
/**
* Tests for {@link org.apache.tapestry.services.impl.BaseTagWriter}.
*
* @author Howard M. Lewis Ship
* @since 3.1
*/
public class TestBaseTagWriter extends HiveMindTestCase
{
private IMarkupWriter newWriter(String url)
{
IMarkupWriter writer = (IMarkupWriter) newMock(IMarkupWriter.class);
writer.beginEmpty("base");
writer.attribute("href", url);
writer.println();
return writer;
}
private INamespace newNamespace(String id)
{
MockControl control = newControl(INamespace.class);
INamespace ns = (INamespace) control.getMock();
ns.getId();
control.setReturnValue(id);
return ns;
}
private IPage newPage(String pageName)
{
return newPage(newNamespace(null), pageName);
}
private IPage newPage(INamespace ns, String pageName)
{
MockControl control = newControl(IPage.class);
IPage page = (IPage) control.getMock();
page.getNamespace();
control.setReturnValue(ns);
if (pageName != null)
{
page.getPageName();
control.setReturnValue(pageName);
}
return page;
}
private IRequestCycle newRequestCycle(IPage page, String url)
{
MockControl control = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) control.getMock();
cycle.getPage();
control.setReturnValue(page);
cycle.getAbsoluteURL(url);
control.setReturnValue("http://foo.com/context" + url);
return cycle;
}
private void run(IMarkupWriter writer, IRequestCycle cycle)
{
replayControls();
new BaseTagWriter().render(writer, cycle);
verifyControls();
}
public void testNotApplicationNamespace()
{
INamespace ns = newNamespace("library");
IPage page = newPage(ns, null);
IRequestCycle cycle = newRequestCycle(page, "/");
IMarkupWriter writer = newWriter("http://foo.com/context/");
run(writer, cycle);
}
public void testInRoot()
{
IPage page = newPage("Home");
IRequestCycle cycle = newRequestCycle(page, "/");
IMarkupWriter writer = newWriter("http://foo.com/context/");
run(writer, cycle);
}
public void testInSubFolder()
{
IPage page = newPage("admin/AdminMenu");
IRequestCycle cycle = newRequestCycle(page, "/admin/");
IMarkupWriter writer = newWriter("http://foo.com/context/admin/");
run(writer, cycle);
}
}
1.1 jakarta-tapestry/framework/src/test/org/apache/tapestry/asset/TestAssetSource.java
Index: TestAssetSource.java
===================================================================
package org.apache.tapestry.asset;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.apache.hivemind.Location;
import org.apache.hivemind.Resource;
import org.apache.hivemind.test.HiveMindTestCase;
import org.apache.tapestry.IAsset;
import org.easymock.MockControl;
/**
* Tests for {@link org.apache.tapestry.asset.AssetSourceImpl}.
*
* @author Howard M. Lewis Ship
* @since 3.1
*/
public class TestAssetSource extends HiveMindTestCase
{
private AssetFactoryContribution newContribution(String prefix, AssetFactory factory)
{
AssetFactoryContribution c = new AssetFactoryContribution();
c.setPrefix(prefix);
c.setFactory(factory);
return c;
}
private List newContributions(String prefix, AssetFactory factory)
{
return Collections.singletonList(newContribution(prefix, factory));
}
private Resource newResource()
{
return (Resource) newMock(Resource.class);
}
private AssetFactory newAssetFactory(Resource base, String path, Locale locale,
Location location, IAsset asset)
{
MockControl control = newControl(AssetFactory.class);
AssetFactory f = (AssetFactory) control.getMock();
f.createAsset(base, path, locale, location);
control.setReturnValue(asset);
return f;
}
private IAsset newAsset()
{
return (IAsset) newMock(IAsset.class);
}
public void testKnownPrefix()
{
Location l = fabricateLocation(17);
Resource r = newResource();
IAsset asset = newAsset();
List contributions = newContributions("known", newAssetFactory(
r,
"path/to/asset",
Locale.ENGLISH,
l,
asset));
replayControls();
AssetSourceImpl as = new AssetSourceImpl();
as.setContributions(contributions);
as.initializeService();
IAsset actual = as.findAsset(r, "known:path/to/asset", Locale.ENGLISH, l);
assertSame(actual, asset);
verifyControls();
}
public void testUnkownPrefix()
{
Location l = fabricateLocation(17);
Resource r = newResource();
IAsset asset = newAsset();
AssetFactory f = newAssetFactory(r, "unknown:path/to/asset", Locale.ENGLISH, l, asset);
replayControls();
AssetSourceImpl as = new AssetSourceImpl();
as.setDefaultAssetFactory(f);
IAsset actual = as.findAsset(r, "unknown:path/to/asset", Locale.ENGLISH, l);
assertSame(actual, asset);
verifyControls();
}
public void testNoPrefix()
{
Location l = fabricateLocation(17);
Resource r = newResource();
IAsset asset = newAsset();
AssetFactory f = newAssetFactory(r, "path/to/asset", Locale.ENGLISH, l, asset);
replayControls();
AssetSourceImpl as = new AssetSourceImpl();
as.setLookupAssetFactory(f);
IAsset actual = as.findAsset(r, "path/to/asset", Locale.ENGLISH, l);
assertSame(actual, asset);
verifyControls();
}
}
1.3 +22 -22 jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/form/TestListEditMap.java
Index: TestListEditMap.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/form/TestListEditMap.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestListEditMap.java 19 Nov 2004 16:44:11 -0000 1.2
+++ TestListEditMap.java 19 Dec 2004 15:36:13 -0000 1.3
@@ -16,7 +16,7 @@
import org.apache.tapestry.form.ListEditMap;
import org.apache.tapestry.junit.TapestryTestCase;
-import org.apache.tapestry.spec.AssetType;
+import org.apache.tapestry.spec.BeanLifecycle;
/**
* Suite of tests for {@link org.apache.tapestry.form.ListEditMap}.
@@ -32,9 +32,9 @@
{
ListEditMap m = new ListEditMap();
- m.add("external", AssetType.EXTERNAL);
- m.add("private", AssetType.PRIVATE);
- m.add("context", AssetType.CONTEXT);
+ m.add("request", BeanLifecycle.REQUEST);
+ m.add("page", BeanLifecycle.PAGE);
+ m.add("render", BeanLifecycle.RENDER);
return m;
}
@@ -43,14 +43,14 @@
{
ListEditMap m = create();
- assertEquals("context", m.getKey());
+ assertEquals("render", m.getKey());
checkList("keys", new Object[]
- { "external", "private", "context" }, m.getKeys());
+ { "request", "page", "render" }, m.getKeys());
checkList("all values", new Object[]
- { AssetType.EXTERNAL, AssetType.PRIVATE, AssetType.CONTEXT }, m.getAllValues());
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getAllValues());
checkList("all values", new Object[]
- { AssetType.EXTERNAL, AssetType.PRIVATE, AssetType.CONTEXT }, m.getValues());
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getValues());
assertNull(m.getDeletedKeys());
}
@@ -59,10 +59,10 @@
{
ListEditMap m = create();
- m.setKey("private");
+ m.setKey("page");
- assertEquals("private", m.getKey());
- assertSame(AssetType.PRIVATE, m.getValue());
+ assertEquals("page", m.getKey());
+ assertSame(BeanLifecycle.PAGE, m.getValue());
}
public void testGetUnknown()
@@ -78,7 +78,7 @@
{
ListEditMap m = create();
- m.setKey("private");
+ m.setKey("page");
assertEquals(false, m.isDeleted());
@@ -87,13 +87,13 @@
assertEquals(true, m.isDeleted());
checkList("all values", new Object[]
- { AssetType.EXTERNAL, AssetType.PRIVATE, AssetType.CONTEXT }, m.getAllValues());
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE, BeanLifecycle.RENDER }, m.getAllValues());
checkList("undeleted values", new Object[]
- { AssetType.EXTERNAL, AssetType.CONTEXT }, m.getValues());
+ { BeanLifecycle.REQUEST, BeanLifecycle.RENDER }, m.getValues());
checkList("deleted keys", new Object[]
- { "private" }, m.getDeletedKeys());
+ { "page" }, m.getDeletedKeys());
}
public void testMarkAlreadyDeleted()
@@ -101,7 +101,7 @@
ListEditMap m = create();
- m.setKey("private");
+ m.setKey("page");
assertEquals(false, m.isDeleted());
@@ -114,32 +114,32 @@
{
ListEditMap m = create();
- m.setKey("private");
+ m.setKey("page");
m.setDeleted(true);
- m.setKey("context");
+ m.setKey("render");
assertEquals(false, m.isDeleted());
m.setDeleted(true);
assertEquals(true, m.isDeleted());
checkList("undeleted values", new Object[]
- { AssetType.EXTERNAL }, m.getValues());
+ { BeanLifecycle.REQUEST }, m.getValues());
}
public void testDeleteUndelete()
{
ListEditMap m = create();
- m.setKey("private");
+ m.setKey("page");
m.setDeleted(true);
m.setDeleted(false);
- m.setKey("context");
+ m.setKey("render");
m.setDeleted(true);
checkList("undeleted values", new Object[]
- { AssetType.EXTERNAL, AssetType.PRIVATE }, m.getValues());
+ { BeanLifecycle.REQUEST, BeanLifecycle.PAGE }, m.getValues());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org