mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 10:19:41 +02:00
gradle: Remove archives configuration
and FileTestUtil in favor of commons-io. This is required because Eclipse won't put src/test code into the classpath of src/main code (even though gradle was configured with an according dependency).
This commit is contained in:
parent
89cb3f679b
commit
2f667f95a8
18 changed files with 30 additions and 114 deletions
|
@ -14,9 +14,9 @@ dependencies {
|
|||
compile project(':smack-omemo')
|
||||
compile project(':smack-openpgp')
|
||||
compile project(':smack-debug')
|
||||
compile project(path: ":smack-omemo", configuration: "testRuntime")
|
||||
compile 'org.reflections:reflections:0.9.11'
|
||||
compile 'eu.geekplace.javapinning:java-pinning-java7:1.1.0-alpha1'
|
||||
compile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"
|
||||
// Note that the junit-vintage-engine runtime dependency is not
|
||||
// directly required, but it declares a dependency to
|
||||
// junit:junit:4.12, which we currently need in sinttest, since it
|
||||
|
@ -25,6 +25,7 @@ dependencies {
|
|||
compile 'junit:junit:4.12'
|
||||
// Add Junit 5 API for e.g. assertThrows()
|
||||
implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||
testCompile project(path: ":smack-core", configuration: "testRuntime")
|
||||
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 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.jivesoftware.smackx.omemo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoTrustCallback;
|
||||
import org.jivesoftware.smackx.omemo.trust.TrustState;
|
||||
|
||||
/**
|
||||
* Ephemera Trust Callback used to make trust decisions in tests.
|
||||
*/
|
||||
public class EphemeralTrustCallback implements OmemoTrustCallback {
|
||||
|
||||
private final HashMap<OmemoDevice, HashMap<OmemoFingerprint, TrustState>> trustStates = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public TrustState getTrust(OmemoDevice device, OmemoFingerprint fingerprint) {
|
||||
HashMap<OmemoFingerprint, TrustState> states = trustStates.get(device);
|
||||
|
||||
if (states != null) {
|
||||
TrustState state = states.get(fingerprint);
|
||||
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
return TrustState.undecided;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrust(OmemoDevice device, OmemoFingerprint fingerprint, TrustState state) {
|
||||
HashMap<OmemoFingerprint, TrustState> states = trustStates.get(device);
|
||||
|
||||
if (states == null) {
|
||||
states = new HashMap<>();
|
||||
trustStates.put(device, states);
|
||||
}
|
||||
|
||||
states.put(fingerprint, state);
|
||||
}
|
||||
}
|
|
@ -33,7 +33,6 @@ import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
|||
import org.jivesoftware.smackx.omemo.internal.OmemoCachedDeviceList;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.util.EphemeralTrustCallback;
|
||||
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.logging.Level;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.test.util.FileTestUtil;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.ox.callback.backup.AskForBackupCodeCallback;
|
||||
import org.jivesoftware.smackx.ox.callback.backup.DisplayBackupCodeCallback;
|
||||
|
@ -63,8 +62,9 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
|||
public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegrationTest {
|
||||
|
||||
private static final String sessionId = StringUtils.randomString(10);
|
||||
private static final File beforePath = FileTestUtil.getTempDir("ox_backup_" + sessionId);
|
||||
private static final File afterPath = FileTestUtil.getTempDir("ox_restore_" + sessionId);
|
||||
private static final File tempDir = org.apache.commons.io.FileUtils.getTempDirectory();
|
||||
private static final File beforePath = new File(tempDir, "ox_backup_" + sessionId);
|
||||
private static final File afterPath = new File(tempDir, "ox_restore_" + sessionId);
|
||||
|
||||
private String backupCode = null;
|
||||
|
||||
|
@ -108,10 +108,10 @@ public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegration
|
|||
|
||||
@AfterClass
|
||||
@BeforeClass
|
||||
public static void cleanStore() {
|
||||
public static void cleanStore() throws IOException {
|
||||
LOGGER.log(Level.INFO, "Delete store directories...");
|
||||
FileTestUtil.deleteDirectory(afterPath);
|
||||
FileTestUtil.deleteDirectory(beforePath);
|
||||
org.apache.commons.io.FileUtils.deleteDirectory(afterPath);
|
||||
org.apache.commons.io.FileUtils.deleteDirectory(beforePath);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -20,12 +20,12 @@ import static junit.framework.TestCase.assertFalse;
|
|||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.FileTestUtil;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.ox.AbstractOpenPgpIntegrationTest;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpContact;
|
||||
|
@ -49,8 +49,9 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
|||
public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegrationTest {
|
||||
|
||||
private static final String sessionId = StringUtils.randomString(10);
|
||||
private static final File aliceStorePath = FileTestUtil.getTempDir("basic_ox_messaging_test_alice_" + sessionId);
|
||||
private static final File bobStorePath = FileTestUtil.getTempDir("basic_ox_messaging_test_bob_" + sessionId);
|
||||
private static final File tempDir = org.apache.commons.io.FileUtils.getTempDirectory();
|
||||
private static final File aliceStorePath = new File(tempDir, "basic_ox_messaging_test_alice_" + sessionId);
|
||||
private static final File bobStorePath = new File(tempDir, "basic_ox_messaging_test_bob_" + sessionId);
|
||||
|
||||
private OpenPgpV4Fingerprint aliceFingerprint = null;
|
||||
private OpenPgpV4Fingerprint bobFingerprint = null;
|
||||
|
@ -95,10 +96,10 @@ public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegratio
|
|||
|
||||
@BeforeClass
|
||||
@AfterClass
|
||||
public static void deleteStore() {
|
||||
public static void deleteStore() throws IOException {
|
||||
LOGGER.log(Level.INFO, "Deleting storage directories...");
|
||||
FileTestUtil.deleteDirectory(aliceStorePath);
|
||||
FileTestUtil.deleteDirectory(bobStorePath);
|
||||
org.apache.commons.io.FileUtils.deleteDirectory(aliceStorePath);
|
||||
org.apache.commons.io.FileUtils.deleteDirectory(bobStorePath);
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue