This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5233-tiles in repository https://gitbox.apache.org/repos/asf/struts.git
commit 567828244b09f1b7d0b3e1a89633ff81d9ccddc3 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Sun Oct 2 14:53:17 2022 +0200 WW-5233 Copies Tiles Autotag related tests --- .../tiles/autotag/model/TemplateClassTest.java | 153 +++++++++++++++++++ .../tiles/autotag/model/TemplateMethodTest.java | 132 +++++++++++++++++ .../tiles/autotag/model/TemplateParameterTest.java | 88 +++++++++++ .../tiles/autotag/model/TemplateSuiteTest.java | 112 ++++++++++++++ .../autotag/runtime/AbstractModelBodyTest.java | 164 +++++++++++++++++++++ .../tiles/autotag/runtime/util/NullWriterTest.java | 71 +++++++++ 6 files changed, 720 insertions(+) diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateClassTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateClassTest.java new file mode 100644 index 000000000..1b875c37d --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateClassTest.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.model; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +public class TemplateClassTest { + + /** + * Test method for {@link TemplateClass#TemplateClass(String)}. + */ + @Test + public void testTemplateConstructor1() { + TemplateClass templateClass = new TemplateClass("name"); + assertEquals("name", templateClass.getName()); + assertNull(templateClass.getTagName()); + assertNull(templateClass.getTagClassPrefix()); + assertNull(templateClass.getExecuteMethod()); + Collection<TemplateParameter> params = templateClass.getParameters(); + assertTrue(params.isEmpty()); + } + + /** + * Test method for {@link TemplateClass#TemplateClass(String, String, String, TemplateMethod)}. + */ + @Test + public void testTemplateConstructor2() { + TemplateMethod method = createMock(TemplateMethod.class); + + replay(method); + TemplateClass templateClass = new TemplateClass("name", "tagName", "tagClassPrefix", method); + assertEquals("name", templateClass.getName()); + assertEquals("tagName", templateClass.getTagName()); + assertEquals("tagClassPrefix", templateClass.getTagClassPrefix()); + assertEquals(method, templateClass.getExecuteMethod()); + verify(method); + } + + /** + * Test method for {@link TemplateClass#getSimpleName()}. + */ + @Test + public void testGetSimpleName() { + TemplateClass templateClass = new TemplateClass("name"); + assertEquals("name", templateClass.getSimpleName()); + templateClass = new TemplateClass("org.whatever.Hello"); + assertEquals("Hello", templateClass.getSimpleName()); + } + + /** + * Test method for {@link TemplateClass#setDocumentation(String)}. + */ + @Test + public void testSetDocumentation() { + TemplateClass templateClass = new TemplateClass("name"); + templateClass.setDocumentation("docs"); + assertEquals("docs", templateClass.getDocumentation()); + } + + /** + * Test method for {@link TemplateClass#getParameters()}. + */ + @Test + public void testGetParameters() { + TemplateParameter param1 = createMock(TemplateParameter.class); + TemplateParameter param2 = createMock(TemplateParameter.class); + TemplateParameter param3 = createMock(TemplateParameter.class); + TemplateParameter param4 = createMock(TemplateParameter.class); + TemplateMethod method = createMock(TemplateMethod.class); + List<TemplateParameter> params = new ArrayList<>(); + + expect(method.getParameters()).andReturn(params); + expect(param1.isRequest()).andReturn(true); + expect(param2.isRequest()).andReturn(false); + expect(param2.isBody()).andReturn(true); + expect(param3.isRequest()).andReturn(false); + expect(param3.isBody()).andReturn(false); + expect(param4.isRequest()).andReturn(false); + expect(param4.isBody()).andReturn(false); + expect(param3.getName()).andReturn("param1"); + expect(param4.getName()).andReturn("param2"); + + replay(param1, param2, param3, param4, method); + params.add(param1); + params.add(param2); + params.add(param3); + params.add(param4); + + TemplateClass templateClass = new TemplateClass("name", "tagName", "tagClassPrefix", method); + Collection<TemplateParameter> returnedParams = templateClass.getParameters(); + Iterator<TemplateParameter> paramIt = returnedParams.iterator(); + assertSame(param3, paramIt.next()); + assertSame(param4, paramIt.next()); + assertFalse(paramIt.hasNext()); + verify(param1, param2, param3, param4, method); + } + + /** + * Test method for {@link TemplateClass#hasBody()}. + */ + @Test + public void testHasBody() { + TemplateMethod method = createMock(TemplateMethod.class); + expect(method.hasBody()).andReturn(true); + + replay(method); + TemplateClass templateClass = new TemplateClass("name", "tagName", "tagClassPrefix", method); + assertTrue(templateClass.hasBody()); + verify(method); + } + + /** + * Test method for {@link TemplateClass#toString()}. + */ + @Test + public void testToString() { + TemplateMethod method = new TemplateMethod("method", new ArrayList<>()); + TemplateClass templateClass = new TemplateClass("name", "tagName", "tagClassPrefix", method); + assertEquals("TemplateClass [name=name, tagName=tagName, tagClassPrefix=tagClassPrefix, " + "documentation=null, executeMethod=TemplateMethod " + "[name=method, documentation=null, parameters={}]]", templateClass.toString()); + } + +} diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateMethodTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateMethodTest.java new file mode 100644 index 000000000..e6ad8b181 --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateMethodTest.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.model; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +/** + * Tests {@link TemplateMethod}. + */ +public class TemplateMethodTest { + + /** + * Tests {@link TemplateMethod#TemplateMethod(String, Iterable)}. + */ + @Test + public void testTemplateMethod() { + TemplateParameter param1 = createMock(TemplateParameter.class); + TemplateParameter param2 = createMock(TemplateParameter.class); + + expect(param1.getName()).andReturn("param1"); + expect(param2.getName()).andReturn("param2"); + + replay(param1, param2); + List<TemplateParameter> parameters = new ArrayList<>(); + parameters.add(param1); + parameters.add(param2); + + TemplateMethod method = new TemplateMethod("method", parameters); + assertEquals("method", method.getName()); + Iterator<TemplateParameter> params = method.getParameters().iterator(); + assertSame(param1, params.next()); + assertSame(param2, params.next()); + assertFalse(params.hasNext()); + assertSame(param1, method.getParameterByName("param1")); + assertSame(param2, method.getParameterByName("param2")); + verify(param1, param2); + } + + /** + * Tests {@link TemplateMethod#setDocumentation(String)}. + */ + @Test + public void testSetDocumentation() { + TemplateMethod method = new TemplateMethod("method", new ArrayList<>()); + method.setDocumentation("docs"); + assertEquals("docs", method.getDocumentation()); + } + + /** + * Tests {@link TemplateMethod#hasBody()}. + */ + @Test + public void testHasBody() { + TemplateParameter param1 = createMock(TemplateParameter.class); + TemplateParameter param2 = createMock(TemplateParameter.class); + + expect(param1.getName()).andReturn("param1"); + expect(param2.getName()).andReturn("param2"); + expect(param1.isBody()).andReturn(true); + + replay(param1, param2); + List<TemplateParameter> parameters = new ArrayList<>(); + parameters.add(param1); + parameters.add(param2); + + TemplateMethod method = new TemplateMethod("method", parameters); + assertTrue(method.hasBody()); + verify(param1, param2); + } + + /** + * Tests {@link TemplateMethod#hasBody()}. + */ + @Test + public void testHasBody2() { + TemplateParameter param1 = createMock(TemplateParameter.class); + TemplateParameter param2 = createMock(TemplateParameter.class); + + expect(param1.getName()).andReturn("param1"); + expect(param2.getName()).andReturn("param2"); + expect(param1.isBody()).andReturn(false); + expect(param2.isBody()).andReturn(false); + + replay(param1, param2); + List<TemplateParameter> parameters = new ArrayList<>(); + parameters.add(param1); + parameters.add(param2); + + TemplateMethod method = new TemplateMethod("method", parameters); + assertFalse(method.hasBody()); + verify(param1, param2); + } + + /** + * Tests {@link TemplateMethod#toString()}. + */ + @Test + public void testToString() { + TemplateMethod method = new TemplateMethod("method", new ArrayList<>()); + assertEquals("TemplateMethod [name=method, documentation=null, parameters={}]", method.toString()); + } + +} diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateParameterTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateParameterTest.java new file mode 100644 index 000000000..efa486950 --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateParameterTest.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.model; + +import org.apache.tiles.autotag.core.runtime.ModelBody; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Tests {@link TemplateParameter}. + */ +public class TemplateParameterTest { + + @Test + public void testTemplateParameter() { + TemplateParameter parameter = new TemplateParameter("name", "exportedName", "type", "defaultValue", true, false); + assertEquals("name", parameter.getName()); + assertEquals("exportedName", parameter.getExportedName()); + assertEquals("type", parameter.getType()); + assertEquals("defaultValue", parameter.getDefaultValue()); + assertTrue(parameter.isRequired()); + assertEquals("ExportedName", parameter.getGetterSetterSuffix()); + assertFalse(parameter.isBody()); + assertFalse(parameter.isRequest()); + + parameter = new TemplateParameter("name", "exportedName", "my.Request", "defaultValue", false, true); + assertEquals("name", parameter.getName()); + assertEquals("exportedName", parameter.getExportedName()); + assertEquals("my.Request", parameter.getType()); + assertEquals("defaultValue", parameter.getDefaultValue()); + assertFalse(parameter.isRequired()); + assertEquals("ExportedName", parameter.getGetterSetterSuffix()); + assertFalse(parameter.isBody()); + assertTrue(parameter.isRequest()); + + parameter = new TemplateParameter("name", "exportedName", ModelBody.class.getName(), "defaultValue", false, false); + assertEquals("name", parameter.getName()); + assertEquals("exportedName", parameter.getExportedName()); + assertEquals(ModelBody.class.getName(), parameter.getType()); + assertEquals("defaultValue", parameter.getDefaultValue()); + assertFalse(parameter.isRequired()); + assertEquals("ExportedName", parameter.getGetterSetterSuffix()); + assertTrue(parameter.isBody()); + assertFalse(parameter.isRequest()); + } + + /** + * Tests {@link TemplateParameter#setDocumentation(String)}. + */ + @Test + public void testSetDocumentation() { + TemplateParameter parameter = new TemplateParameter("name", "exportedName", "type", "defaultValue", true, false); + parameter.setDocumentation("docs"); + assertEquals("docs", parameter.getDocumentation()); + } + + /** + * Tests {@link TemplateParameter#toString()}. + */ + @Test + public void testToString() { + TemplateParameter parameter = new TemplateParameter("name", "exportedName", "type", "defaultValue", true, false); + assertEquals( + "TemplateParameter [name=name, exportedName=exportedName, " + + "documentation=null, type=type, defaultValue=defaultValue, required=true, request=false]", + parameter.toString()); + } + +} diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateSuiteTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateSuiteTest.java new file mode 100644 index 000000000..cdb5c5216 --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/model/TemplateSuiteTest.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.model; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +/** + * Tests {@link TemplateSuite}. + */ +public class TemplateSuiteTest { + + /** + * Test method for {@link TemplateSuite#TemplateSuite(String, String)}. + */ + @Test + public void testTemplateSuiteConstructor1() { + TemplateSuite suite = new TemplateSuite("name", "docs"); + assertEquals("name", suite.getName()); + assertEquals("docs", suite.getDocumentation()); + assertTrue(suite.getTemplateClasses().isEmpty()); + } + + /** + * Test method for {@link TemplateSuite#TemplateSuite(String, String, Iterable)}. + */ + @Test + public void testTemplateSuiteConstructor2() { + TemplateClass class1 = createMock(TemplateClass.class); + TemplateClass class2 = createMock(TemplateClass.class); + expect(class1.getName()).andReturn("class1"); + expect(class2.getName()).andReturn("class2"); + + replay(class1, class2); + List<TemplateClass> classes = new ArrayList<>(); + classes.add(class1); + classes.add(class2); + TemplateSuite suite = new TemplateSuite("name", "docs", classes); + assertEquals("name", suite.getName()); + assertEquals("docs", suite.getDocumentation()); + Iterator<TemplateClass> clazzes = suite.getTemplateClasses().iterator(); + assertSame(class1, clazzes.next()); + assertSame(class2, clazzes.next()); + assertFalse(clazzes.hasNext()); + assertSame(class1, suite.getTemplateClassByName("class1")); + assertSame(class2, suite.getTemplateClassByName("class2")); + verify(class1, class2); + } + + /** + * Test method for {@link TemplateSuite#addTemplateClass(TemplateClass)}. + */ + @Test + public void testAddTemplateClass() { + TemplateClass class1 = createMock(TemplateClass.class); + TemplateClass class2 = createMock(TemplateClass.class); + expect(class1.getName()).andReturn("class1"); + expect(class2.getName()).andReturn("class2"); + + replay(class1, class2); + TemplateSuite suite = new TemplateSuite("name", "docs"); + assertEquals("name", suite.getName()); + assertEquals("docs", suite.getDocumentation()); + assertTrue(suite.getTemplateClasses().isEmpty()); + suite.addTemplateClass(class1); + suite.addTemplateClass(class2); + Iterator<TemplateClass> clazzes = suite.getTemplateClasses().iterator(); + assertSame(class1, clazzes.next()); + assertSame(class2, clazzes.next()); + assertFalse(clazzes.hasNext()); + assertSame(class1, suite.getTemplateClassByName("class1")); + assertSame(class2, suite.getTemplateClassByName("class2")); + verify(class1, class2); + } + + /** + * Test method for {@link TemplateSuite#toString()}. + */ + @Test + public void testToString() { + TemplateSuite suite = new TemplateSuite("name", "docs"); + assertEquals("TemplateSuite [name=name, documentation=docs, templateClasses={}]", suite.toString()); + } +} diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/AbstractModelBodyTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/AbstractModelBodyTest.java new file mode 100644 index 000000000..08e4d9011 --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/AbstractModelBodyTest.java @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.runtime; + +import org.apache.tiles.autotag.core.runtime.AbstractModelBody; +import org.apache.tiles.autotag.core.runtime.util.NullWriter; +import org.junit.Test; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createMockBuilder; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * Tests {@link AbstractModelBody}. + * + * @version $Rev$ $Date$ + */ +public class AbstractModelBodyTest { + + /** + * Test method for {@link AbstractModelBody#evaluate()}. + * + * @throws IOException If something goes wrong. + */ + @Test + public void testEvaluate() throws IOException { + Writer writer = createMock(Writer.class); + AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock(); + + modelBody.evaluate(writer); + + replay(writer, modelBody); + modelBody.evaluate(); + verify(writer, modelBody); + } + + /** + * Test method for {@link AbstractModelBody#evaluateAsString()}. + * + * @throws IOException If something goes wrong. + */ + @Test + public void testEvaluateAsString() throws IOException { + AbstractModelBody modelBody = new MockModelBody(null, "return me"); + assertEquals("return me", modelBody.evaluateAsString()); + + modelBody = new MockModelBody(null, "\n \n"); + assertNull(modelBody.evaluateAsString()); + } + + /** + * Test method for {@link AbstractModelBody#evaluateAsString()}. + * + * @throws IOException If something goes wrong. + */ + @Test(expected = IOException.class) + public void testEvaluateAsStringException() throws IOException { + Writer writer = createMock(Writer.class); + AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock(); + + modelBody.evaluate(isA(StringWriter.class)); + expectLastCall().andThrow(new IOException()); + + replay(writer, modelBody); + try { + modelBody.evaluateAsString(); + } finally { + verify(writer, modelBody); + } + } + + /** + * Test method for {@link AbstractModelBody#evaluateWithoutWriting()}. + * + * @throws IOException If something goes wrong. + */ + @Test + public void testEvaluateWithoutWriting() throws IOException { + Writer writer = createMock(Writer.class); + AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock(); + + modelBody.evaluate(isA(NullWriter.class)); + + replay(writer, modelBody); + modelBody.evaluateWithoutWriting(); + verify(writer, modelBody); + } + + /** + * Test method for {@link AbstractModelBody#evaluateWithoutWriting()}. + * + * @throws IOException If something goes wrong. + */ + @Test(expected = IOException.class) + public void testEvaluateWithoutWritingException() throws IOException { + Writer writer = createMock(Writer.class); + AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock(); + + modelBody.evaluate(isA(NullWriter.class)); + expectLastCall().andThrow(new IOException()); + + replay(writer, modelBody); + try { + modelBody.evaluateWithoutWriting(); + } finally { + verify(writer, modelBody); + } + } + + /** + * A mock model body. + * + * @version $Rev$ $Date$ + */ + public static class MockModelBody extends AbstractModelBody { + + /** + * The result to return. + */ + private final String toReturn; + + /** + * Constructor. + * + * @param defaultWriter The default writer. + * @param toReturn The result to return. + */ + public MockModelBody(Writer defaultWriter, String toReturn) { + super(defaultWriter); + this.toReturn = toReturn; + } + + @Override + public void evaluate(Writer writer) throws IOException { + writer.write(toReturn); + } + + } +} diff --git a/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/util/NullWriterTest.java b/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/util/NullWriterTest.java new file mode 100644 index 000000000..00f6b452c --- /dev/null +++ b/plugins/tiles/src/test/java/org/apache/tiles/autotag/runtime/util/NullWriterTest.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.tiles.autotag.runtime.util; + +import org.apache.tiles.autotag.core.runtime.util.NullWriter; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests {@link NullWriter}. + */ +public class NullWriterTest { + + /** + * A dummy size. + */ + private static final int DUMMY_SIZE = 15; + /** + * The object to test. + */ + private NullWriter writer; + + /** + * Sets up the test. + */ + @Before + public void setUp() { + writer = new NullWriter(); + } + + /** + * Test method for {@link NullWriter#write(char[], int, int)}. + */ + @Test + public void testWriteCharArrayIntInt() { + writer.write("Hello there".toCharArray(), 0, DUMMY_SIZE); + } + + /** + * Test method for {@link NullWriter#flush()}. + */ + @Test + public void testFlush() { + writer.flush(); + } + + /** + * Test method for {@link NullWriter#close()}. + */ + @Test + public void testClose() { + writer.close(); + } + +}