You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2019/06/26 12:48:35 UTC
svn commit: r1862131 - in /turbine/fulcrum/trunk/parser: ./
src/java/org/apache/fulcrum/parser/ src/test/
src/test/org/apache/fulcrum/parser/ src/test/org/apache/fulcrum/parser/pool/
Author: gk
Date: Wed Jun 26 12:48:35 2019
New Revision: 1862131
URL: http://svn.apache.org/viewvc?rev=1862131&view=rev
Log:
- reitroduce fallback optional Fulcrum Pool (without Recycable feature)
- fix dispose bug of parser resources (using now new dispose from ValueParser instead Fulcrum Pool Recycable dispose check)
- add + fix tests
- update commons pool2
Added:
turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml (with props)
turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml (with props)
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java (with props)
Modified:
turbine/fulcrum/trunk/parser/pom.xml
turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java
turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java
turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ValueParser.java
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/BaseValueParserPoolTest.java
turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/ParameterParserPoolTest.java
Modified: turbine/fulcrum/trunk/parser/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/pom.xml?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/pom.xml (original)
+++ turbine/fulcrum/trunk/parser/pom.xml Wed Jun 26 12:48:35 2019
@@ -109,8 +109,15 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
- <version>2.6.1</version>
+ <version>2.6.2</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-pool</artifactId>
+ <version>1.0.5</version>
+ <optional>true</optional>
+ </dependency>
<!-- testing dependencies -->
<dependency>
Modified: turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java (original)
+++ turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java Wed Jun 26 12:48:35 2019
@@ -44,10 +44,12 @@ import org.apache.fulcrum.parser.pool.Co
import org.apache.fulcrum.parser.pool.CookieParserPool;
import org.apache.fulcrum.parser.pool.DefaultParameterParserFactory;
import org.apache.fulcrum.parser.pool.DefaultParameterParserPool;
+import org.apache.fulcrum.pool.PoolException;
+import org.apache.fulcrum.pool.PoolService;
/**
- * The DefaultParserService provides the efault implementation
+ * The DefaultParserService provides the default implementation
* of a {@link ParserService}.
*
* @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
@@ -58,6 +60,7 @@ public class DefaultParserService
implements ParserService,
Configurable, Serviceable
{
+
/** The folding from the configuration */
private URLCaseFolding folding = URLCaseFolding.NONE;
@@ -68,6 +71,18 @@ public class DefaultParserService
* The parameter encoding to use when parsing parameter strings
*/
private String parameterEncoding = PARAMETER_ENCODING_DEFAULT;
+
+ /**
+ * reintroduced fulcrum, may be used in the case, that
+ * commons pool2 is not configured exactly as needed properly as fast fall back.
+ */
+ private boolean useFulcrumPool = FULCRUM_POOL_DEFAULT;
+
+
+ /**
+ * The Fulcrum pool service component to use (optional), by default it is deactivated and commons pool is used.
+ */
+ private PoolService fulcrumPoolService = null;
/**
* Use commons pool to manage value parsers
@@ -84,24 +99,9 @@ public class DefaultParserService
*/
private CookieParserPool cookieParserPool;
+
public DefaultParserService()
{
- // Define the default configuration
- GenericObjectPoolConfig config = new GenericObjectPoolConfig();
- config.setMaxIdle(DEFAULT_MAX_IDLE);
- config.setMaxTotal(DEFAULT_POOL_CAPACITY);
-
- // init the pool
- valueParserPool
- = new BaseValueParserPool(new BaseValueParserFactory(), config);
-
- // init the pool
- parameterParserPool
- = new DefaultParameterParserPool(new DefaultParameterParserFactory(), config);
-
- // init the pool
- cookieParserPool
- = new CookieParserPool(new CookieParserFactory(), config);
}
public DefaultParserService(GenericObjectPoolConfig<?> config)
@@ -257,38 +257,78 @@ public class DefaultParserService
try
{
- if ( ppClass.equals(BaseValueParser.class) )
+ if (useFulcrumPool) {
+ try
+ {
+ P parserInstance = (P) fulcrumPoolService.getInstance(ppClass);
+ vp = parserInstance;
+ }
+ catch (PoolException pe)
+ {
+ throw new InstantiationException("Parser class '" + ppClass + "' is illegal. " + pe.getMessage());
+ }
+ } else if ( ppClass.equals(BaseValueParser.class) )
{
- BaseValueParser parserInstance;
+ BaseValueParser parserInstance = null;
try {
- parserInstance = valueParserPool.borrowObject();
+ parserInstance = valueParserPool.borrowObject();
vp = (P) parserInstance;
+ if (vp == null) {
+ throw new InstantiationException("Could not borrow object from pool: " + valueParserPool);
+ }
} catch (Exception e) {
+ try {
+ valueParserPool.invalidateObject(parserInstance);
+ parserInstance = null;
+ } catch (Exception e1) {
+ throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
+ }
}
- }
-
- if ( ppClass.equals(DefaultParameterParser.class) )
+ } else if ( ppClass.equals(DefaultParameterParser.class) )
{
- try {
- DefaultParameterParser parserInstance = parameterParserPool.borrowObject();
- vp = (P) parserInstance;
- } catch (Exception e) {
- }
+ DefaultParameterParser parserInstance = null;
+ try {
+ parserInstance = parameterParserPool.borrowObject();
+ vp = (P) parserInstance;
+ if (vp == null) {
+ throw new InstantiationException("Could not borrow object from pool: " + parameterParserPool);
+ }
+ } catch (Exception e) {
+ try {
+ parameterParserPool.invalidateObject(parserInstance);
+ parserInstance = null;
+ } catch (Exception e1) {
+ throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
+ }
+ }
+ } else if ( ppClass.equals(DefaultCookieParser.class) )
+ {
+ DefaultCookieParser parserInstance = null;
+ try {
+ parserInstance = cookieParserPool.borrowObject();
+ vp = (P) parserInstance;
+ if (vp == null) {
+ throw new InstantiationException("Could not borrow object from pool: " + cookieParserPool);
+ }
+ } catch (Exception e) {
+ try {
+ cookieParserPool.invalidateObject(parserInstance);
+ parserInstance = null;
+ } catch (Exception e1) {
+ throw new InstantiationException("Could not invalidate object " + e1.getMessage() + " after exception: " + e.getMessage());
+ }
+ }
}
- if ( ppClass.equals(DefaultCookieParser.class) )
+ if (vp != null && vp instanceof ParserServiceSupport ) {
+ ((ParserServiceSupport)vp).setParserService(this);
+ } else {
+ throw new InstantiationException("Could not set parser");
+ }
+ if (vp instanceof LogEnabled)
{
- try {
- DefaultCookieParser parserInstance = cookieParserPool.borrowObject();
- vp = (P) parserInstance;
- } catch (Exception e) {
- }
+ ((LogEnabled)vp).enableLogging(getLogger().getChildLogger(ppClass.getSimpleName()));
}
-
-
-
- ((ParserServiceSupport)vp).setParserService(this);
- ((LogEnabled)vp).enableLogging(getLogger().getChildLogger(ppClass.getSimpleName()));
}
catch (ClassCastException x)
{
@@ -302,6 +342,8 @@ public class DefaultParserService
* Clears the parse and puts it back into
* the pool service. This allows for pooling
* and recycling
+ *
+ * As we are not yet using org.apache.fulcrum.pool.Recyclable, we call insteda {@link ValueParser#dispose()}.
*
* @param parser The value parser to use
*/
@@ -309,26 +351,31 @@ public class DefaultParserService
public void putParser(ValueParser parser)
{
parser.clear();
-
- if ( parser.getClass().isInstance(BaseValueParser.class) )
+ parser.dispose();
+
+ if (useFulcrumPool) {
+
+ fulcrumPoolService.putInstance(parser);
+
+ } else if( parser.getClass().equals(BaseValueParser.class) )
{
- valueParserPool.returnObject( (BaseValueParser) parser );
-
- } else if ( parser.getClass().isInstance(DefaultParameterParser.class) ||
+ valueParserPool.returnObject( (BaseValueParser) parser );
+
+ } else if ( parser.getClass().equals(DefaultParameterParser.class) ||
parser instanceof DefaultParameterParser)
{
- parameterParserPool.returnObject( (DefaultParameterParser) parser );
+ parameterParserPool.returnObject( (DefaultParameterParser) parser );
- } else if ( parser.getClass().isInstance(DefaultCookieParser.class) ||
+ } else if ( parser.getClass().equals(DefaultCookieParser.class) ||
parser instanceof DefaultCookieParser)
{
- cookieParserPool.returnObject( (DefaultCookieParser) parser );
+ cookieParserPool.returnObject( (DefaultCookieParser) parser );
} else {
// log
getLogger().warn(parser.getClass() + " could not be put back into any pool exhausting some pool");
// log even borrowed count of each pool?: cookieParserPool.getBorrowedCount())
- }
+ }
}
/**
@@ -363,7 +410,44 @@ public class DefaultParserService
.getValue(PARAMETER_ENCODING_DEFAULT).toLowerCase();
automaticUpload = conf.getChild(AUTOMATIC_KEY).getValueAsBoolean(AUTOMATIC_DEFAULT);
-
+
+ useFulcrumPool = conf.getChild(FULCRUM_POOL_KEY).getValueAsBoolean(FULCRUM_POOL_DEFAULT);
+
+ if (useFulcrumPool) {
+ if (fulcrumPoolService == null)
+ {
+ // only for fulcrum pool, need to call internal service, if role pool service is set
+ throw new ConfigurationException("Fulcrum Pool is activated", new ServiceException(ParserService.ROLE,
+ "Fulcrum enabled Pool Service requires " +
+ PoolService.ROLE + " to be available"));
+ }
+ getLogger().info("Using Fulcrum Pool Service: "+ fulcrumPoolService);
+ } else {
+ // reset not used fulcrum pool
+ fulcrumPoolService = null;
+
+ // Define the default configuration
+ GenericObjectPoolConfig config = new GenericObjectPoolConfig();
+ config.setMaxIdle(DEFAULT_MAX_IDLE);
+ config.setMaxTotal(DEFAULT_POOL_CAPACITY);
+
+ // init the pool
+ valueParserPool
+ = new BaseValueParserPool(new BaseValueParserFactory(), config);
+
+ // init the pool
+ parameterParserPool
+ = new DefaultParameterParserPool(new DefaultParameterParserFactory(), config);
+
+ // init the pool
+ cookieParserPool
+ = new CookieParserPool(new CookieParserFactory(), config);
+
+ getLogger().info("Init Commons2 Fulcrum Pool Services.." );
+ getLogger().info(valueParserPool.getClass().getName());
+ getLogger().info(parameterParserPool.getClass().getName());
+ getLogger().info(cookieParserPool.getClass().getName());
+ }
Configuration[] poolChildren = conf.getChild(POOL_KEY).getChildren();
if (poolChildren.length > 0) {
@@ -393,7 +477,20 @@ public class DefaultParserService
int minIdle = poolConf.getValueAsInteger();
genObjPoolConfig.setMinIdle(minIdle);
break;
+ case "testOnReturn":
+ boolean testOnReturn = poolConf.getValueAsBoolean();
+ genObjPoolConfig.setTestOnReturn(testOnReturn);
+ break;
+ case "testOnBorrow":
+ boolean testOnBorrow = poolConf.getValueAsBoolean();
+ genObjPoolConfig.setTestOnBorrow(testOnBorrow);
+ break;
+ case "testOnCreate":
+ boolean testOnCreate = poolConf.getValueAsBoolean();
+ genObjPoolConfig.setTestOnCreate(testOnCreate);
+ break;
default:
+
break;
}
}
@@ -401,9 +498,12 @@ public class DefaultParserService
valueParserPool.setConfig(genObjPoolConfig);
parameterParserPool.setConfig(genObjPoolConfig);
cookieParserPool.setConfig(genObjPoolConfig);
+
+ getLogger().debug(valueParserPool.toString());
+ getLogger().debug(parameterParserPool.toString());
+ getLogger().debug(cookieParserPool.toString());
}
-
- getLogger().debug(valueParserPool.toString());
+
}
// ---------------- Avalon Lifecycle Methods ---------------------
@@ -417,16 +517,11 @@ public class DefaultParserService
@Override
public void service(ServiceManager manager) throws ServiceException
{
- // no need to call internal service
-// if (manager.hasService(PoolService.ROLE))
-// {
-// poolService = (PoolService)manager.lookup(PoolService.ROLE);
-// }
-// else
-// {
-// throw new ServiceException(ParserService.ROLE,
-// "Service requires " +
-// PoolService.ROLE + " to be available");
-// }
+ // only for fulcrum pool, need to call internal service, if role pool service is set
+ if (manager.hasService(PoolService.ROLE))
+ {
+ fulcrumPoolService = (PoolService)manager.lookup(PoolService.ROLE);
+ }
+ // no check here, until configuration is read
}
}
Modified: turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java (original)
+++ turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java Wed Jun 26 12:48:35 2019
@@ -51,6 +51,12 @@ public interface ParserService
/** Parse file upload items automatically */
String AUTOMATIC_KEY = "automaticUpload";
+ /** fulcrum pool by default false */
+ boolean FULCRUM_POOL_DEFAULT = false;
+
+ /** fulcrum pool activation parameter */
+ String FULCRUM_POOL_KEY = "fulcrumPool";
+
/** commons pool2 parameters */
String POOL_KEY = "pool2";
Modified: turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ValueParser.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ValueParser.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ValueParser.java (original)
+++ turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ValueParser.java Wed Jun 26 12:48:35 2019
@@ -72,6 +72,14 @@ public interface ValueParser extends Ite
* Clear all name/value pairs out of this object.
*/
void clear();
+
+ /**
+ * Dispose all references of this object.
+ *
+ * Instead of org.apache.fulcrum.pool.Recyclable interface we use this,
+ * may change this again..
+ */
+ void dispose();
/**
* Set the character encoding that will be used by this ValueParser.
Added: turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml?rev=1862131&view=auto
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml (added)
+++ turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml Wed Jun 26 12:48:35 2019
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<componentConfig>
+ <parser>
+ <parameterEncoding>utf-8</parameterEncoding>
+ <automaticUpload>true</automaticUpload>
+ <fulcrumPool>true</fulcrumPool>
+ </parser>
+</componentConfig>
Propchange: turbine/fulcrum/trunk/parser/src/test/TestComponentConfigWithFulcrumPool.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml?rev=1862131&view=auto
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml (added)
+++ turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml Wed Jun 26 12:48:35 2019
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+ <role
+ name="org.apache.fulcrum.parser.ParserService"
+ shorthand="parser"
+ default-class="org.apache.fulcrum.parser.DefaultParserService"
+ />
+ <role
+ name="org.apache.fulcrum.pool.PoolService"
+ shorthand="parser"
+ default-class="org.apache.fulcrum.pool.DefaultPoolService"
+ />
+ <role
+ name="org.apache.fulcrum.factory.FactoryService"
+ shorthand="parser"
+ default-class="org.apache.fulcrum.factory.DefaultFactoryService"
+ />
+</role-list>
Propchange: turbine/fulcrum/trunk/parser/src/test/TestRoleConfigWithFulcrumPool.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java (original)
+++ turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserTest.java Wed Jun 26 12:48:35 2019
@@ -29,7 +29,7 @@ import javax.servlet.http.Part;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.fulcrum.parser.ValueParser.URLCaseFolding;
import org.apache.fulcrum.testcontainer.BaseUnit5Test;
-
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -43,84 +43,85 @@ import static org.junit.jupiter.api.Asse
*/
public class ParameterParserTest extends BaseUnit5Test
{
- private ParameterParser parameterParser = null;
+ protected ParameterParser parameterParser = null;
+
+ protected ParserService parserService = null;
- private Part mockTest;
+ protected Part mockTest = new Part()
+ {
+
+ @Override
+ public void write(String fileName) throws IOException
+ {
+ }
+
+ @Override
+ public String getSubmittedFileName()
+ {
+ return null;
+ }
+
+ @Override
+ public long getSize()
+ {
+ return 0;
+ }
+
+ @Override
+ public String getName()
+ {
+ return "upload-field";
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ return null;
+ }
+
+ @Override
+ public Collection<String> getHeaders(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public Collection<String> getHeaderNames()
+ {
+ return null;
+ }
+
+ @Override
+ public String getHeader(String name)
+ {
+ if (name.equals( "content-disposition")) {
+ //return "form-data; name=\"file\"; filename*=utf-8''%c2%a3%20uploadedFileName.ext";
+ //return "attachment; filename=genome.jpeg;";
+ return "form-data; name=\"file\"; filename=\"uploadedFileName.ext\"";
+ }
+ return null;
+ }
+
+ @Override
+ public String getContentType()
+ {
+ return "application/octet-stream";
+ }
+
+ @Override
+ public void delete() throws IOException
+ {
+ }
+ };
@BeforeEach
public void setUpBefore() throws Exception
{
try
{
- ParserService parserService = (ParserService)this.lookup(ParserService.ROLE);
+ parserService = (ParserService)this.lookup(ParserService.ROLE);
parameterParser = parserService.getParser(DefaultParameterParser.class);
- mockTest = new Part()
- {
-
- @Override
- public void write(String fileName) throws IOException
- {
- }
-
- @Override
- public String getSubmittedFileName()
- {
- return null;
- }
-
- @Override
- public long getSize()
- {
- return 0;
- }
-
- @Override
- public String getName()
- {
- return "upload-field";
- }
-
- @Override
- public InputStream getInputStream() throws IOException
- {
- return null;
- }
-
- @Override
- public Collection<String> getHeaders(String name)
- {
- return null;
- }
-
- @Override
- public Collection<String> getHeaderNames()
- {
- return null;
- }
-
- @Override
- public String getHeader(String name)
- {
- if (name.equals( "content-disposition")) {
- //return "form-data; name=\"file\"; filename*=utf-8''%c2%a3%20uploadedFileName.ext";
- //return "attachment; filename=genome.jpeg;";
- return "form-data; name=\"file\"; filename=\"uploadedFileName.ext\"";
- }
- return null;
- }
-
- @Override
- public String getContentType()
- {
- return "application/octet-stream";
- }
-
- @Override
- public void delete() throws IOException
- {
- }
- };
}
catch (ComponentException e)
{
@@ -130,6 +131,16 @@ public class ParameterParserTest extends
}
/**
+ * Clean up after each test is run.
+ */
+ @AfterEach
+ public void tearDown()
+ {
+ parserService.putParser(parameterParser);
+ this.release(parserService);
+ }
+
+ /**
* Simple test to verify the current configuration of URL Case Folding
*
* @throws Exception generic exception
Added: turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java?rev=1862131&view=auto
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java (added)
+++ turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java Wed Jun 26 12:48:35 2019
@@ -0,0 +1,68 @@
+package org.apache.fulcrum.parser;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.servlet.http.Part;
+
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.fulcrum.parser.ValueParser.URLCaseFolding;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * Basic test that ParameterParser instantiates.
+ *
+ * @author <a href="epugh@opensourceconnections.com">Eric Pugh</a>
+ * @version $Id: ParameterParserTest.java 1848895 2018-12-13 21:04:26Z painter $
+ */
+public class ParameterParserWithFulcrumPoolTest extends ParameterParserTest
+{
+
+ @Override
+ @BeforeEach
+ public void setUpBefore() throws Exception
+ {
+ try
+ {
+ setConfigurationFileName("src/test/TestComponentConfigWithFulcrumPool.xml");
+
+ setRoleFileName( "src/test/TestRoleConfigWithFulcrumPool.xml");
+
+ parserService = (ParserService)this.lookup(ParserService.ROLE);
+ parameterParser = parserService.getParser(DefaultParameterParser.class);
+
+ }
+ catch (ComponentException e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+}
Propchange: turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/ParameterParserWithFulcrumPoolTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/BaseValueParserPoolTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/BaseValueParserPoolTest.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/BaseValueParserPoolTest.java (original)
+++ turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/BaseValueParserPoolTest.java Wed Jun 26 12:48:35 2019
@@ -84,7 +84,8 @@ public class BaseValueParserPoolTest ext
@AfterEach
public void tearDown()
{
- parserService.putParser(parser);
+ // parser is explicitely returned from valueParserPool.
+ //parserService.putParser(parser);
this.release(parserService);
}
Modified: turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/ParameterParserPoolTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/ParameterParserPoolTest.java?rev=1862131&r1=1862130&r2=1862131&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/ParameterParserPoolTest.java (original)
+++ turbine/fulcrum/trunk/parser/src/test/org/apache/fulcrum/parser/pool/ParameterParserPoolTest.java Wed Jun 26 12:48:35 2019
@@ -68,7 +68,7 @@ public class ParameterParserPoolTest ext
// init the pool
parameterParserPool
- = new DefaultParameterParserPool(new DefaultParameterParserFactory(), config);;
+ = new DefaultParameterParserPool(new DefaultParameterParserFactory(), config);
}
catch (ComponentException e)
@@ -111,7 +111,6 @@ public class ParameterParserPoolTest ext
assertTrue(parser.isValid());
parameterParserPool.returnObject( parser );
-
} catch ( Exception e )
{
e.printStackTrace();