INT-1596, fixed the broken links as well as all warnings

This commit is contained in:
Oleg Zhurakousky
2010-11-09 12:17:45 -05:00
parent 8da4fae7ef
commit 1278666ed7
31 changed files with 40 additions and 259 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.integration.xmpp.messages;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;
@@ -31,26 +30,11 @@ import org.springframework.util.Assert;
/**
* This component logs in as a user and forwards any messages <em>to</em> that
* user on to downstream components.
* It takes any message from a given XMPP session (as established by
* the current {@link XMPPConnection}) and forwards the
* {@link org.jivesoftware.smack.packet.Message} as the payload of the Spring
* Integration {@link org.springframework.integration.Message}.
* <strong>Note</strong>: the {@link org.jivesoftware.smack.ChatManager}
* maintains a Map&lt;String, Chat&gt; for threads and users, where the threadID
* ({@link String}) is the key or the userID {@link String} is the key. This
* {@link java.util.Map} is a Smack-specific implementation called
* {@link org.jivesoftware.smack.util.collections.ReferenceMap} that removes
* key/values as references are dereferenced.
*
* @author Josh Long
* @author Mark Fisher
* @author Oleg Zhurakousky
*
* @see ChatManager the ChatManager class that
* keeps watch over all Chats between the client and any other
* participants.
* @see XMPPConnection the XMPPConnection (as
* created by {@link XmppConnectionFactory}
*/
public class XmppMessageDrivenEndpoint extends AbstractXmppConnectionAwareEndpoint {

View File

@@ -25,7 +25,6 @@ import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHandlingException;
@@ -33,7 +32,6 @@ import org.springframework.integration.MessagingException;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.xmpp.AbstractXmppConnectionAwareEndpoint;
import org.springframework.integration.xmpp.XmppContextUtils;
import org.springframework.util.Assert;
/**

View File

@@ -21,7 +21,6 @@ import static org.mockito.Mockito.mock;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -38,7 +37,7 @@ public class XmppConnectionFactoryBeanTests {
}
@Test
public void testXmppConnectionFactoryBeanViaConfig() throws Exception{
ApplicationContext ac = new ClassPathXmlApplicationContext("XmppConnectionFactoryBeanTests-context.xml", this.getClass());
new ClassPathXmlApplicationContext("XmppConnectionFactoryBeanTests-context.xml", this.getClass());
// the fact that no exception was thrown satisfies this test
}
}

View File

@@ -1,45 +0,0 @@
/*
* Copyright 2002-2010 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 the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.xmpp.ignore;
import org.apache.commons.lang.StringUtils;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.xmpp.XmppHeaders;
/**
* This class reacts to changes in
* {@link org.jivesoftware.smack.packet.Presence} objects for a given account.
*
* @author Josh Long
* @since 2.0
*/
public class XmppRosterEventConsumer {
@ServiceActivator
public void presenceChanged(Message<?> presenceEventMsg) throws Exception {
// System.out.println(StringUtils.repeat("-", 100));
// String whosePresence = (String) presenceEventMsg.getHeaders().get(XmppHeaders.PRESENCE_FROM);
// System.out.println("entries affected: " + whosePresence);
// MessageHeaders messageHeaders = presenceEventMsg.getHeaders();
// for (String h : messageHeaders.keySet()) {
// System.out.println(String.format("%s = %s", h, messageHeaders.get(h)));
// }
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2002-2010 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 the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.xmpp.ignore;
import org.apache.commons.lang.StringUtils;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.springframework.integration.Message;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.xmpp.XmppHeaders;
/**
* This is used in
* {@link org.springframework.integration.xmpp.ignore.OutboundXmppRosterEventsEndpointTests}
* to produce fake status / presence updates.
*
* @author Josh Long
* @since 2.0
*/
public class XmppRosterEventProducer implements MessageSource<String> {
public Message<String> receive() {
// try {
// Thread.sleep(1000 * 10);
// }
// catch (InterruptedException e) {
// // eat it
// }
// return (Math.random() > .5) ? MessageBuilder.withPayload("available").setHeader(
// XmppHeaders.PRESENCE_MODE, Presence.Mode.chat)
// .setHeader(XmppHeaders.PRESENCE_STATUS, "She Loves me").build()
// : MessageBuilder.withPayload(StringUtils.EMPTY).setHeader(XmppHeaders.PRESENCE_MODE, Presence.Mode.dnd)
// .setHeader(XmppHeaders.PRESENCE_STATUS, "She Loves me not").build();
return null;
}
}

View File

@@ -34,6 +34,7 @@ import org.springframework.integration.xmpp.presence.XmppRosterEventMessageSendi
*/
public class XmppRosterEventMessageSendingHandlerTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testPresencePayload(){
XmppRosterEventMessageSendingHandler handler = new XmppRosterEventMessageSendingHandler(mock(XMPPConnection.class));
@@ -41,6 +42,7 @@ public class XmppRosterEventMessageSendingHandlerTests {
handler.handleMessage(new GenericMessage(mock(Presence.class)));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test(expected=MessageHandlingException.class)
public void testWrongPayload(){
XmppRosterEventMessageSendingHandler handler = new XmppRosterEventMessageSendingHandler(mock(XMPPConnection.class));

View File

@@ -1,93 +0,0 @@
/*
* Copyright 2002-2010 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 the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.xmpp.presence;
import static junit.framework.Assert.assertEquals;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.packet.Presence.Type;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.mapping.MessageMappingException;
import org.springframework.integration.support.MessageBuilder;
/**
* @author Oleg Zhurakousky
*
*/
public class XmppPresenceMessageMapperTests {
@Test
public void testFromMessageWithPayloadPresence() throws Exception{
// Presence presence = new Presence(Type.available, "Hello", 1, Mode.chat);
// Message<?> message = MessageBuilder.withPayload(presence).build();
// XmppPresenceMessageMapper mapper = new XmppPresenceMessageMapper();
// Presence mappedPresence = mapper.fromMessage(message);
// assertEquals(Mode.chat, mappedPresence.getMode());
// assertEquals(Type.available, mappedPresence.getType());
// assertEquals("Hello", mappedPresence.getStatus());
// assertEquals(1, mappedPresence.getPriority());
}
// @Test
// public void testFromMessageWithPayloadPresenceType() throws Exception{
// Message<?> message = MessageBuilder.withPayload(Type.available)
// .setHeader(XmppHeaders.PRESENCE_FROM, "oleg")
// .setHeader(XmppHeaders.PRESENCE_MODE, Mode.chat)
// .setHeader(XmppHeaders.PRESENCE_STATUS, "hello")
// .setHeader(XmppHeaders.PRESENCE_PRIORITY, 1)
// .build();
// XmppPresenceMessageMapper mapper = new XmppPresenceMessageMapper();
// Presence mappedPresence = mapper.fromMessage(message);
// assertEquals(Mode.chat, mappedPresence.getMode());
// assertEquals(Type.available, mappedPresence.getType());
// assertEquals("hello", mappedPresence.getStatus());
// assertEquals(1, mappedPresence.getPriority());
// }
// @Test
// public void testFromMessageWithPayloadPresenceTypeAndStringModeType() throws Exception{
// Message<?> message = MessageBuilder.withPayload(Type.available)
// .setHeader(XmppHeaders.PRESENCE_FROM, "oleg")
// .setHeader(XmppHeaders.PRESENCE_MODE, "chat")
// .setHeader(XmppHeaders.PRESENCE_STATUS, "hello")
// .setHeader(XmppHeaders.PRESENCE_PRIORITY, 1)
// .build();
// XmppPresenceMessageMapper mapper = new XmppPresenceMessageMapper();
// Presence mappedPresence = mapper.fromMessage(message);
// assertEquals(Mode.chat, mappedPresence.getMode());
// assertEquals(Type.available, mappedPresence.getType());
// assertEquals("hello", mappedPresence.getStatus());
// assertEquals(1, mappedPresence.getPriority());
// }
// @Test(expected=MessageMappingException.class)
// public void testFromMessageWithPayloadPresenceTypeUnsupportedMode() throws Exception{
//
// Message<?> message = MessageBuilder.withPayload(Type.available)
// .setHeader(XmppHeaders.PRESENCE_MODE, 1)
// .build();
// XmppPresenceMessageMapper mapper = new XmppPresenceMessageMapper();
// mapper.fromMessage(message);
// }
// @Test(expected=MessageMappingException.class)
// public void testFromMessageWithUnsupportedPayload() throws Exception{
// Message<?> message = MessageBuilder.withPayload("hello").build();
// XmppPresenceMessageMapper mapper = new XmppPresenceMessageMapper();
// mapper.fromMessage(message);
// }
}