CAMEL-6698: Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2ad33aa6 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2ad33aa6 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2ad33aa6 Branch: refs/heads/master Commit: 2ad33aa66a2d306cded747e19461485bc599da85 Parents: 6168724 Author: Claus Ibsen <[email protected]> Authored: Sat Feb 14 14:56:54 2015 +0100 Committer: Claus Ibsen <[email protected]> Committed: Sat Feb 14 14:56:54 2015 +0100 ---------------------------------------------------------------------- .../component/cache/CacheConfiguration.java | 19 ++++++------ .../cache/ObjectCacheProducerTest.java | 31 +++++++++++++------- .../component/cache/PoetryNotSerializable.java | 19 ++++++++++++ 3 files changed, 48 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2ad33aa6/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheConfiguration.java b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheConfiguration.java index 16f51ec..1e74491 100755 --- a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheConfiguration.java +++ b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheConfiguration.java @@ -32,7 +32,7 @@ public class CacheConfiguration implements Cloneable { private String cacheName; @UriParam(defaultValue = "1000") private int maxElementsInMemory = 1000; - @UriParam(defaultValue = "LFU") + @UriParam(defaultValue = "LFU", enums = "LRU,LFU,FIFO,CLOCK") private MemoryStoreEvictionPolicy memoryStoreEvictionPolicy = MemoryStoreEvictionPolicy.LFU; @UriParam(defaultValue = "true") private boolean overflowToDisk = true; @@ -49,11 +49,11 @@ public class CacheConfiguration implements Cloneable { @UriParam(defaultValue = "false") private long diskExpiryThreadIntervalSeconds; @UriParam + private boolean objectCache; + @UriParam private CacheEventListenerRegistry eventListenerRegistry = new CacheEventListenerRegistry(); @UriParam private CacheLoaderRegistry cacheLoaderRegistry = new CacheLoaderRegistry(); - @UriParam - private boolean objectCache; public CacheConfiguration() { } @@ -83,7 +83,7 @@ public class CacheConfiguration implements Cloneable { Map<String, Object> cacheSettings = URISupport.parseParameters(uri); if (cacheSettings.containsKey("maxElementsInMemory")) { - setMaxElementsInMemory(Integer.valueOf((String) cacheSettings.get("maxElementsInMemory")).intValue()); + setMaxElementsInMemory(Integer.valueOf((String) cacheSettings.get("maxElementsInMemory"))); } if (cacheSettings.containsKey("overflowToDisk")) { setOverflowToDisk(Boolean.valueOf((String) cacheSettings.get("overflowToDisk"))); @@ -95,16 +95,16 @@ public class CacheConfiguration implements Cloneable { setEternal(Boolean.valueOf((String) cacheSettings.get("eternal"))); } if (cacheSettings.containsKey("timeToLiveSeconds")) { - setTimeToLiveSeconds(Long.valueOf((String) cacheSettings.get("timeToLiveSeconds")).longValue()); + setTimeToLiveSeconds(Long.valueOf((String) cacheSettings.get("timeToLiveSeconds"))); } if (cacheSettings.containsKey("timeToIdleSeconds")) { - setTimeToIdleSeconds(Long.valueOf((String) cacheSettings.get("timeToIdleSeconds")).longValue()); + setTimeToIdleSeconds(Long.valueOf((String) cacheSettings.get("timeToIdleSeconds"))); } if (cacheSettings.containsKey("diskPersistent")) { setDiskPersistent(Boolean.valueOf((String) cacheSettings.get("diskPersistent"))); } if (cacheSettings.containsKey("diskExpiryThreadIntervalSeconds")) { - setDiskExpiryThreadIntervalSeconds(Long.valueOf((String) cacheSettings.get("diskExpiryThreadIntervalSeconds")).longValue()); + setDiskExpiryThreadIntervalSeconds(Long.valueOf((String) cacheSettings.get("diskExpiryThreadIntervalSeconds"))); } if (cacheSettings.containsKey("memoryStoreEvictionPolicy")) { String policy = (String) cacheSettings.get("memoryStoreEvictionPolicy"); @@ -112,12 +112,11 @@ public class CacheConfiguration implements Cloneable { policy = policy.replace("MemoryStoreEvictionPolicy.", ""); setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.fromString(policy)); } - if (cacheSettings.containsKey("objectCache")){ + if (cacheSettings.containsKey("objectCache")) { setObjectCache(Boolean.valueOf((String) cacheSettings.get("objectCache"))); } - if (isObjectCache() - && (isOverflowToDisk() || isDiskPersistent())) { + if (isObjectCache() && (isOverflowToDisk() || isDiskPersistent())) { throw new IllegalArgumentException("Unable to create object cache with disk access"); } } http://git-wip-us.apache.org/repos/asf/camel/blob/2ad33aa6/components/camel-cache/src/test/java/org/apache/camel/component/cache/ObjectCacheProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cache/src/test/java/org/apache/camel/component/cache/ObjectCacheProducerTest.java b/components/camel-cache/src/test/java/org/apache/camel/component/cache/ObjectCacheProducerTest.java index 630ce19..9e020c4 100644 --- a/components/camel-cache/src/test/java/org/apache/camel/component/cache/ObjectCacheProducerTest.java +++ b/components/camel-cache/src/test/java/org/apache/camel/component/cache/ObjectCacheProducerTest.java @@ -1,3 +1,19 @@ +/** + * 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.camel.component.cache; import org.apache.camel.EndpointInject; @@ -11,22 +27,17 @@ import org.junit.Test; public class ObjectCacheProducerTest extends CamelTestSupport { + @EndpointInject(uri = "mock:ObjectCacheProducerTest.result") + protected MockEndpoint resultEndpoint; -// protected String ehcacheConfigurationPath() { -// return "src/test/resources/test-object-ehcache.xml"; -// } + @EndpointInject(uri = "mock:ObjectCacheProducerTest.cacheException") + protected MockEndpoint cacheExceptionEndpoint; @Override public boolean isUseRouteBuilder() { return false; } - @EndpointInject(uri = "mock:ObjectCacheProducerTest.result") - protected MockEndpoint resultEndpoint; - - @EndpointInject(uri = "mock:ObjectCacheProducerTest.cacheException") - protected MockEndpoint cacheExceptionEndpoint; - /** * Test storing 3 elements into object cache then retrieving them back. * We allow cache to store maximum of 2 values to check that overflow to disk not happened (it is not @@ -101,7 +112,6 @@ public class ObjectCacheProducerTest extends CamelTestSupport { private void sendNonSerializedData(String endpoint, final PoetryNotSerializable notSerializable) throws Exception { template.send(endpoint, new Processor() { public void process(Exchange exchange) throws Exception { - // Set the property of the charset encoding exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8"); Message in = exchange.getIn(); @@ -123,6 +133,5 @@ public class ObjectCacheProducerTest extends CamelTestSupport { poetry.setPoet(poet); poetry.setPoem(poem); return poetry; - } } http://git-wip-us.apache.org/repos/asf/camel/blob/2ad33aa6/components/camel-cache/src/test/java/org/apache/camel/component/cache/PoetryNotSerializable.java ---------------------------------------------------------------------- diff --git a/components/camel-cache/src/test/java/org/apache/camel/component/cache/PoetryNotSerializable.java b/components/camel-cache/src/test/java/org/apache/camel/component/cache/PoetryNotSerializable.java index e26464f..95cd44b 100644 --- a/components/camel-cache/src/test/java/org/apache/camel/component/cache/PoetryNotSerializable.java +++ b/components/camel-cache/src/test/java/org/apache/camel/component/cache/PoetryNotSerializable.java @@ -1,3 +1,19 @@ +/** + * 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.camel.component.cache; public class PoetryNotSerializable { @@ -8,12 +24,15 @@ public class PoetryNotSerializable { public String getPoet() { return poet; } + public void setPoet(String poet) { this.poet = poet; } + public String getPoem() { return poem; } + public void setPoem(String poem) { this.poem = poem; }
