mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-07 03:21:08 +01:00
Introduce Smack's Modular Connection Architecture
This is a complete redesign of what was previously XmppNioTcpConnection. The new architecture allows to extend an XMPP client to server (c2s) connection with new transport bindings and other extensions.
This commit is contained in:
parent
cec312fe64
commit
cc636fff21
142 changed files with 6819 additions and 4068 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2019 Florian Schmaus
|
||||
* Copyright 2015-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -26,12 +26,19 @@ import org.jivesoftware.smack.DummyConnection.DummyConnectionConfiguration;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
public class DummySmackIntegrationTestFramework extends SmackIntegrationTestFramework<DummyConnection> {
|
||||
public class DummySmackIntegrationTestFramework extends SmackIntegrationTestFramework {
|
||||
|
||||
public static final String DUMMY_CONNECTION_NICKNAME = "dummy";
|
||||
|
||||
static {
|
||||
try {
|
||||
XmppConnectionManager.addConnectionDescriptor(DummyConnection.class, DummyConnectionConfiguration.class);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
|
||||
XmppConnectionManager.addConnectionDescriptor(
|
||||
XmppConnectionDescriptor
|
||||
.buildWith(DummyConnection.class, DummyConnectionConfiguration.class)
|
||||
.withNickname(DUMMY_CONNECTION_NICKNAME)
|
||||
.build()
|
||||
);
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -39,15 +46,15 @@ public class DummySmackIntegrationTestFramework extends SmackIntegrationTestFram
|
|||
public DummySmackIntegrationTestFramework(Configuration configuration) throws KeyManagementException,
|
||||
InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
|
||||
NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException {
|
||||
super(configuration, DummyConnection.class);
|
||||
super(configuration);
|
||||
testRunResult = new TestRunResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SmackIntegrationTestEnvironment<DummyConnection> prepareEnvironment() {
|
||||
protected SmackIntegrationTestEnvironment prepareEnvironment() {
|
||||
DummyConnection dummyConnection = new DummyConnection();
|
||||
connectionManager.conOne = connectionManager.conTwo = connectionManager.conThree = dummyConnection;
|
||||
return new SmackIntegrationTestEnvironment<DummyConnection>(dummyConnection, dummyConnection, dummyConnection,
|
||||
return new SmackIntegrationTestEnvironment(dummyConnection, dummyConnection, dummyConnection,
|
||||
testRunResult.getTestRunId(), config, null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2017 Florian Schmaus
|
||||
* Copyright 2015-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -35,7 +35,9 @@ public class SmackIntegrationTestUnitTestUtil {
|
|||
Configuration configuration = Configuration.builder()
|
||||
.setService(JidTestUtil.DOMAIN_BARE_JID_1)
|
||||
.setUsernamesAndPassword("dummy1", "dummy1pass", "dummy2", "dummy2pass", "dummy3", "dummy3pass")
|
||||
.addEnabledTest(unitTest).build();
|
||||
.setDefaultConnection(DummySmackIntegrationTestFramework.DUMMY_CONNECTION_NICKNAME)
|
||||
.addEnabledTest(unitTest)
|
||||
.build();
|
||||
// @formatter:on
|
||||
try {
|
||||
return new DummySmackIntegrationTestFramework(configuration);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018-2019 Florian Schmaus
|
||||
* Copyright 2018-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -22,8 +22,9 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
||||
import org.jivesoftware.smack.tcp.XmppNioTcpConnection;
|
||||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection;
|
||||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
|
||||
import org.jivesoftware.smack.tcp.XmppTcpTransportModuleDescriptor;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
|
@ -34,11 +35,19 @@ public class SmackIntegrationTestXmppConnectionManagerTest {
|
|||
public void simpleXmppConnectionDescriptorTest() throws ClassNotFoundException, NoSuchMethodException,
|
||||
SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
|
||||
KeyManagementException, NoSuchAlgorithmException, XmppStringprepException, InstantiationException {
|
||||
XmppConnectionDescriptor<XmppNioTcpConnection, XMPPTCPConnectionConfiguration, XMPPTCPConnectionConfiguration.Builder> descriptor
|
||||
= new XmppConnectionDescriptor<>(XmppNioTcpConnection.class, XMPPTCPConnectionConfiguration.class);
|
||||
XmppConnectionDescriptor<
|
||||
ModularXmppClientToServerConnection,
|
||||
ModularXmppClientToServerConnectionConfiguration,
|
||||
ModularXmppClientToServerConnectionConfiguration.Builder
|
||||
> descriptor = XmppConnectionDescriptor.buildWith(
|
||||
ModularXmppClientToServerConnection.class,
|
||||
ModularXmppClientToServerConnectionConfiguration.class,
|
||||
ModularXmppClientToServerConnectionConfiguration.Builder.class)
|
||||
.applyExtraConfguration(b -> b.removeAllModules().addModule(XmppTcpTransportModuleDescriptor.class))
|
||||
.build();
|
||||
|
||||
Configuration sinttestConfiguration = Configuration.builder().setService("example.org").build();
|
||||
XmppNioTcpConnection connection = descriptor.construct(sinttestConfiguration);
|
||||
ModularXmppClientToServerConnection connection = descriptor.construct(sinttestConfiguration);
|
||||
|
||||
assertEquals("example.org", connection.getXMPPServiceDomain().toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
|||
|
||||
public static class ThrowsRuntimeExceptionDummyTest extends AbstractSmackIntegrationTest {
|
||||
|
||||
public ThrowsRuntimeExceptionDummyTest(SmackIntegrationTestEnvironment<?> environment) {
|
||||
public ThrowsRuntimeExceptionDummyTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
|||
|
||||
public static final String DESCRIPTIVE_TEXT = "I'm not fatal";
|
||||
|
||||
public ThrowsNonFatalExceptionDummyTest(SmackIntegrationTestEnvironment<?> environment) {
|
||||
public ThrowsNonFatalExceptionDummyTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
|||
|
||||
public static class BeforeAfterClassTest extends AbstractSmackIntegrationTest {
|
||||
|
||||
public BeforeAfterClassTest(SmackIntegrationTestEnvironment<?> environment) {
|
||||
public BeforeAfterClassTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue