mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-07 19:41:11 +01:00
Rename smack-java8(-full) to smack-java11(-full)
To denote that Smack now requires at least Java 11 to run. Fixes SMACK-953.
This commit is contained in:
parent
5d2ca5d7d3
commit
07d9d694da
28 changed files with 15 additions and 15 deletions
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2021 Florian Schmaus
|
||||
*
|
||||
* 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.jivesoftware.smack.full;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmppElementUtil;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
|
||||
public class ExtensionElementQNameDeclaredTest {
|
||||
|
||||
@Test
|
||||
public void qnameOrElementNamespaceDeclaredTest() {
|
||||
String[] smackPackages = new String[] {
|
||||
"org.jivesoftware.smack",
|
||||
"org.igniterealtime.smack",
|
||||
};
|
||||
Reflections reflections = new Reflections(smackPackages, new SubTypesScanner());
|
||||
Set<Class<? extends ExtensionElement>> extensionElementClasses = reflections.getSubTypesOf(
|
||||
ExtensionElement.class);
|
||||
|
||||
Map<Class<? extends ExtensionElement>, IllegalArgumentException> exceptions = new HashMap<>();
|
||||
for (Class<? extends ExtensionElement> extensionElementClass : extensionElementClasses) {
|
||||
if (Modifier.isAbstract(extensionElementClass.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
XmppElementUtil.getQNameFor(extensionElementClass);
|
||||
} catch (IllegalArgumentException e) {
|
||||
exceptions.put(extensionElementClass, e);
|
||||
}
|
||||
}
|
||||
|
||||
Set<Class<? extends ExtensionElement>> failedClasses = exceptions.keySet();
|
||||
|
||||
assertThat(failedClasses).withFailMessage("The following " + failedClasses.size()
|
||||
+ " classes are missing QNAME declaration: " + failedClasses).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020-2021 Florian Schmaus
|
||||
*
|
||||
* 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.jivesoftware.smack.full;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
|
||||
import org.jivesoftware.smack.compression.CompressionModuleDescriptor;
|
||||
import org.jivesoftware.smack.util.EqualsUtil;
|
||||
import org.jivesoftware.smack.util.HashCode;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.jgrapht.graph.DefaultEdge;
|
||||
import org.jgrapht.graph.DirectedPseudograph;
|
||||
import org.jgrapht.io.DOTImporter;
|
||||
import org.jgrapht.io.ImportException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
public class ModularXmppClientToServerConnectionStateGraphTest {
|
||||
|
||||
@Test
|
||||
public void testStateGraphDotOutput() throws IOException, ImportException {
|
||||
URL stateGraphDotFileUrl = Resources.getResource("state-graph.dot");
|
||||
String expectedStateGraphDot = Resources.toString(stateGraphDotFileUrl, StandardCharsets.UTF_8);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
ModularXmppClientToServerConnectionTool.printStateGraph(pw, false);
|
||||
String currentStateGraphDot = sw.toString();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
DOTImporter<String, DefaultEdge> dotImporter = new DOTImporter<>(
|
||||
(id, attributes) -> id,
|
||||
(from, to, label, attributes) -> {
|
||||
return new DefaultEdge() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return HashCode.builder()
|
||||
.append(getSource())
|
||||
.append(getTarget())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return EqualsUtil.equals(this, other, (b, o) ->
|
||||
b.append(getSource(), o.getSource())
|
||||
.append(getTarget(), o.getTarget())
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
DirectedPseudograph<String, DefaultEdge> currentStateGraph = new DirectedPseudograph<>(DefaultEdge.class);
|
||||
DirectedPseudograph<String, DefaultEdge> expectedStateGraph = new DirectedPseudograph<>(DefaultEdge.class);
|
||||
|
||||
dotImporter.importGraph(expectedStateGraph, new StringReader(expectedStateGraphDot));
|
||||
dotImporter.importGraph(currentStateGraph, new StringReader(currentStateGraphDot));
|
||||
|
||||
assertEquals(expectedStateGraph, currentStateGraph);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoUnknownStates() throws XmppStringprepException {
|
||||
ModularXmppClientToServerConnectionConfiguration.builder()
|
||||
.setUsernameAndPassword("user", "password")
|
||||
.setXmppDomain("example.org")
|
||||
.failOnUnknownStates() // This is the actual option that enableds this test.
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void throwsOnUnknownStates() throws XmppStringprepException {
|
||||
assertThrows(IllegalStateException.class, () ->
|
||||
ModularXmppClientToServerConnectionConfiguration.builder()
|
||||
.setUsernameAndPassword("user", "password")
|
||||
.setXmppDomain("example.org")
|
||||
.removeModule(CompressionModuleDescriptor.class)
|
||||
.failOnUnknownStates() // This is the actual option that enableds this test.
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
38
smack-java11-full/src/test/resources/state-graph.dot
Normal file
38
smack-java11-full/src/test/resources/state-graph.dot
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
digraph {
|
||||
"Disconnected" -> "LookupRemoteConnectionEndpoints";
|
||||
"LookupRemoteConnectionEndpoints" -> "EstablishingTcpConnection" [xlabel="1"];
|
||||
"EstablishingTcpConnection" -> "EstablishTls (RFC 6120 § 5)" [xlabel="1"];
|
||||
"EstablishTls (RFC 6120 § 5)" -> "ConnectedButUnauthenticated";
|
||||
"ConnectedButUnauthenticated" -> "Bind2 (XEP-0386)" [xlabel="1"];
|
||||
"Bind2 (XEP-0386)" -> "AuthenticatedAndResourceBound";
|
||||
"AuthenticatedAndResourceBound" -> "Shutdown" [xlabel="1"];
|
||||
"Shutdown" -> "CloseConnection";
|
||||
"CloseConnection" -> "Disconnected";
|
||||
"AuthenticatedAndResourceBound" -> "InstantShutdown" [xlabel="2"];
|
||||
"InstantShutdown" -> "CloseConnection";
|
||||
"AuthenticatedAndResourceBound" [ style=filled ]
|
||||
"Bind2 (XEP-0386)" [ style=dashed ]
|
||||
"ConnectedButUnauthenticated" -> "InstantStreamResumption (XEP-0397)" [xlabel="2"];
|
||||
"InstantStreamResumption (XEP-0397)" -> "AuthenticatedAndResourceBound";
|
||||
"InstantStreamResumption (XEP-0397)" [ style=dashed ]
|
||||
"ConnectedButUnauthenticated" -> "SaslAuthentication (RFC 6120 § 6)" [xlabel="3"];
|
||||
"SaslAuthentication (RFC 6120 § 6)" -> "AuthenticatedButUnbound";
|
||||
"AuthenticatedButUnbound" -> "Compression (XEP-0138)" [xlabel="1"];
|
||||
"Compression (XEP-0138)" -> "AuthenticatedButUnbound";
|
||||
"AuthenticatedButUnbound" -> "ResumeStream (XEP-0198)" [xlabel="2"];
|
||||
"ResumeStream (XEP-0198)" -> "AuthenticatedAndResourceBound";
|
||||
"ResumeStream (XEP-0198)" [ style=dashed ]
|
||||
"AuthenticatedButUnbound" -> "ResourceBinding (RFC 6120 § 7)" [xlabel="3"];
|
||||
"ResourceBinding (RFC 6120 § 7)" -> "EnableStreamManagement (XEP-0198)" [xlabel="1"];
|
||||
"EnableStreamManagement (XEP-0198)" -> "AuthenticatedAndResourceBound";
|
||||
"EnableStreamManagement (XEP-0198)" [ style=dashed ]
|
||||
"ResourceBinding (RFC 6120 § 7)" -> "AuthenticatedAndResourceBound" [xlabel="2"];
|
||||
"AuthenticatedButUnbound" [ style=bold ]
|
||||
"ConnectedButUnauthenticated" -> "Shutdown" [xlabel="4"];
|
||||
"ConnectedButUnauthenticated" -> "InstantShutdown" [xlabel="5"];
|
||||
"ConnectedButUnauthenticated" [ style=filled ]
|
||||
"EstablishingTcpConnection" -> "ConnectedButUnauthenticated" [xlabel="2"];
|
||||
"LookupRemoteConnectionEndpoints" -> "EstablishingWebSocketConnection" [xlabel="2"];
|
||||
"EstablishingWebSocketConnection" -> "ConnectedButUnauthenticated";
|
||||
"Disconnected" [ style=filled ]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue