broker/test/ServerIntegrationDBAuthenticatorTest: code formatter used
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package io.moquette.server;
|
package io.moquette.server;
|
||||||
|
|
||||||
import io.moquette.BrokerConstants;
|
import io.moquette.BrokerConstants;
|
||||||
@@ -10,19 +11,18 @@ import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence;
|
|||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mackristof on 13/05/2016.
|
* Created by mackristof on 13/05/2016.
|
||||||
*/
|
*/
|
||||||
public class ServerIntegrationDBAuthenticatorTest {
|
public class ServerIntegrationDBAuthenticatorTest {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationDBAuthenticatorTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationDBAuthenticatorTest.class);
|
||||||
|
|
||||||
static MqttClientPersistence s_dataStore;
|
static MqttClientPersistence s_dataStore;
|
||||||
@@ -35,8 +35,6 @@ public class ServerIntegrationDBAuthenticatorTest {
|
|||||||
MessageCollector m_messagesCollector;
|
MessageCollector m_messagesCollector;
|
||||||
IConfig m_config;
|
IConfig m_config;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeTests() throws NoSuchAlgorithmException, SQLException, ClassNotFoundException {
|
public static void beforeTests() throws NoSuchAlgorithmException, SQLException, ClassNotFoundException {
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||||
@@ -53,7 +51,6 @@ public class ServerIntegrationDBAuthenticatorTest {
|
|||||||
m_server.startServer(m_config);
|
m_server.startServer(m_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void stopServer() {
|
private void stopServer() {
|
||||||
m_server.stopServer();
|
m_server.stopServer();
|
||||||
IntegrationUtils.cleanPersistenceFile(m_config);
|
IntegrationUtils.cleanPersistenceFile(m_config);
|
||||||
@@ -96,7 +93,7 @@ public class ServerIntegrationDBAuthenticatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void shutdown(){
|
public static void shutdown() {
|
||||||
dbAuthenticatorTest.teardown();
|
dbAuthenticatorTest.teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,9 +108,8 @@ public class ServerIntegrationDBAuthenticatorTest {
|
|||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectWithWrongCredentials() {
|
public void connectWithWrongCredentials() {
|
||||||
LOG.info("*** connectWithWrongCredentials ***");
|
LOG.info("*** connectWithWrongCredentials ***");
|
||||||
try {
|
try {
|
||||||
m_client = new MqttClient("tcp://localhost:1883", "Publisher", s_pubDataStore);
|
m_client = new MqttClient("tcp://localhost:1883", "Publisher", s_pubDataStore);
|
||||||
@@ -121,18 +117,16 @@ public class ServerIntegrationDBAuthenticatorTest {
|
|||||||
options.setUserName("dbuser");
|
options.setUserName("dbuser");
|
||||||
options.setPassword("wrongPassword".toCharArray());
|
options.setPassword("wrongPassword".toCharArray());
|
||||||
m_client.connect(options);
|
m_client.connect(options);
|
||||||
} catch (MqttException e){
|
} catch (MqttException e) {
|
||||||
if (e instanceof MqttSecurityException) {
|
if (e instanceof MqttSecurityException) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
assertTrue(e.getMessage(),false);
|
assertTrue(e.getMessage(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("must not be connected. cause : wrong password given to client",false);
|
assertTrue("must not be connected. cause : wrong password given to client", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user