Skip to content

Commit

Permalink
Fix unused local variable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jan 25, 2013
1 parent 6a1e841 commit 065b1c0
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public void testInterfaceDrivenDependencyInjectionUponDeserialization() throws E
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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -45,7 +45,6 @@ public void setUp() {

@Test
public void testWithNoScopes() throws Exception {
Scope scope = mock(Scope.class);
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
figurer.postProcessBeanFactory(factory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -644,6 +645,7 @@ public void testPropertyPlaceholderConfigurerWithSelfReferencingPlaceholderInAli
ppc.postProcessBeanFactory(factory);

TestBean tb = (TestBean) factory.getBean("tb");
assertNotNull(tb);
assertEquals(0, factory.getAliases("tb").length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ public void testTrustedExecution() throws Exception {
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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testGetInstanceByMatchingClass() {

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) {
Expand Down Expand Up @@ -155,7 +155,7 @@ public void testGetSharedInstanceByMatchingClassNoCatch() {

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) {
Expand Down Expand Up @@ -199,7 +199,7 @@ public void testPrototypeInstancesAreIndependent() {
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) {
Expand All @@ -223,7 +223,7 @@ public void testValidEmpty() {

public void xtestTypeMismatch() {
try {
Object o = getBeanFactory().getBean("typeMismatch");
getBeanFactory().getBean("typeMismatch");
fail("Shouldn't succeed with type mismatch");
}
catch (BeanCreationException wex) {
Expand Down Expand Up @@ -278,6 +278,7 @@ public void testGetFactoryItself() throws Exception {
*/
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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -51,13 +51,15 @@ public void testMBeanRegistration() throws Exception {

public void testRegisterOperations() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
MBeanInfo inf = getMBeanInfo();
assertEquals("Incorrect number of operations registered",
getExpectedOperationCount(), inf.getOperations().length);
}

public void testRegisterAttributes() throws Exception {
IJmxTestBean bean = getBean();
assertNotNull(bean);
MBeanInfo inf = getMBeanInfo();
assertEquals("Incorrect number of attributes registered",
getExpectedAttributeCount(), inf.getAttributes().length);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -39,7 +39,7 @@ public void testGetAgeIsReadOnly() throws Exception {

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) {
Expand All @@ -49,7 +49,7 @@ public void testWithUnknownClass() throws Exception {

public void testWithNonInterface() throws Exception {
try {
InterfaceBasedMBeanInfoAssembler assembler = getWithMapping("JmxTestBean");
getWithMapping("JmxTestBean");
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testLabelFoundForAbstractEnums() {

public void testDoesNotMatchWrongClass() {
try {
LabeledEnum none = StaticLabeledEnumResolver.instance().getLabeledEnumByCode(Dog.class,
StaticLabeledEnumResolver.instance().getLabeledEnumByCode(Dog.class,
new Short((short) 1));
fail("Should have failed");
}
Expand All @@ -119,10 +119,11 @@ public void testEquals() {
}


@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");


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -34,7 +34,6 @@ public void testValidUsage() throws Exception {
String name1 = "Task 1";
String name2 = "Task 2";

long fudgeFactor = 5L;
assertFalse(sw.isRunning());
sw.start(name1);
Thread.sleep(int1);
Expand All @@ -44,6 +43,7 @@ public void testValidUsage() throws Exception {
// 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);
Expand Down Expand Up @@ -72,7 +72,6 @@ public void testValidUsageNotKeepingTaskList() throws Exception {
String name1 = "Task 1";
String name2 = "Task 2";

long fudgeFactor = 5L;
assertFalse(sw.isRunning());
sw.start(name1);
Thread.sleep(int1);
Expand All @@ -82,6 +81,7 @@ public void testValidUsageNotKeepingTaskList() throws Exception {
// 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -83,9 +84,10 @@ public void testGetValue(){

ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("testBean.properties['key2']");
String key= (String)exp.getValue(bean);
String key = (String) exp.getValue(bean);
assertNotNull(key);

}
}

public static class TestBean
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,6 +18,7 @@

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;

Expand Down Expand Up @@ -213,9 +214,11 @@ public void testDictionaryAccess() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -1680,27 +1681,31 @@ public void SPR_10091_simpleTestValueType() {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Class<?> valueType = parser.parseExpression("simpleProperty").getValueType(evaluationContext);
assertNotNull(valueType);
}

@Test
public void SPR_10091_simpleTestValue() {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Object value = parser.parseExpression("simpleProperty").getValue(evaluationContext);
assertNotNull(value);
}

@Test
public void SPR_10091_primitiveTestValueType() {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Class<?> valueType = parser.parseExpression("primitiveProperty").getValueType(evaluationContext);
assertNotNull(valueType);
}

@Test
public void SPR_10091_primitiveTestValue() {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new BooleanHolder());
Object value = parser.parseExpression("primitiveProperty").getValue(evaluationContext);
assertNotNull(value);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -67,7 +67,6 @@ public void testInvalidSqlStateCode() {
* Bug 729170
*/
public void testMalformedSqlStateCodes() {
String sql = "SELECT FOO FROM BAR";
SQLException sex = new SQLException("Message", null, 1);
testMalformedSqlStateCode(sex);

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testTopicSessionCallback() throws Exception {
template.execute(new SessionCallback() {
@Override
public Object doInJms(Session session) throws JMSException {
boolean b = session.getTransacted();
session.getTransacted();
return null;
}
});
Expand Down Expand Up @@ -249,8 +249,8 @@ public void testTopicProducerCallback() throws Exception {
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;
}
});
Expand Down
Loading

0 comments on commit 065b1c0

Please sign in to comment.