-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b95a898
commit e9a49dc
Showing
2 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,40 @@ | |
import org.xmpp.packet.Packet; | ||
|
||
public class TestAgentCommunicationComponent { | ||
|
||
|
||
private Properties createProperties() { | ||
Properties prop = new Properties(); | ||
prop.put("xmpp.jid", "[email protected]"); | ||
prop.put("xmpp.password", "tellnoone"); | ||
prop.put("xmpp.host", "localhost"); | ||
prop.put("xmpp.port", "23"); | ||
prop.put("host.ip", "123.456.78.9"); | ||
prop.put("host.name", "host"); | ||
prop.put("host.macAddress", "A1:B2:C3:D4:E5:67"); | ||
return prop; | ||
} | ||
|
||
@Test | ||
public void testThreadTimeIsNotSetted() { | ||
Properties prop = createProperties(); | ||
AgentCommunicationComponent acc = new AgentCommunicationComponent(prop); | ||
Assert.assertEquals(60, acc.getThreadTime()); | ||
} | ||
|
||
@Test | ||
public void testThreadTimeIstSetted() { | ||
Properties prop = createProperties(); | ||
prop.put("green.threadTime", "50"); | ||
AgentCommunicationComponent acc = new AgentCommunicationComponent(prop); | ||
Assert.assertEquals(50, acc.getThreadTime()); | ||
} | ||
|
||
@Test | ||
public void testSendIamAliveSignal() { | ||
XMPPClient client = Mockito.mock(XMPPClient.class); | ||
Mockito.doReturn(Mockito.mock(XMPPConnection.class)).when(client) | ||
.getConnection(); | ||
Properties prop = new Properties(); | ||
prop.put("host.ip", "123.456.78.9"); | ||
prop.put("host.name", "host"); | ||
prop.put("host.macAddress", "A1:B2:C3:D4:E5:67"); | ||
Properties prop = createProperties(); | ||
AgentCommunicationComponent acc = | ||
new AgentCommunicationComponent(prop); | ||
acc.setClient(client); | ||
|
@@ -54,10 +78,8 @@ public void testInitConnectException() throws XMPPException { | |
public void testAccountAlreadyCreated () throws XMPPException { | ||
XMPPException e = new XMPPException(); | ||
XEP0077 register = Mockito.mock(XEP0077.class); | ||
Properties prop = new Properties(); | ||
prop.put("xmpp.jid", "[email protected]"); | ||
prop.put("xmpp.password", "tellnoone"); | ||
XMPPClient client = Mockito.mock(XMPPClient.class); | ||
Properties prop = createProperties(); | ||
; XMPPClient client = Mockito.mock(XMPPClient.class); | ||
Mockito.doReturn(Mockito.mock(XMPPConnection.class)).when(client).getConnection(); | ||
Mockito.doThrow(e).when(register).createAccount("[email protected]", "tellnoone"); | ||
AgentCommunicationComponent acc = new AgentCommunicationComponent(prop); | ||
|
@@ -165,6 +187,4 @@ public void testCallTurnOff() { | |
pl.processPacket(Mockito.mock(Packet.class)); | ||
Mockito.verify(turnOff).suspend(); | ||
} | ||
|
||
|
||
} |