Migrate JUnit 3 tests to JUnit 4

This commit migrates all remaining tests from JUnit 3 to JUnit 4, with
the exception of Spring's legacy JUnit 3.8 based testing framework that
is still in use in the spring-orm module.

Issue: SPR-13514
This commit is contained in:
Sam Brannen
2015-09-26 00:10:58 +02:00
parent 1580288815
commit d5ee787e1e
213 changed files with 4879 additions and 3939 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,35 +19,34 @@ package org.springframework.jms.listener.endpoint;
import javax.jms.Destination;
import javax.jms.Session;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.jca.StubResourceAdapter;
import org.springframework.jms.StubQueue;
import org.springframework.jms.support.destination.DestinationResolver;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
/**
* @author Agim Emruli
* @author Juergen Hoeller
*/
public class DefaultJmsActivationSpecFactoryTests extends TestCase {
public class DefaultJmsActivationSpecFactoryTests {
private JmsActivationSpecConfig activationSpecConfig;
private final JmsActivationSpecConfig activationSpecConfig = new JmsActivationSpecConfig() {{
setMaxConcurrency(5);
setPrefetchSize(3);
setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
setClientId("clientid");
setDestinationName("destinationname");
setDurableSubscriptionName("durableSubscriptionName");
setMessageSelector("selector");
}};
@Override
protected void setUp() throws Exception {
activationSpecConfig = new JmsActivationSpecConfig();
activationSpecConfig.setMaxConcurrency(5);
activationSpecConfig.setPrefetchSize(3);
activationSpecConfig.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
activationSpecConfig.setClientId("clientid");
activationSpecConfig.setDestinationName("destinationname");
activationSpecConfig.setDurableSubscriptionName("durableSubscriptionName");
activationSpecConfig.setMessageSelector("selector");
}
public void testActiveMQResourceAdapterSetup() {
@Test
public void activeMQResourceAdapterSetup() {
activationSpecConfig.setAcknowledgeMode(Session.SESSION_TRANSACTED);
JmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory();
StubActiveMQActivationSpec spec = (StubActiveMQActivationSpec) activationSpecFactory.createActivationSpec(
@@ -58,7 +57,8 @@ public class DefaultJmsActivationSpecFactoryTests extends TestCase {
assertTrue(spec.isUseRAManagedTransaction());
}
public void testWebSphereResourceAdapterSetup() throws Exception {
@Test
public void webSphereResourceAdapterSetup() throws Exception {
Destination destination = new StubQueue();
DestinationResolver destinationResolver = mock(DestinationResolver.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,43 +24,48 @@ import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicSession;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.jms.StubQueue;
import org.springframework.jms.StubTopic;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
/**
* @author Rick Evans
*/
public class DynamicDestinationResolverTests extends TestCase {
public class DynamicDestinationResolverTests {
private static final String DESTINATION_NAME = "foo";
public void testResolveWithPubSubTopicSession() throws Exception {
@Test
public void resolveWithPubSubTopicSession() throws Exception {
Topic expectedDestination = new StubTopic();
TopicSession session = mock(TopicSession.class);
given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
testResolveDestination(session, expectedDestination, true);
}
public void testResolveWithPubSubVanillaSession() throws Exception {
@Test
public void resolveWithPubSubVanillaSession() throws Exception {
Topic expectedDestination = new StubTopic();
Session session = mock(Session.class);
given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
testResolveDestination(session, expectedDestination, true);
}
public void testResolveWithPointToPointQueueSession() throws Exception {
@Test
public void resolveWithPointToPointQueueSession() throws Exception {
Queue expectedDestination = new StubQueue();
Session session = mock(QueueSession.class);
given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);
testResolveDestination(session, expectedDestination, false);
}
public void testResolveWithPointToPointVanillaSession() throws Exception {
@Test
public void resolveWithPointToPointVanillaSession() throws Exception {
Queue expectedDestination = new StubQueue();
Session session = mock(Session.class);
given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);