Skip to content

Commit

Permalink
Bypass EasyMock JDK21 incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Oct 11, 2023
1 parent 00db844 commit 9dfeae3
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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;

import java.io.File;
import java.net.URI;

public class DummyFile extends File {
public DummyFile(URI uri) {
super(uri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@
*/
package org.apache.tiles.autotag.freemarker;

import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;

import java.io.File;

import org.apache.tiles.autotag.DummyFile;
import org.apache.tiles.autotag.generate.TemplateGenerator;
import org.apache.tiles.autotag.generate.TemplateGeneratorBuilder;
import org.apache.velocity.app.VelocityEngine;
import org.junit.Test;

import java.io.File;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertSame;

/**
* Tests FMTemplateGeneratorFactory.
*/
Expand All @@ -38,7 +43,7 @@ public class FMTemplateGeneratorFactoryTest {
*/
@Test
public void testCreateTemplateGenerator() {
File classesOutputDirectory = createMock(File.class);
File classesOutputDirectory = createMock(DummyFile.class);
VelocityEngine velocityEngine = createMock(VelocityEngine.class);
TemplateGeneratorBuilder builder = createMock(TemplateGeneratorBuilder.class);
TemplateGenerator generator = createMock(TemplateGenerator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@
*/
package org.apache.tiles.autotag.jsp;

import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;

import java.io.File;

import org.apache.tiles.autotag.DummyFile;
import org.apache.tiles.autotag.generate.TemplateGenerator;
import org.apache.tiles.autotag.generate.TemplateGeneratorBuilder;
import org.apache.velocity.app.VelocityEngine;
import org.junit.Test;

import java.io.File;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertSame;

/**
* Tests JspTemplateGeneratorFactory.
*/
Expand All @@ -38,8 +43,8 @@ public class JspTemplateGeneratorFactoryTest {
*/
@Test
public void testCreateTemplateGenerator() {
File classesOutputDirectory = createMock(File.class);
File resourcesOutputDirectory = createMock(File.class);
File classesOutputDirectory = createMock(DummyFile.class);
File resourcesOutputDirectory = createMock(DummyFile.class);
VelocityEngine velocityEngine = createMock(VelocityEngine.class);
TemplateGeneratorBuilder builder = createMock(TemplateGeneratorBuilder.class);
TemplateGenerator generator = createMock(TemplateGenerator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class AbstractModelBodyTest {
*/
@Test
public void testEvaluate() throws IOException {
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock();

modelBody.evaluate(writer);
Expand Down Expand Up @@ -78,7 +78,7 @@ public void testEvaluateAsString() throws IOException {
*/
@Test(expected = IOException.class)
public void testEvaluateAsStringException() throws IOException {
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock();

modelBody.evaluate(isA(StringWriter.class));
Expand All @@ -99,7 +99,7 @@ public void testEvaluateAsStringException() throws IOException {
*/
@Test
public void testEvaluateWithoutWriting() throws IOException {
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock();

modelBody.evaluate(isA(NullWriter.class));
Expand All @@ -116,7 +116,7 @@ public void testEvaluateWithoutWriting() throws IOException {
*/
@Test(expected = IOException.class)
public void testEvaluateWithoutWritingException() throws IOException {
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
AbstractModelBody modelBody = createMockBuilder(AbstractModelBody.class).withConstructor(writer).createMock();

modelBody.evaluate(isA(NullWriter.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@
*/
package org.apache.tiles.autotag.velocity;

import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;

import java.io.File;

import org.apache.tiles.autotag.DummyFile;
import org.apache.tiles.autotag.generate.TemplateGenerator;
import org.apache.tiles.autotag.generate.TemplateGeneratorBuilder;
import org.apache.velocity.app.VelocityEngine;
import org.junit.Test;

import java.io.File;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertSame;

/**
* Tests JspTemplateGeneratorFactory.
*/
Expand All @@ -38,8 +43,8 @@ public class VelocityTemplateGeneratorFactoryTest {
*/
@Test
public void testCreateTemplateGenerator() {
File classesOutputDirectory = createMock(File.class);
File resourcesOutputDirectory = createMock(File.class);
File classesOutputDirectory = createMock(DummyFile.class);
File resourcesOutputDirectory = createMock(DummyFile.class);
VelocityEngine velocityEngine = createMock(VelocityEngine.class);
TemplateGeneratorBuilder builder = createMock(TemplateGeneratorBuilder.class);
TemplateGenerator generator = createMock(TemplateGenerator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.tiles.api.TilesContainer;
import org.apache.tiles.api.access.TilesAccess;
import org.apache.tiles.autotag.core.runtime.ModelBody;
import org.apache.tiles.autotag.core.runtime.util.NullWriter;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.Request;
import org.junit.Before;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void testExecute() throws IOException {
Attribute attribute = createMock(Attribute.class);
AttributeContext attributeContext = createMock(AttributeContext.class);
Request request = createMock(Request.class);
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
Map<String, Object> requestScope = new HashMap<>();
Deque<Object> composeStack = new ArrayDeque<>();
requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
Expand Down Expand Up @@ -115,7 +116,7 @@ public void testExecuteIgnore() throws IOException {
TilesContainer container = createMock(TilesContainer.class);
AttributeContext attributeContext = createMock(AttributeContext.class);
Request request = createMock(Request.class);
Writer writer = createMock(Writer.class);
Writer writer = createMock(NullWriter.class);
Map<String, Object> requestScope = new HashMap<>();
Deque<Object> composeStack = new ArrayDeque<>();
requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
Expand Down

0 comments on commit 9dfeae3

Please sign in to comment.