mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 15:08:10 +00:00
activemq-core module renamed to activemq-unit-tests git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1439685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a55aae00e7
commit
ef24cc9a04
@ -86,7 +86,7 @@
|
||||
<!-- testing helpers -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<artifactId>activemq-unit-tests</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -1,113 +0,0 @@
|
||||
/**
|
||||
* 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.activemq.util;
|
||||
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A Simple LRU Set
|
||||
*
|
||||
*
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
|
||||
public class LRUSet<E>
|
||||
extends AbstractSet<E>
|
||||
implements Set<E>, Cloneable, java.io.Serializable{
|
||||
|
||||
private static final Object IGNORE = new Object();
|
||||
|
||||
private final LRUCache cache;
|
||||
|
||||
/**
|
||||
* Default constructor for an LRU Cache The default capacity is 10000
|
||||
*/
|
||||
public LRUSet() {
|
||||
this(0,10000, 0.75f, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a LRUCache with a maximum capacity
|
||||
*
|
||||
* @param maximumCacheSize
|
||||
*/
|
||||
public LRUSet(int maximumCacheSize) {
|
||||
this(0, maximumCacheSize, 0.75f, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an empty <tt>LRUCache</tt> instance with the specified
|
||||
* initial capacity, maximumCacheSize,load factor and ordering mode.
|
||||
*
|
||||
* @param initialCapacity
|
||||
* the initial capacity.
|
||||
* @param maximumCacheSize
|
||||
* @param loadFactor
|
||||
* the load factor.
|
||||
* @param accessOrder
|
||||
* the ordering mode - <tt>true</tt> for access-order,
|
||||
* <tt>false</tt> for insertion-order.
|
||||
* @throws IllegalArgumentException
|
||||
* if the initial capacity is negative or the load factor is
|
||||
* non-positive.
|
||||
*/
|
||||
|
||||
public LRUSet(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) {
|
||||
this.cache = new LRUCache<E,Object>(initialCapacity,maximumCacheSize,loadFactor,accessOrder);
|
||||
}
|
||||
|
||||
|
||||
public Iterator<E> iterator() {
|
||||
return cache.keySet().iterator();
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty() {
|
||||
return cache.isEmpty();
|
||||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
return cache.containsKey(o);
|
||||
}
|
||||
|
||||
|
||||
public boolean add(E o) {
|
||||
return cache.put(o, IGNORE)==null;
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
return cache.remove(o)==IGNORE;
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* 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.activemq.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
import javax.jms.Message;
|
||||
|
||||
/**
|
||||
* A base class for comparators which works on JMS {@link Message} objects
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class MessageComparatorSupport implements Comparator, Serializable {
|
||||
|
||||
public int compare(Object object1, Object object2) {
|
||||
Message command1 = (Message)object1;
|
||||
Message command2 = (Message)object2;
|
||||
return compareMessages(command1, command2);
|
||||
}
|
||||
|
||||
protected abstract int compareMessages(Message message1, Message message2);
|
||||
|
||||
protected int compareComparators(final Comparable comparable, final Comparable comparable2) {
|
||||
if (comparable == null && comparable2 == null) {
|
||||
return 0;
|
||||
} else if (comparable != null) {
|
||||
if (comparable2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return comparable.compareTo(comparable2);
|
||||
} else if (comparable2 != null) {
|
||||
if (comparable == null) {
|
||||
return -11;
|
||||
}
|
||||
return comparable2.compareTo(comparable) * -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* 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.activemq.util;
|
||||
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
|
||||
import org.apache.activemq.command.ActiveMQMessage;
|
||||
|
||||
/**
|
||||
* A comparator which works on SendCommand objects to compare the destinations
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MessageDestinationComparator extends MessageComparatorSupport {
|
||||
|
||||
protected int compareMessages(Message message1, Message message2) {
|
||||
return compareComparators(getComparable(getDestination(message1)), getComparable(getDestination(message2)));
|
||||
}
|
||||
|
||||
protected Destination getDestination(Message message) {
|
||||
if (message instanceof ActiveMQMessage) {
|
||||
ActiveMQMessage amqMessage = (ActiveMQMessage)message;
|
||||
return amqMessage.getDestination();
|
||||
}
|
||||
try {
|
||||
return message.getJMSDestination();
|
||||
} catch (JMSException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected Comparable getComparable(Destination destination) {
|
||||
if (destination != null) {
|
||||
return destination.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
/**
|
||||
* 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.activemq.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.propertyeditors.ClassEditor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.ConverterMatcher;
|
||||
import com.thoughtworks.xstream.converters.SingleValueConverter;
|
||||
|
||||
public class XStreamFactoryBean implements FactoryBean {
|
||||
|
||||
XStream xstream = new XStream();
|
||||
|
||||
/**
|
||||
* Sets the <code>Converters</code> or <code>SingleValueConverters</code> to be registered with the
|
||||
* <code>XStream</code> instance.
|
||||
*
|
||||
* @see Converter
|
||||
* @see SingleValueConverter
|
||||
*/
|
||||
public void setConverters(ConverterMatcher[] converters) {
|
||||
for (int i = 0; i < converters.length; i++) {
|
||||
if (converters[i] instanceof Converter) {
|
||||
xstream.registerConverter((Converter) converters[i], i);
|
||||
}
|
||||
else if (converters[i] instanceof SingleValueConverter) {
|
||||
xstream.registerConverter((SingleValueConverter) converters[i], i);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Invalid ConverterMatcher [" + converters[i] + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a alias/type map, consisting of string aliases mapped to <code>Class</code> instances (or Strings to be
|
||||
* converted to <code>Class</code> instances).
|
||||
*
|
||||
* @see org.springframework.beans.propertyeditors.ClassEditor
|
||||
*/
|
||||
public void setAliases(Map aliases) {
|
||||
for (Iterator iterator = aliases.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) iterator.next();
|
||||
// Check whether we need to convert from String to Class.
|
||||
Class type;
|
||||
if (entry.getValue() instanceof Class) {
|
||||
type = (Class) entry.getValue();
|
||||
}
|
||||
else {
|
||||
ClassEditor editor = new ClassEditor();
|
||||
editor.setAsText(String.valueOf(entry.getValue()));
|
||||
type = (Class) editor.getValue();
|
||||
}
|
||||
xstream.alias((String) entry.getKey(), type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XStream mode.
|
||||
*
|
||||
* @see XStream#XPATH_REFERENCES
|
||||
* @see XStream#ID_REFERENCES
|
||||
* @see XStream#NO_REFERENCES
|
||||
*/
|
||||
public void setMode(int mode) {
|
||||
xstream.setMode(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the classes, for which mappings will be read from class-level JDK 1.5+ annotation metadata.
|
||||
*
|
||||
* @see Annotations#configureAliases(XStream, Class[])
|
||||
*/
|
||||
public void setAnnotatedClass(Class<?> annotatedClass) {
|
||||
Assert.notNull(annotatedClass, "'annotatedClass' must not be null");
|
||||
xstream.processAnnotations(annotatedClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets annotated classes, for which aliases will be read from class-level JDK 1.5+ annotation metadata.
|
||||
*
|
||||
* @see Annotations#configureAliases(XStream, Class[])
|
||||
*/
|
||||
public void setAnnotatedClasses(Class<?>[] annotatedClasses) {
|
||||
Assert.notEmpty(annotatedClasses, "'annotatedClasses' must not be empty");
|
||||
xstream.processAnnotations(annotatedClasses);
|
||||
}
|
||||
|
||||
public Object getObject() throws Exception {
|
||||
return xstream;
|
||||
}
|
||||
|
||||
public Class getObjectType() {
|
||||
return XStream.class;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Some utility classes
|
||||
|
||||
</body>
|
||||
</html>
|
@ -79,7 +79,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<artifactId>activemq-unit-tests</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -67,7 +67,7 @@
|
||||
<!-- =============================== -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<artifactId>activemq-unit-tests</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -6,9 +6,9 @@
|
||||
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.
|
||||
@ -32,7 +32,7 @@
|
||||
<description>ActiveMQ integration test with Spring 3.1</description>
|
||||
|
||||
<properties>
|
||||
<!-- force using spring 3.1.x -->
|
||||
<!-- force using spring 3.1.x -->
|
||||
<spring-version>3.1.3.RELEASE</spring-version>
|
||||
</properties>
|
||||
|
||||
@ -45,15 +45,11 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- testing helpers -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<artifactId>activemq-unit-tests</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -94,10 +94,6 @@
|
||||
<artifactId>org.osgi.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-http</artifactId>
|
||||
|
@ -26,9 +26,9 @@
|
||||
<version>5.8-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<name>ActiveMQ :: Core</name>
|
||||
<description>The ActiveMQ Message Broker and Client implementations</description>
|
||||
<artifactId>activemq-unit-tests</artifactId>
|
||||
<name>ActiveMQ :: Unit Tests</name>
|
||||
<description>The ActiveMQ Message Broker and Client Unit Tests</description>
|
||||
|
||||
<properties>
|
||||
<surefire.argLine>-Xmx512M</surefire.argLine>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user