Fix unused local variable warnings

This commit is contained in:
Phillip Webb 2013-01-25 14:33:23 -08:00
parent 6a1e841952
commit 065b1c0e46
24 changed files with 69 additions and 51 deletions

View File

@ -60,7 +60,7 @@ public abstract aspect AbstractTransactionAspect extends TransactionAspectSuppor
before(Object txObject) : transactionalMethodExecution(txObject) {
MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
Method method = methodSignature.getMethod();
TransactionInfo txInfo = createTransactionIfNecessary(method, txObject.getClass());
createTransactionIfNecessary(method, txObject.getClass());
}
@SuppressAjWarnings("adviceDidNotMatch")

View File

@ -211,6 +211,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase {
MailClientDependencyInjectionAspect.aspectOf().setMailSender(new JavaMailSenderImpl());
Order testOrder = new Order();
Order deserializedOrder = serializeAndDeserialize(testOrder);
assertNotNull(deserializedOrder);
assertNotNull("Interface driven injection didn't occur for deserialization", testOrder.mailSender);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -45,7 +45,6 @@ public final class CustomScopeConfigurerTests {
@Test
public void testWithNoScopes() throws Exception {
Scope scope = mock(Scope.class);
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
figurer.postProcessBeanFactory(factory);
}

View File

@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@ -644,6 +645,7 @@ public final class PropertyResourceConfigurerTests {
ppc.postProcessBeanFactory(factory);
TestBean tb = (TestBean) factory.getBean("tb");
assertNotNull(tb);
assertEquals(0, factory.getAliases("tb").length);
}

View File

@ -515,8 +515,7 @@ public class CallbacksSecurityTests {
perms.add(new AuthPermission("getSubject"));
ProtectionDomain pd = new ProtectionDomain(null, perms);
AccessControlContext acc = new AccessControlContext(
new ProtectionDomain[] { pd });
new AccessControlContext(new ProtectionDomain[] { pd });
final Subject subject = new Subject();
subject.getPrincipals().add(new TestPrincipal("user1"));

View File

@ -121,7 +121,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
public void testGetInstanceByNonmatchingClass() {
try {
Object o = getBeanFactory().getBean("rod", BeanFactory.class);
getBeanFactory().getBean("rod", BeanFactory.class);
fail("Rod bean is not of type BeanFactory; getBeanInstance(rod, BeanFactory.class) should throw BeanNotOfRequiredTypeException");
}
catch (BeanNotOfRequiredTypeException ex) {
@ -155,7 +155,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
public void testGetSharedInstanceByNonmatchingClass() {
try {
Object o = getBeanFactory().getBean("rod", BeanFactory.class);
getBeanFactory().getBean("rod", BeanFactory.class);
fail("Rod bean is not of type BeanFactory; getBeanInstance(rod, BeanFactory.class) should throw BeanNotOfRequiredTypeException");
}
catch (BeanNotOfRequiredTypeException ex) {
@ -199,7 +199,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
public void testNotThere() {
assertFalse(getBeanFactory().containsBean("Mr Squiggle"));
try {
Object o = getBeanFactory().getBean("Mr Squiggle");
getBeanFactory().getBean("Mr Squiggle");
fail("Can't find missing bean");
}
catch (BeansException ex) {
@ -223,7 +223,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
public void xtestTypeMismatch() {
try {
Object o = getBeanFactory().getBean("typeMismatch");
getBeanFactory().getBean("typeMismatch");
fail("Shouldn't succeed with type mismatch");
}
catch (BeanCreationException wex) {
@ -278,6 +278,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
*/
public void testFactoryIsInitialized() throws Exception {
TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory");
assertNotNull(tb);
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
assertTrue("Factory was initialized because it implemented InitializingBean", factory.wasInitialized());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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. You may obtain a copy of
@ -51,6 +51,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testRegisterOperations() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
MBeanInfo inf = getMBeanInfo();
assertEquals("Incorrect number of operations registered",
getExpectedOperationCount(), inf.getOperations().length);
@ -58,6 +59,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testRegisterAttributes() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
MBeanInfo inf = getMBeanInfo();
assertEquals("Incorrect number of attributes registered",
getExpectedAttributeCount(), inf.getAttributes().length);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -39,7 +39,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
public void testWithUnknownClass() throws Exception {
try {
InterfaceBasedMBeanInfoAssembler assembler = getWithMapping("com.foo.bar.Unknown");
getWithMapping("com.foo.bar.Unknown");
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
@ -49,7 +49,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
public void testWithNonInterface() throws Exception {
try {
InterfaceBasedMBeanInfoAssembler assembler = getWithMapping("JmxTestBean");
getWithMapping("JmxTestBean");
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -104,7 +104,7 @@ public class LabeledEnumTests extends TestCase {
public void testDoesNotMatchWrongClass() {
try {
LabeledEnum none = StaticLabeledEnumResolver.instance().getLabeledEnumByCode(Dog.class,
StaticLabeledEnumResolver.instance().getLabeledEnumByCode(Dog.class,
new Short((short) 1));
fail("Should have failed");
}
@ -119,10 +119,11 @@ public class LabeledEnumTests extends TestCase {
}
@SuppressWarnings("serial")
@SuppressWarnings({ "serial", "unused" })
private static class Other extends StaticLabeledEnum {
public static final Other THING1 = new Other(1, "Thing1");
public static final Other THING2 = new Other(2, "Thing2");

View File

@ -1,6 +1,6 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -34,7 +34,6 @@ public class StopWatchTests extends TestCase {
String name1 = "Task 1";
String name2 = "Task 2";
long fudgeFactor = 5L;
assertFalse(sw.isRunning());
sw.start(name1);
Thread.sleep(int1);
@ -44,6 +43,7 @@ public class StopWatchTests extends TestCase {
// TODO are timings off in JUnit? Why do these assertions sometimes fail
// under both Ant and Eclipse?
//long fudgeFactor = 5L;
//assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1);
//assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor);
sw.start(name2);
@ -72,7 +72,6 @@ public class StopWatchTests extends TestCase {
String name1 = "Task 1";
String name2 = "Task 2";
long fudgeFactor = 5L;
assertFalse(sw.isRunning());
sw.start(name1);
Thread.sleep(int1);
@ -82,6 +81,7 @@ public class StopWatchTests extends TestCase {
// TODO are timings off in JUnit? Why do these assertions sometimes fail
// under both Ant and Eclipse?
//long fudgeFactor = 5L;
//assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1);
//assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor);
sw.start(name2);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -17,6 +17,7 @@
package org.springframework.expression.spel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
@ -84,6 +85,7 @@ public class MapAccessTests extends ExpressionTestCase {
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("testBean.properties['key2']");
String key = (String) exp.getValue(bean);
assertNotNull(key);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -18,6 +18,7 @@ package org.springframework.expression.spel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -213,9 +214,11 @@ public class SpelDocumentationTests extends ExpressionTestCase {
societyContext.setRootObject(new IEEE());
// Officer's Dictionary
Inventor pupin = parser.parseExpression("officers['president']").getValue(societyContext, Inventor.class);
assertNotNull(pupin);
// evaluates to "Idvor"
String city = parser.parseExpression("officers['president'].PlaceOfBirth.city").getValue(societyContext, String.class);
assertNotNull(city);
// setting values
Inventor i = parser.parseExpression("officers['advisors'][0]").getValue(societyContext,Inventor.class);

View File

@ -19,6 +19,7 @@ package org.springframework.expression.spel;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -1680,6 +1681,7 @@ public class SpelReproTests extends ExpressionTestCase {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Class<?> valueType = parser.parseExpression("simpleProperty").getValueType(evaluationContext);
assertNotNull(valueType);
}
@Test
@ -1687,6 +1689,7 @@ public class SpelReproTests extends ExpressionTestCase {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Object value = parser.parseExpression("simpleProperty").getValue(evaluationContext);
assertNotNull(value);
}
@Test
@ -1694,6 +1697,7 @@ public class SpelReproTests extends ExpressionTestCase {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Class<?> valueType = parser.parseExpression("primitiveProperty").getValueType(evaluationContext);
assertNotNull(valueType);
}
@Test
@ -1701,6 +1705,7 @@ public class SpelReproTests extends ExpressionTestCase {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Object value = parser.parseExpression("primitiveProperty").getValue(evaluationContext);
assertNotNull(value);
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -67,7 +67,6 @@ public class SQLStateExceptionTranslatorTests extends TestCase {
* Bug 729170
*/
public void testMalformedSqlStateCodes() {
String sql = "SELECT FOO FROM BAR";
SQLException sex = new SQLException("Message", null, 1);
testMalformedSqlStateCode(sex);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -207,7 +207,7 @@ public class JmsTemplate102Tests extends TestCase {
template.execute(new SessionCallback() {
@Override
public Object doInJms(Session session) throws JMSException {
boolean b = session.getTransacted();
session.getTransacted();
return null;
}
});
@ -249,8 +249,8 @@ public class JmsTemplate102Tests extends TestCase {
template.execute(new ProducerCallback() {
@Override
public Object doInJms(Session session, MessageProducer producer) throws JMSException {
boolean b = session.getTransacted();
int i = producer.getPriority();
session.getTransacted();
producer.getPriority();
return null;
}
});

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -190,8 +190,8 @@ public class JmsTemplateTests extends TestCase {
template.execute(new ProducerCallback() {
@Override
public Object doInJms(Session session, MessageProducer producer) throws JMSException {
boolean b = session.getTransacted();
int i = producer.getPriority();
session.getTransacted();
producer.getPriority();
return null;
}
});
@ -234,8 +234,8 @@ public class JmsTemplateTests extends TestCase {
template.execute(new ProducerCallback() {
@Override
public Object doInJms(Session session, MessageProducer producer) throws JMSException {
boolean b = session.getTransacted();
int i = producer.getPriority();
session.getTransacted();
producer.getPriority();
return null;
}
});
@ -264,7 +264,7 @@ public class JmsTemplateTests extends TestCase {
template.execute(new SessionCallback() {
@Override
public Object doInJms(Session session) throws JMSException {
boolean b = session.getTransacted();
session.getTransacted();
return null;
}
});
@ -303,14 +303,14 @@ public class JmsTemplateTests extends TestCase {
template.execute(new SessionCallback() {
@Override
public Object doInJms(Session session) throws JMSException {
boolean b = session.getTransacted();
session.getTransacted();
return null;
}
});
template.execute(new SessionCallback() {
@Override
public Object doInJms(Session session) throws JMSException {
boolean b = session.getTransacted();
session.getTransacted();
return null;
}
});
@ -321,7 +321,7 @@ public class JmsTemplateTests extends TestCase {
TransactionAwareConnectionFactoryProxy tacf = new TransactionAwareConnectionFactoryProxy(scf);
Connection tac = tacf.createConnection();
Session tas = tac.createSession(false, Session.AUTO_ACKNOWLEDGE);
boolean b = tas.getTransacted();
tas.getTransacted();
tas.close();
tac.close();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -48,6 +48,7 @@ public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEnt
assertTrue(Proxy.isProxyClass(em.getClass()));
Query q = em.createQuery("select p from Person as p");
List<Person> people = q.getResultList();
assertNotNull(people);
assertTrue("Should be open to start with", em.isOpen());
em.close();

View File

@ -539,7 +539,7 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
Method m = setNameMethod;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
tas.register(m, txatt);
Method m2 = getNameMethod;
// Method m2 = getNameMethod;
// No attributes for m2
MockControl ptmControl = MockControl.createControl(PlatformTransactionManager.class);

View File

@ -163,6 +163,7 @@ public class BeanFactoryTransactionTests extends TestCase {
public void testGetBeansOfTypeWithAbstract() {
Map beansOfType = factory.getBeansOfType(ITestBean.class, true, true);
assertNotNull(beansOfType);
}
/**
@ -172,7 +173,7 @@ public class BeanFactoryTransactionTests extends TestCase {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("noTransactionAttributeSource.xml", getClass()));
ITestBean testBean = (ITestBean) bf.getBean("noTransactionAttributeSource");
bf.getBean("noTransactionAttributeSource");
fail("Should require TransactionAttributeSource to be set");
}
catch (FatalBeanException ex) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -81,7 +81,7 @@ public class StreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestF
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/methods/post"), HttpMethod.POST);
final int BUF_SIZE = 4096;
final int ITERATIONS = Integer.MAX_VALUE / BUF_SIZE;
final int contentLength = ITERATIONS * BUF_SIZE;
// final int contentLength = ITERATIONS * BUF_SIZE;
// request.getHeaders().setContentLength(contentLength);
OutputStream body = request.getBody();
for (int i = 0; i < ITERATIONS; i++) {

View File

@ -63,7 +63,7 @@ public class ResponseStatusExceptionResolverTests {
exceptionResolver.setMessageSource(messageSource);
StatusCodeAndReasonMessageException ex = new StatusCodeAndReasonMessageException();
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
exceptionResolver.resolveException(request, response, null, ex);
assertEquals("Invalid status reason", "Gone reason message", response.getErrorMessage());
}
finally {

View File

@ -453,7 +453,7 @@ public class MultiActionControllerTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/handleIllegalStateException.html");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mav = mac.handleRequest(request, response);
mac.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus());
}
@ -524,7 +524,6 @@ public class MultiActionControllerTests extends TestCase {
this.invoked.put("commandNoSession", Boolean.TRUE);
String pname = request.getParameter("name");
String page = request.getParameter("age");
// ALLOW FOR NULL
if (pname == null) {
assertTrue("name null", command.getName() == null);
@ -532,6 +531,8 @@ public class MultiActionControllerTests extends TestCase {
else {
assertTrue("name param set", pname.equals(command.getName()));
}
//String page = request.getParameter("age");
// if (page == null)
// assertTrue("age default", command.getAge() == 0);
// else

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -72,14 +72,14 @@ public class ResourceBundleViewResolverTests extends TestCase {
public void testParentsAreAbstract() throws Exception {
try {
View v = rb.resolveViewName("debug.Parent", Locale.ENGLISH);
rb.resolveViewName("debug.Parent", Locale.ENGLISH);
fail("Should have thrown BeanIsAbstractException");
}
catch (BeanIsAbstractException ex) {
// expected
}
try {
View v = rb.resolveViewName("testParent", Locale.ENGLISH);
rb.resolveViewName("testParent", Locale.ENGLISH);
fail("Should have thrown BeanIsAbstractException");
}
catch (BeanIsAbstractException ex) {
@ -152,7 +152,7 @@ public class ResourceBundleViewResolverTests extends TestCase {
public void testNoSuchBasename() throws Exception {
try {
rb.setBasename("weoriwoierqupowiuer");
View v = rb.resolveViewName("debugView", Locale.ENGLISH);
rb.resolveViewName("debugView", Locale.ENGLISH);
fail("No such basename: all requests should fail with exception");
}
catch (MissingResourceException ex) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -86,6 +86,7 @@ public class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
public void testPrototype() {
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("prototype");
assertNotNull(bean);
assertTrue(context.isPrototype("prototype"));
assertFalse(context.isSingleton("prototype"));
}