Format source code

This commit is contained in:
Benedikt Ritter 2015-05-12 08:26:25 +02:00
parent a48071b0d4
commit 5637a5204f
1 changed files with 20 additions and 33 deletions

View File

@ -39,8 +39,8 @@ import org.junit.Test;
/** /**
* @since 3.0 * @since 3.0
*/ */
public class EventListenerSupportTest public class EventListenerSupportTest {
{
@Test @Test
public void testAddListenerNoDuplicates() { public void testAddListenerNoDuplicates() {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
@ -61,23 +61,20 @@ public class EventListenerSupportTest
assertSame(empty, listenerSupport.getListeners()); assertSame(empty, listenerSupport.getListeners());
} }
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void testAddNullListener() public void testAddNullListener() {
{
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(null); listenerSupport.addListener(null);
} }
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void testRemoveNullListener() public void testRemoveNullListener() {
{
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.removeListener(null); listenerSupport.removeListener(null);
} }
@Test @Test
public void testEventDispatchOrder() throws PropertyVetoException public void testEventDispatchOrder() throws PropertyVetoException {
{
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>(); final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>();
@ -91,24 +88,20 @@ public class EventListenerSupportTest
assertSame(calledListeners.get(1), listener2); assertSame(calledListeners.get(1), listener2);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testCreateWithNonInterfaceParameter() public void testCreateWithNonInterfaceParameter() {
{
EventListenerSupport.create(String.class); EventListenerSupport.create(String.class);
} }
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void testCreateWithNullParameter() public void testCreateWithNullParameter() {
{
EventListenerSupport.create(null); EventListenerSupport.create(null);
} }
@Test @Test
public void testRemoveListenerDuringEvent() throws PropertyVetoException public void testRemoveListenerDuringEvent() throws PropertyVetoException {
{
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i) {
{
addDeregisterListener(listenerSupport); addDeregisterListener(listenerSupport);
} }
assertEquals(listenerSupport.getListenerCount(), 10); assertEquals(listenerSupport.getListenerCount(), 10);
@ -143,7 +136,7 @@ public class EventListenerSupportTest
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException { public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
listenerSupport.addListener(new VetoableChangeListener() { listenerSupport.addListener(new VetoableChangeListener() {
@Override @Override
public void vetoableChange(final PropertyChangeEvent e) { public void vetoableChange(final PropertyChangeEvent e) {
} }
@ -218,25 +211,19 @@ public class EventListenerSupportTest
EasyMock.verify(listener); EasyMock.verify(listener);
} }
private void addDeregisterListener(final EventListenerSupport<VetoableChangeListener> listenerSupport) private void addDeregisterListener(final EventListenerSupport<VetoableChangeListener> listenerSupport) {
{ listenerSupport.addListener(new VetoableChangeListener() {
listenerSupport.addListener(new VetoableChangeListener()
{
@Override @Override
public void vetoableChange(final PropertyChangeEvent e) public void vetoableChange(final PropertyChangeEvent e) {
{
listenerSupport.removeListener(this); listenerSupport.removeListener(this);
} }
}); });
} }
private VetoableChangeListener createListener(final List<VetoableChangeListener> calledListeners) private VetoableChangeListener createListener(final List<VetoableChangeListener> calledListeners) {
{ return new VetoableChangeListener() {
return new VetoableChangeListener()
{
@Override @Override
public void vetoableChange(final PropertyChangeEvent e) public void vetoableChange(final PropertyChangeEvent e) {
{
calledListeners.add(this); calledListeners.add(this);
} }
}; };