Use generics more

This commit is contained in:
Ville Skyttä 2016-02-28 01:06:59 +02:00
parent e202240ccc
commit 7c275cdb1a
65 changed files with 158 additions and 169 deletions

View File

@ -34,7 +34,7 @@ public class ConnectionFactoryObjectFactory implements ObjectFactory {
public Object getObjectInstance(final Object ref,
final Name name,
final Context ctx,
final Hashtable props) throws Exception {
final Hashtable<?, ?> props) throws Exception {
Reference r = (Reference) ref;
byte[] bytes = (byte[]) r.get("ActiveMQ-CF").getContent();

View File

@ -34,7 +34,7 @@ public class DestinationObjectFactory implements ObjectFactory {
public Object getObjectInstance(final Object ref,
final Name name,
final Context ctx,
final Hashtable props) throws Exception {
final Hashtable<?, ?> props) throws Exception {
Reference r = (Reference) ref;
byte[] bytes = (byte[]) r.get("ActiveMQ-DEST").getContent();

View File

@ -23,7 +23,6 @@ import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -48,11 +47,10 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
private String topicPrefix = "topic.";
@Override
public Context getInitialContext(Hashtable environment) throws NamingException {
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
// lets create a factory
Map<String, Object> data = new ConcurrentHashMap<>();
for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
for (Map.Entry<?, ?> entry : environment.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith(connectionFactoryPrefix)) {
String jndiName = key.substring(connectionFactoryPrefix.length());
@ -111,13 +109,12 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
// Implementation methods
// -------------------------------------------------------------------------
protected ReadOnlyContext createContext(Hashtable environment, Map<String, Object> data) {
protected ReadOnlyContext createContext(Hashtable<?, ?> environment, Map<String, Object> data) {
return new ReadOnlyContext(environment, data);
}
protected void createQueues(Map<String, Object> data, Hashtable environment) {
for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
protected void createQueues(Map<String, Object> data, Hashtable<?, ?> environment) {
for (Map.Entry<?, ?> entry : environment.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith(queuePrefix)) {
String jndiName = key.substring(queuePrefix.length());
@ -126,9 +123,8 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
}
}
protected void createTopics(Map<String, Object> data, Hashtable environment) {
for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
protected void createTopics(Map<String, Object> data, Hashtable<?, ?> environment) {
for (Map.Entry<?, ?> entry : environment.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith(topicPrefix)) {
String jndiName = key.substring(topicPrefix.length());

View File

@ -112,7 +112,7 @@ public class ReadOnlyContext implements Context, Serializable {
frozen = true;
}
public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace) {
public ReadOnlyContext(Hashtable environment, Map<String, Object> bindings, String nameInNamespace) {
this(environment, bindings);
this.nameInNamespace = nameInNamespace;
}
@ -181,9 +181,8 @@ public class ReadOnlyContext implements Context, Serializable {
ReadOnlyContext readOnlyContext = (ReadOnlyContext) o;
String remainder = name.substring(pos + 1);
Map<String, Object> subBindings = readOnlyContext.internalBind(remainder, value);
for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry) iterator.next();
String subName = segment + "/" + (String) entry.getKey();
for (Map.Entry<String, Object> entry : subBindings.entrySet()) {
String subName = segment + "/" + entry.getKey();
Object bound = entry.getValue();
treeBindings.put(subName, bound);
newBindings.put(subName, bound);
@ -302,7 +301,7 @@ public class ReadOnlyContext implements Context, Serializable {
}
@Override
public NamingEnumeration list(String name) throws NamingException {
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
Object o = lookup(name);
if (o == this) {
return new ListEnumeration();
@ -316,7 +315,7 @@ public class ReadOnlyContext implements Context, Serializable {
}
@Override
public NamingEnumeration listBindings(String name) throws NamingException {
public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
Object o = lookup(name);
if (o == this) {
return new ListBindingEnumeration();
@ -335,12 +334,12 @@ public class ReadOnlyContext implements Context, Serializable {
}
@Override
public NamingEnumeration list(Name name) throws NamingException {
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
return list(name.toString());
}
@Override
public NamingEnumeration listBindings(Name name) throws NamingException {
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
return listBindings(name.toString());
}
@ -426,7 +425,7 @@ public class ReadOnlyContext implements Context, Serializable {
private abstract class LocalNamingEnumeration implements NamingEnumeration {
private final Iterator i = bindings.entrySet().iterator();
private final Iterator<Map.Entry<String, Object>> i = bindings.entrySet().iterator();
@Override
public boolean hasMore() throws NamingException {
@ -438,8 +437,8 @@ public class ReadOnlyContext implements Context, Serializable {
return i.hasNext();
}
protected Map.Entry getNext() {
return (Map.Entry) i.next();
protected Map.Entry<String, Object> getNext() {
return i.next();
}
@Override
@ -459,8 +458,8 @@ public class ReadOnlyContext implements Context, Serializable {
@Override
public Object nextElement() {
Map.Entry entry = getNext();
return new NameClassPair((String) entry.getKey(), entry.getValue().getClass().getName());
Map.Entry<String, Object> entry = getNext();
return new NameClassPair(entry.getKey(), entry.getValue().getClass().getName());
}
}
@ -476,8 +475,8 @@ public class ReadOnlyContext implements Context, Serializable {
@Override
public Object nextElement() {
Map.Entry entry = getNext();
return new Binding((String) entry.getKey(), entry.getValue());
Map.Entry<String, Object> entry = getNext();
return new Binding(entry.getKey(), entry.getValue());
}
}
}

View File

@ -22,7 +22,7 @@ import java.util.Hashtable;
public class JNDIConnectionFactoryFactory extends JNDIFactorySupport implements ConnectionFactoryFactory {
public JNDIConnectionFactoryFactory(final Hashtable jndiProperties, final String lookup) {
public JNDIConnectionFactoryFactory(final Hashtable<?, ?> jndiProperties, final String lookup) {
super(jndiProperties, lookup);
}

View File

@ -24,7 +24,7 @@ import javax.jms.Destination;
public class JNDIDestinationFactory extends JNDIFactorySupport implements DestinationFactory {
public JNDIDestinationFactory(final Hashtable jndiProperties, final String lookup) {
public JNDIDestinationFactory(final Hashtable<?, ?> jndiProperties, final String lookup) {
super(jndiProperties, lookup);
}

View File

@ -22,11 +22,11 @@ import javax.naming.InitialContext;
public abstract class JNDIFactorySupport {
protected Hashtable jndiProperties;
protected Hashtable<?, ?> jndiProperties;
protected String lookup;
protected JNDIFactorySupport(final Hashtable jndiProperties, final String lookup) {
protected JNDIFactorySupport(final Hashtable<?, ?> jndiProperties, final String lookup) {
this.jndiProperties = jndiProperties;
this.lookup = lookup;

View File

@ -320,7 +320,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro
}
@Override
public String sendTextMessage(Map headers, String body) throws Exception {
public String sendTextMessage(Map<String, String> headers, String body) throws Exception {
return sendTextMessage(headers, body, null, null);
}

View File

@ -25,11 +25,11 @@ public class DumbServer {
static ConcurrentMap<String, BlockingDeque<Object>> maps = new ConcurrentHashMap<>();
public static BlockingDeque getQueue(String name) {
BlockingDeque q = maps.get(name);
public static BlockingDeque<Object> getQueue(String name) {
BlockingDeque<Object> q = maps.get(name);
if (q == null) {
q = new LinkedBlockingDeque();
BlockingDeque oldValue = maps.putIfAbsent(name, q);
q = new LinkedBlockingDeque<>();
BlockingDeque<Object> oldValue = maps.putIfAbsent(name, q);
if (oldValue != null) {
q = oldValue;
}

View File

@ -1630,7 +1630,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable {
if (!knownConnectionFactories.keySet().contains(overrideProperties)) {
cf = newConnectionFactory(overrideProperties);
knownConnectionFactories.put(overrideProperties, new Pair(cf, new AtomicInteger(1)));
knownConnectionFactories.put(overrideProperties, new Pair<>(cf, new AtomicInteger(1)));
}
else {
Pair<ActiveMQConnectionFactory, AtomicInteger> pair = knownConnectionFactories.get(overrideProperties);
@ -1642,7 +1642,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable {
if (known && cf.getServerLocator().isClosed()) {
knownConnectionFactories.remove(overrideProperties);
cf = newConnectionFactory(overrideProperties);
knownConnectionFactories.put(overrideProperties, new Pair(cf, new AtomicInteger(1)));
knownConnectionFactories.put(overrideProperties, new Pair<>(cf, new AtomicInteger(1)));
}
return cf;

View File

@ -124,7 +124,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen
private String jndiParams = null;
private Hashtable parsedJndiParams;
private Hashtable<String, String> parsedJndiParams;
/* use local tx instead of XA*/
private Boolean localTx;

View File

@ -178,7 +178,7 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
return UnaryExpression.createNOT(createLike(left, right, escape));
}
public static BooleanExpression createInFilter(Expression left, List elements) {
public static BooleanExpression createInFilter(Expression left, List<Object> elements) {
if (!(left instanceof PropertyExpression)) {
throw new RuntimeException("Expected a property for In expression, got: " + left);
@ -187,7 +187,7 @@ public abstract class ComparisonExpression extends BinaryExpression implements B
}
public static BooleanExpression createNotInFilter(Expression left, List elements) {
public static BooleanExpression createNotInFilter(Expression left, List<Object> elements) {
if (!(left instanceof PropertyExpression)) {
throw new RuntimeException("Expected a property for In expression, got: " + left);

View File

@ -28,7 +28,7 @@ import org.apache.activemq.artemis.selector.strict.StrictParser;
*/
public class SelectorParser {
private static final LRUCache cache = new LRUCache(100);
private static final LRUCache<String, Object> cache = new LRUCache<>(100);
private static final String CONVERT_STRING_EXPRESSIONS_PREFIX = "convert_string_expressions:";
private static final String HYPHENATED_PROPS_PREFIX = "hyphenated_props:";
private static final String NO_CONVERT_STRING_EXPRESSIONS_PREFIX = "no_convert_string_expressions:";

View File

@ -107,7 +107,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
private final ClusterManager clusterManager;
private final Map<String, ProtocolManagerFactory> protocolMap = new ConcurrentHashMap();
private final Map<String, ProtocolManagerFactory> protocolMap = new ConcurrentHashMap<>();
private ActiveMQPrincipal defaultInvmSecurityPrincipal;
@ -213,7 +213,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
try {
AcceptorFactory factory = server.getServiceRegistry().getAcceptorFactory(info.getName(), info.getFactoryClassName());
Map<String, ProtocolManagerFactory> selectedProtocolFactories = new ConcurrentHashMap();
Map<String, ProtocolManagerFactory> selectedProtocolFactories = new ConcurrentHashMap<>();
@SuppressWarnings("deprecation")
String protocol = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOL_PROP_NAME, null, info.getParams());
@ -235,7 +235,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
selectedProtocolFactories = protocolMap;
}
Map<String, ProtocolManager> selectedProtocols = new ConcurrentHashMap();
Map<String, ProtocolManager> selectedProtocols = new ConcurrentHashMap<>();
for (Map.Entry<String, ProtocolManagerFactory> entry: selectedProtocolFactories.entrySet()) {
selectedProtocols.put(entry.getKey(), entry.getValue().createProtocolManager(server, info.getExtraParams(), incomingInterceptors, outgoingInterceptors));
}

View File

@ -79,9 +79,9 @@ public final class ClusterManager implements ActiveMQComponent {
private HAManager haManager;
private final Map<String, BroadcastGroup> broadcastGroups = new HashMap();
private final Map<String, BroadcastGroup> broadcastGroups = new HashMap<>();
private final Map<String, Bridge> bridges = new HashMap();
private final Map<String, Bridge> bridges = new HashMap<>();
private final ExecutorFactory executorFactory;

View File

@ -60,7 +60,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract {
private final ConcurrentMap<SimpleString, List<SimpleString>> groupMap = new ConcurrentHashMap<>();
private final ConcurrentHashSet<Notification> pendingNotifications = new ConcurrentHashSet();
private final ConcurrentHashSet<Notification> pendingNotifications = new ConcurrentHashSet<>();
private boolean started = false;

View File

@ -1807,15 +1807,15 @@ public class ActiveMQServerImpl implements ActiveMQServer {
JournalLoadInformation[] journalInfo = new JournalLoadInformation[2];
List<QueueBindingInfo> queueBindingInfos = new ArrayList();
List<QueueBindingInfo> queueBindingInfos = new ArrayList<>();
List<GroupingInfo> groupingInfos = new ArrayList();
List<GroupingInfo> groupingInfos = new ArrayList<>();
journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos);
recoverStoredConfigs();
Map<Long, QueueBindingInfo> queueBindingInfosMap = new HashMap();
Map<Long, QueueBindingInfo> queueBindingInfosMap = new HashMap<>();
journalLoader.initQueues(queueBindingInfosMap, queueBindingInfos);

View File

@ -427,14 +427,14 @@ public class PostOfficeJournalLoader implements JournalLoader {
Map<Long, Map<Long, List<PageCountPending>>> perPageMap = perAddressMap.get(address);
if (perPageMap == null) {
perPageMap = new HashMap();
perPageMap = new HashMap<>();
perAddressMap.put(address, perPageMap);
}
Map<Long, List<PageCountPending>> perQueueMap = perPageMap.get(pageID);
if (perQueueMap == null) {
perQueueMap = new HashMap();
perQueueMap = new HashMap<>();
perPageMap.put(pageID, perQueueMap);
}

View File

@ -39,7 +39,7 @@ public abstract class AbstractProtocolManagerFactory<P extends BaseInterceptor>
return Collections.emptyList();
}
else {
CopyOnWriteArrayList<P> listOut = new CopyOnWriteArrayList();
CopyOnWriteArrayList<P> listOut = new CopyOnWriteArrayList<>();
for (BaseInterceptor<?> in : listIn) {
if (type.isInstance(in)) {
listOut.add((P) in);

View File

@ -51,7 +51,7 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements
* Overriding to allow for proper initialization. Standard JAAS.
*/
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;

View File

@ -53,7 +53,7 @@ public class GuestLoginModule implements LoginModule {
private boolean loginSucceeded;
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
debug = "true".equalsIgnoreCase((String) options.get("debug"));

View File

@ -46,7 +46,7 @@ public class InVMLoginModule implements LoginModule {
private boolean loginSucceeded;
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
this.configuration = (SecurityConfiguration) options.get(CONFIG_PROP_NAME);

View File

@ -82,7 +82,7 @@ public class LDAPLoginModule implements LoginModule {
private Set<RolePrincipal> groups = new HashSet<>();
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.handler = callbackHandler;

View File

@ -51,8 +51,8 @@ public class PropertiesLoginModule extends PropertiesLoader implements LoginModu
@Override
public void initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options) {
Map<String, ?> sharedState,
Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
loginSucceeded = false;

View File

@ -49,7 +49,7 @@ public class TextFileCertificateLoginModule extends CertificateLoginModule {
* Performs initialization of file paths. A standard JAAS override.
*/
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
super.initialize(subject, callbackHandler, sharedState, options);
usersByDn = load(USER_FILE_PROP_NAME, "", options).invertedPropertiesMap();
roles = load(ROLE_FILE_PROP_NAME, "", options).getProps();

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.security.Principal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
@ -59,7 +58,7 @@ public class CertificateLoginModuleTest extends Assert {
loginModule = new StubCertificateLoginModule(userName, new HashSet<>(rolesNames));
JaasCallbackHandler callbackHandler = new JaasCallbackHandler(null, null, null);
loginModule.initialize(subject, callbackHandler, null, new HashMap());
loginModule.initialize(subject, callbackHandler, null, new HashMap<String, Object>());
loginModule.login();
loginModule.commit();
@ -72,9 +71,7 @@ public class CertificateLoginModuleTest extends Assert {
rolesFound[i] = false;
}
for (Iterator iter = subject.getPrincipals().iterator(); iter.hasNext(); ) {
Principal currentPrincipal = (Principal) iter.next();
for (Principal currentPrincipal : subject.getPrincipals()) {
if (currentPrincipal instanceof UserPrincipal) {
if (currentPrincipal.getName().equals(USER_NAME)) {
if (!nameFound) {

View File

@ -70,11 +70,10 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit {
}
}
@SuppressWarnings("unchecked")
@Test
public void testRunning() throws Exception {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
@ -82,12 +81,12 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit {
env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
DirContext ctx = new InitialDirContext(env);
HashSet set = new HashSet();
HashSet<String> set = new HashSet<>();
NamingEnumeration list = ctx.list("ou=system");
NamingEnumeration<NameClassPair> list = ctx.list("ou=system");
while (list.hasMore()) {
NameClassPair ncp = (NameClassPair) list.next();
NameClassPair ncp = list.next();
set.add(ncp.getName());
}

View File

@ -70,11 +70,10 @@ public class LDAPModuleRoleExpansionTest extends AbstractLdapTestUnit {
}
}
@SuppressWarnings("unchecked")
@Test
public void testRunning() throws Exception {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
@ -82,12 +81,12 @@ public class LDAPModuleRoleExpansionTest extends AbstractLdapTestUnit {
env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
DirContext ctx = new InitialDirContext(env);
HashSet set = new HashSet();
HashSet<String> set = new HashSet<>();
NamingEnumeration list = ctx.list("ou=system");
NamingEnumeration<NameClassPair> list = ctx.list("ou=system");
while (list.hasMore()) {
NameClassPair ncp = (NameClassPair) list.next();
NameClassPair ncp = list.next();
set.add(ncp.getName());
}

View File

@ -93,7 +93,7 @@ public class PropertiesLoginModuleRaceConditionTest {
Subject subject = new Subject();
PropertiesLoginModule module = new PropertiesLoginModule();
module.initialize(subject, callback, new HashMap<>(), options);
module.initialize(subject, callback, new HashMap<String, Object>(), options);
module.login();
module.commit();
}

View File

@ -75,7 +75,7 @@ public class TextFileCertificateLoginModuleTest {
private void loginTest(String usersFiles, String groupsFile) throws LoginException {
HashMap options = new HashMap<String, String>();
HashMap<String, String> options = new HashMap<>();
options.put("org.apache.activemq.jaas.textfiledn.user", usersFiles);
options.put("org.apache.activemq.jaas.textfiledn.role", groupsFile);
options.put("reload", "true");
@ -113,7 +113,7 @@ public class TextFileCertificateLoginModuleTest {
return new JaasCallbackHandler(null, null, new X509Certificate[]{cert});
}
private Subject doAuthenticate(HashMap options, JaasCallbackHandler callbackHandler) throws LoginException {
private Subject doAuthenticate(HashMap<String, ?> options, JaasCallbackHandler callbackHandler) throws LoginException {
Subject mySubject = new Subject();
loginModule.initialize(mySubject, callbackHandler, null, options);
loginModule.login();

View File

@ -20,6 +20,7 @@ import java.net.URI;
import java.util.Set;
import org.apache.activemq.EmbeddedBrokerTestSupport;
import org.apache.activemq.broker.region.Destination;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
@ -48,7 +49,7 @@ public class CreateDestinationsOnStartupViaXBeanTest extends EmbeddedBrokerTestS
}
protected void assertDestinationCreated(ActiveMQDestination destination, boolean expected) throws Exception {
Set answer = broker.getBroker().getDestinations(destination);
Set<Destination> answer = broker.getBroker().getDestinations(destination);
int size = expected ? 1 : 0;
assertEquals("Could not find destination: " + destination + ". Size of found destinations: " + answer, size, answer.size());
}

View File

@ -18,9 +18,10 @@
package org.apache.activemq.broker;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import javax.jms.Message;
import junit.framework.TestCase;
import org.apache.activemq.spring.SpringConsumer;
@ -67,10 +68,9 @@ public class SpringTest extends TestCase {
consumer.waitForMessagesToArrive(producer.getMessageCount());
// now lets check that the consumer has received some messages
List messages = consumer.flushMessages();
List<Message> messages = consumer.flushMessages();
LOG.info("Consumer has received messages....");
for (Iterator iter = messages.iterator(); iter.hasNext(); ) {
Object message = iter.next();
for (Message message : messages) {
LOG.info("Received: " + message);
}

View File

@ -41,7 +41,7 @@ public class mKahaDbQueueMasterSlaveTest extends QueueMasterSlaveTestSupport {
master.setDeleteAllMessagesOnStartup(true);
MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
List adapters = new LinkedList<FilteredKahaDBPersistenceAdapter>();
List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>();
FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter());
defaultEntry.setPerDestination(true);
@ -72,7 +72,7 @@ public class mKahaDbQueueMasterSlaveTest extends QueueMasterSlaveTestSupport {
broker.setPersistent(true);
MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
List adapters = new LinkedList<FilteredKahaDBPersistenceAdapter>();
List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>();
FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter());
defaultEntry.setPerDestination(true);

View File

@ -1432,7 +1432,7 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
BrokerViewMBean brokerView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
Map connectors = brokerView.getTransportConnectors();
Map<String, String> connectors = brokerView.getTransportConnectors();
LOG.info("Connectors: " + connectors);
assertEquals("one connector", 1, connectors.size());

View File

@ -34,7 +34,7 @@ public class mKahaDBXARecoveryBrokerTest extends XARecoveryBrokerTest {
super.configureBroker(broker);
MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
List adapters = new LinkedList<FilteredKahaDBPersistenceAdapter>();
List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>();
FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter());
adapters.add(defaultEntry);

View File

@ -34,7 +34,7 @@ public class mLevelDBXARecoveryBrokerTest extends XARecoveryBrokerTest {
super.configureBroker(broker);
MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
List adapters = new LinkedList<FilteredKahaDBPersistenceAdapter>();
List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>();
FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
defaultEntry.setPersistenceAdapter(new LevelDBPersistenceAdapter());
adapters.add(defaultEntry);

View File

@ -175,8 +175,8 @@ public class AMQ5266SingleDestTest {
publisher.waitForCompletion();
List publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet(publishedIds).size();
List<String> publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet<>(publishedIds).size();
LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);
LOG.info("Publisher duration: {}", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - totalStart));

View File

@ -182,8 +182,8 @@ public class AMQ5266StarvedConsumerTest {
publisher.waitForCompletion();
List publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet(publishedIds).size();
List<String> publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet<>(publishedIds).size();
LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);

View File

@ -166,8 +166,8 @@ public class AMQ5266Test {
publisher.waitForCompletion();
List publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet(publishedIds).size();
List<String> publishedIds = publisher.getIDs();
distinctPublishedCount = new TreeSet<>(publishedIds).size();
LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);

View File

@ -53,7 +53,7 @@ public class AMQ5450Test {
private final static String[] DESTS = new String[]{DESTINATION_NAME, DESTINATION_NAME_2, DESTINATION_NAME_3, DESTINATION_NAME, DESTINATION_NAME};
BrokerService broker;
private HashMap<Object, PersistenceAdapter> adapters = new HashMap();
private HashMap<Object, PersistenceAdapter> adapters = new HashMap<>();
@After
public void tearDown() throws Exception {
@ -98,7 +98,7 @@ public class AMQ5450Test {
assertEquals(1, destination2.getMessageStore().getMessageCount());
}
HashMap numDests = new HashMap();
HashMap<Integer, PersistenceAdapter> numDests = new HashMap<>();
for (PersistenceAdapter pa : adapters.values()) {
numDests.put(pa.getDestinations().size(), pa);
}

View File

@ -49,7 +49,7 @@ public class ActiveMQDestinationTest extends DataStructureTestSupport {
}
public void testDestinationOptions() throws IOException {
Map options = destination.getOptions();
Map<String, String> options = destination.getOptions();
assertNotNull(options);
assertEquals("v1", options.get("k1"));
assertEquals("v2", options.get("k2"));

View File

@ -62,7 +62,7 @@ public abstract class MessageTestSupport extends BaseCommandTestSupport {
}
{
Map map = new HashMap();
Map<String, Object> map = new HashMap<>();
map.put("MarshalledProperties", 12);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);

View File

@ -61,7 +61,7 @@ public abstract class MessageTestSupport extends BaseCommandTestSupport {
info.setContent(baos.toByteSequence());
}
{
Map map = new HashMap();
Map<String, Object> map = new HashMap<>();
map.put("MarshalledProperties", 12);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);

View File

@ -104,8 +104,8 @@ public class ReliableTransportTest extends TestCase {
transport.onCommand(info);
}
Queue exceptions = listener.getExceptions();
Queue commands = listener.getCommands();
Queue<Object> exceptions = listener.getExceptions();
Queue<Object> commands = listener.getCommands();
if (expected) {
if (!exceptions.isEmpty()) {
Exception e = (Exception) exceptions.remove();

View File

@ -71,7 +71,7 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
connector0.setHost("localhost");
jetty.addConnector(connector0);
jetty.start();
HashMap<String, Object> params = new HashMap();
HashMap<String, Object> params = new HashMap<>();
params.put(AeroGearConstants.QUEUE_NAME, "testQueue");
params.put(AeroGearConstants.ENDPOINT_NAME, "http://localhost:8080");
params.put(AeroGearConstants.APPLICATION_ID_NAME, "9d646a12-e601-4452-9e05-efb0fccdfd08");

View File

@ -82,7 +82,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testVMCF0() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.ConnectionFactory", "vm://0");
Context ctx = new InitialContext(props);
@ -94,7 +94,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testVMCF1() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.ConnectionFactory", "vm://1");
Context ctx = new InitialContext(props);
@ -106,7 +106,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testXACF() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "vm://0?type=XA_CF");
Context ctx = new InitialContext(props);
@ -118,7 +118,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testQueueCF() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "vm://0?type=QUEUE_CF");
Context ctx = new InitialContext(props);
@ -130,7 +130,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testQueueXACF() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "vm://0?type=QUEUE_XA_CF");
Context ctx = new InitialContext(props);
@ -142,7 +142,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testTopicCF() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "vm://0?type=TOPIC_CF");
Context ctx = new InitialContext(props);
@ -154,7 +154,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testTopicXACF() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "vm://0?type=TOPIC_XA_CF");
Context ctx = new InitialContext(props);
@ -166,7 +166,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithTCP() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "tcp://127.0.0.1:61616");
Context ctx = new InitialContext(props);
@ -178,7 +178,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithTCPandHA() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "tcp://127.0.0.1:61616?ha=true");
Context ctx = new InitialContext(props);
@ -190,7 +190,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithJGroups() throws Exception {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "jgroups://mychannelid?file=test-jgroups-file_ping.xml");
Context ctx = new InitialContext(props);
@ -201,7 +201,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithJgroupsWithTransportConfigFile() throws Exception {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.myConnectionFactory", "jgroups://testChannelName?file=test-jgroups-file_ping.xml&" +
ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" +
@ -221,7 +221,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithJgroupsWithTransportConfigProps() throws Exception {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?properties=param=value&" +
ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" +
@ -243,7 +243,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithJgroupsWithTransportConfigNullProps() throws Exception {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?" +
ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" +
@ -265,7 +265,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithUDP() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "udp://" + getUDPDiscoveryAddress() + ":" + getUDPDiscoveryPort());
Context ctx = new InitialContext(props);
@ -277,7 +277,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithUDPWithTransportConfig() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory.myConnectionFactory", "udp://" + getUDPDiscoveryAddress() + ":" + getUDPDiscoveryPort() + "?" +
TransportConstants.LOCAL_ADDRESS_PROP_NAME + "=Server1&" +
@ -302,7 +302,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithMultipleHosts() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "tcp://127.0.0.1:61616/httpEnabled=true&foo=bar,tcp://127.0.0.2:61617?httpEnabled=false?clientID=myClientID");
Context ctx = new InitialContext(props);
@ -314,7 +314,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testRemoteCFWithTransportConfig() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.myConnectionFactory", "tcp://127.0.0.1:61616?" +
TransportConstants.SSL_ENABLED_PROP_NAME + "=mySSLEnabledPropValue&" +
@ -350,7 +350,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
Map parametersFromJNDI = cf.getServerLocator().getStaticTransportConfigurations()[0].getParams();
Map<String, Object> parametersFromJNDI = cf.getServerLocator().getStaticTransportConfigurations()[0].getParams();
Assert.assertEquals(parametersFromJNDI.get(TransportConstants.SSL_ENABLED_PROP_NAME), "mySSLEnabledPropValue");
Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_ENABLED_PROP_NAME), "myHTTPEnabledPropValue");
@ -398,7 +398,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
List<String> connectorNames = new ArrayList<>();
connectorNames.add(liveTC.getName());
Map params = new HashMap();
Map<String, Object> params = new HashMap<>();
params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, 1);
Configuration liveConf = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params)).addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY)).setConnectorConfigurations(connectors).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
@ -421,7 +421,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testQueue() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("queue.myQueue", "myQueue");
props.put("queue.queues/myQueue", "myQueue");
@ -436,7 +436,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testDynamicQueue() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
Context ctx = new InitialContext(props);
@ -446,7 +446,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testTopic() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("topic.myTopic", "myTopic");
props.put("topic.topics/myTopic", "myTopic");
@ -461,7 +461,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
@Test
public void testDynamicTopic() throws NamingException, JMSException {
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
Context ctx = new InitialContext(props);

View File

@ -54,7 +54,7 @@ public class InvalidDestinationTest extends JMSTestBase {
Topic invalidTopic = null;
String message = "hello world";
byte[] bytesMsgSend = message.getBytes();
Map<String, Object> mapMsgSend = new HashMap();
Map<String, Object> mapMsgSend = new HashMap<>();
mapMsgSend.put("s", "foo");
mapMsgSend.put("b", true);
mapMsgSend.put("i", 1);

View File

@ -380,7 +380,7 @@ public class XmlImportExportTest extends ActiveMQTestBase {
final String jndi_binding2 = name + "Binding2";
final JMSFactoryType type = JMSFactoryType.CF;
final boolean ha = true;
final List connectors = Arrays.asList("in-vm1", "in-vm2");
final List<String> connectors = Arrays.asList("in-vm1", "in-vm2");
ClientSession session = basicSetUp();

View File

@ -41,7 +41,7 @@ public class ActiveMQRAClusteredTestBase extends ActiveMQRATestBase {
super.setUp();
primaryConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
HashMap<String, Object> params = new HashMap();
HashMap<String, Object> params = new HashMap<>();
params.put(TransportConstants.SERVER_ID_PROP_NAME, "1");
secondaryConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params);
@ -59,8 +59,8 @@ public class ActiveMQRAClusteredTestBase extends ActiveMQRATestBase {
}
protected Configuration createSecondaryDefaultConfig(boolean secondary) throws Exception {
HashMap invmMap = new HashMap();
HashMap nettyMap = new HashMap();
HashMap<String, Object> invmMap = new HashMap<>();
HashMap<String, Object> nettyMap = new HashMap<>();
String primaryConnectorName = "invm2";
String secondaryConnectorName = "invm";
int index = 0;

View File

@ -97,10 +97,9 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit {
testDir = temporaryFolder.getRoot().getAbsolutePath();
}
@SuppressWarnings("unchecked")
@Test
public void testRunning() throws Exception {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
@ -108,12 +107,12 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit {
env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
DirContext ctx = new InitialDirContext(env);
HashSet set = new HashSet();
HashSet<String> set = new HashSet<>();
NamingEnumeration list = ctx.list("ou=system");
NamingEnumeration<NameClassPair> list = ctx.list("ou=system");
while (list.hasMore()) {
NameClassPair ncp = (NameClassPair) list.next();
NameClassPair ncp = list.next();
set.add(ncp.getName());
}

View File

@ -102,17 +102,16 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
testDir = temporaryFolder.getRoot().getAbsolutePath();
}
@SuppressWarnings("unchecked")
@Test
public void testRunning() throws Exception {
DirContext ctx = getContext();
HashSet set = new HashSet();
HashSet<String> set = new HashSet<>();
NamingEnumeration list = ctx.list("ou=system");
NamingEnumeration<NameClassPair> list = ctx.list("ou=system");
while (list.hasMore()) {
NameClassPair ncp = (NameClassPair) list.next();
NameClassPair ncp = list.next();
set.add(ncp.getName());
}
@ -124,7 +123,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
}
private DirContext getContext() throws NamingException {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");

View File

@ -96,10 +96,9 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit {
testDir = temporaryFolder.getRoot().getAbsolutePath();
}
@SuppressWarnings("unchecked")
@Test
public void testRunning() throws Exception {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
@ -107,12 +106,12 @@ public class LegacyLDAPSecuritySettingPluginTest extends AbstractLdapTestUnit {
env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
DirContext ctx = new InitialDirContext(env);
HashSet set = new HashSet();
HashSet<String> set = new HashSet<>();
NamingEnumeration list = ctx.list("ou=system");
NamingEnumeration<NameClassPair> list = ctx.list("ou=system");
while (list.hasMore()) {
NameClassPair ncp = (NameClassPair) list.next();
NameClassPair ncp = list.next();
set.add(ncp.getName());
}

View File

@ -42,10 +42,10 @@ public class ConnectionLimitTest extends ActiveMQTestBase {
public void setUp() throws Exception {
super.setUp();
Map nettyParams = new HashMap();
Map<String, Object> nettyParams = new HashMap<>();
nettyParams.put(TransportConstants.CONNECTIONS_ALLOWED, 1);
Map invmParams = new HashMap();
Map<String, Object> invmParams = new HashMap<>();
invmParams.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED, 1);
Configuration configuration = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, nettyParams)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, invmParams));

View File

@ -98,7 +98,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
private Channel channel;
private BlockingQueue priorityQueue;
private BlockingQueue<String> priorityQueue;
private EventLoopGroup group;
@ -108,7 +108,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
@Before
public void setUp() throws Exception {
super.setUp();
priorityQueue = new ArrayBlockingQueue(1000);
priorityQueue = new ArrayBlockingQueue<>(1000);
if (autoCreateServer) {
server = createServer();
addServer(server.getActiveMQServer());
@ -271,7 +271,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
}
public String receiveFrame(long timeOut) throws Exception {
String msg = (String) priorityQueue.poll(timeOut, TimeUnit.MILLISECONDS);
String msg = priorityQueue.poll(timeOut, TimeUnit.MILLISECONDS);
return msg;
}

View File

@ -31,7 +31,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage
// Attributes ----------------------------------------------------
protected Map content;
protected Map<String, Object> content;
protected boolean bodyReadOnly = false;
@ -40,7 +40,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage
// Constructors --------------------------------------------------
public SimpleJMSMapMessage() {
content = new HashMap();
content = new HashMap<>();
}
// MapMessage implementation -------------------------------------
@ -472,7 +472,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage
@Override
public Enumeration getMapNames() throws JMSException {
return Collections.enumeration(new HashMap(content).keySet());
return Collections.enumeration(new HashMap<>(content).keySet());
}

View File

@ -29,6 +29,7 @@ import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
@ -152,17 +153,17 @@ public class InVMContext implements Context, Serializable {
}
@Override
public NamingEnumeration list(final Name name) throws NamingException {
public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
throw new UnsupportedOperationException();
}
@Override
public NamingEnumeration list(final String name) throws NamingException {
public NamingEnumeration<NameClassPair> list(final String name) throws NamingException {
throw new UnsupportedOperationException();
}
@Override
public NamingEnumeration listBindings(final Name name) throws NamingException {
public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
throw new UnsupportedOperationException();
}

View File

@ -32,7 +32,7 @@ public class InVMInitialContextFactory implements InitialContextFactory {
// Static --------------------------------------------------------
private static Map initialContexts;
private static Map<Integer, Context> initialContexts;
static {
InVMInitialContextFactory.reset();
@ -59,7 +59,7 @@ public class InVMInitialContextFactory implements InitialContextFactory {
// Public --------------------------------------------------------
@Override
public Context getInitialContext(final Hashtable environment) throws NamingException {
public Context getInitialContext(final Hashtable<?, ?> environment) throws NamingException {
// try first in the environment passed as argument ...
String s = (String) environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
@ -107,7 +107,7 @@ public class InVMInitialContextFactory implements InitialContextFactory {
}
public static void reset() {
InVMInitialContextFactory.initialContexts = new HashMap();
InVMInitialContextFactory.initialContexts = new HashMap<>();
}
// Package protected ---------------------------------------------

View File

@ -41,7 +41,7 @@ public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBu
// InitialContextFactoryBuilder implementation --------------------------------------------------
@Override
public InitialContextFactory createInitialContextFactory(final Hashtable environment) throws NamingException {
public InitialContextFactory createInitialContextFactory(final Hashtable<?, ?> environment) throws NamingException {
InitialContextFactory icf = null;

View File

@ -89,7 +89,7 @@ public final class NonSerializableFactory implements ObjectFactory {
public Object getObjectInstance(final Object obj,
final Name name,
final Context nameCtx,
final Hashtable env) throws Exception {
final Hashtable<?, ?> env) throws Exception {
Reference ref = (Reference) obj;
RefAddr addr = ref.get("nns");
String key = (String) addr.getContent();

View File

@ -235,7 +235,7 @@ public class MessageTypeTest extends PTPTestCase {
@Test
public void testObjectMessage_2() {
try {
Vector vector = new Vector();
Vector<Object> vector = new Vector<>();
vector.add("pi");
vector.add(new Double(3.14159));

View File

@ -171,7 +171,7 @@ public class MessageHeaderTest extends PTPTestCase {
try {
admin.createQueue("anotherQueue");
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getName());
props.put("queue.anotherQueue", "anotherQueue");

View File

@ -115,7 +115,7 @@ public abstract class PTPTestCase extends JMSTestCase {
admin.createQueueConnectionFactory(PTPTestCase.QCF_NAME);
admin.createQueue(PTPTestCase.QUEUE_NAME);
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory." + PTPTestCase.QCF_NAME, "tcp://127.0.0.1:61616?type=QUEUE_CF");
props.put("queue." + PTPTestCase.QUEUE_NAME, PTPTestCase.QUEUE_NAME);

View File

@ -115,7 +115,7 @@ public abstract class PubSubTestCase extends JMSTestCase {
admin.createTopicConnectionFactory(PubSubTestCase.TCF_NAME);
admin.createTopic(PubSubTestCase.TOPIC_NAME);
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory." + PubSubTestCase.TCF_NAME, "tcp://127.0.0.1:61616?type=TOPIC_CF");
props.put("topic." + PubSubTestCase.TOPIC_NAME, PubSubTestCase.TOPIC_NAME);

View File

@ -165,7 +165,7 @@ public abstract class UnifiedTestCase extends JMSTestCase {
admin.createQueue(UnifiedTestCase.QUEUE_NAME);
admin.createTopic(UnifiedTestCase.TOPIC_NAME);
Hashtable props = new Hashtable<>();
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
props.put("connectionFactory." + UnifiedTestCase.CF_NAME, "tcp://127.0.0.1:61616");
props.put("connectionFactory." + UnifiedTestCase.QCF_NAME, "tcp://127.0.0.1:61616?type=QUEUE_CF");

View File

@ -66,7 +66,7 @@ public abstract class SequentialFileFactoryTestBase extends ActiveMQTestBase {
@Test
public void listFilesOnNonExistentFolder() throws Exception {
SequentialFileFactory fileFactory = createFactory("./target/dontexist");
List list = fileFactory.listFiles("tmp");
List<String> list = fileFactory.listFiles("tmp");
Assert.assertNotNull(list);
Assert.assertEquals(0, list.size());
}