mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 08:12:05 +01:00
Fix for getting after method
This commit is contained in:
parent
9d0ea3cf70
commit
75e35e8db6
3 changed files with 45 additions and 3 deletions
|
@ -400,7 +400,7 @@ public class SmackIntegrationTestFramework {
|
||||||
| Modifier.STATIC));
|
| Modifier.STATIC));
|
||||||
|
|
||||||
// See if there are any methods that have the @AfterClassAnnotation but a wrong signature
|
// See if there are any methods that have the @AfterClassAnnotation but a wrong signature
|
||||||
Set<Method> allAfterClassMethods = getAllMethods(testClass, withAnnotation(BeforeClass.class));
|
Set<Method> allAfterClassMethods = getAllMethods(testClass, withAnnotation(AfterClass.class));
|
||||||
allAfterClassMethods.removeAll(afterClassMethods);
|
allAfterClassMethods.removeAll(afterClassMethods);
|
||||||
if (!allAfterClassMethods.isEmpty()) {
|
if (!allAfterClassMethods.isEmpty()) {
|
||||||
LOGGER.warning("@AfterClass methods with wrong signature found");
|
LOGGER.warning("@AfterClass methods with wrong signature found");
|
||||||
|
|
|
@ -55,12 +55,12 @@ public class ChatTest extends AbstractSmackIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void setUp() {
|
public static void setUp() {
|
||||||
JivePropertiesManager.setJavaObjectEnabled(true);
|
JivePropertiesManager.setJavaObjectEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void tearDown() {
|
public static void tearDown() {
|
||||||
JivePropertiesManager.setJavaObjectEnabled(false);
|
JivePropertiesManager.setJavaObjectEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.igniterealtime.smack.inttest.unittest;
|
||||||
|
|
||||||
import static org.igniterealtime.smack.inttest.SmackIntegrationTestUnitTestUtil.getFrameworkForUnitTest;
|
import static org.igniterealtime.smack.inttest.SmackIntegrationTestUnitTestUtil.getFrameworkForUnitTest;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,6 +36,8 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
@ -44,6 +47,9 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
|
private static boolean beforeClassInvoked;
|
||||||
|
private static boolean afterClassInvoked;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void throwsRuntimeExceptionsTest() throws KeyManagementException, NoSuchAlgorithmException, SmackException,
|
public void throwsRuntimeExceptionsTest() throws KeyManagementException, NoSuchAlgorithmException, SmackException,
|
||||||
IOException, XMPPException, InterruptedException {
|
IOException, XMPPException, InterruptedException {
|
||||||
|
@ -95,4 +101,40 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
||||||
XMPPError.from(XMPPError.Condition.bad_request, DESCRIPTIVE_TEXT));
|
XMPPError.from(XMPPError.Condition.bad_request, DESCRIPTIVE_TEXT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvoking() throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException,
|
||||||
|
XMPPException, InterruptedException {
|
||||||
|
beforeClassInvoked = false;
|
||||||
|
afterClassInvoked = false;
|
||||||
|
|
||||||
|
DummySmackIntegrationTestFramework sinttest = getFrameworkForUnitTest(BeforeAfterClassTest.class);
|
||||||
|
sinttest.run();
|
||||||
|
|
||||||
|
assertTrue("A before class method should have been executed to this time", beforeClassInvoked);
|
||||||
|
assertTrue("A after class method should have been executed to this time", afterClassInvoked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BeforeAfterClassTest extends AbstractSmackIntegrationTest {
|
||||||
|
|
||||||
|
public BeforeAfterClassTest(SmackIntegrationTestEnvironment environment) {
|
||||||
|
super(environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() {
|
||||||
|
beforeClassInvoked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDown() {
|
||||||
|
afterClassInvoked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SmackIntegrationTest
|
||||||
|
public void test() {
|
||||||
|
assertTrue("A before class method should have been executed to this time", beforeClassInvoked);
|
||||||
|
assertFalse("A after class method shouldn't have been executed to this time", afterClassInvoked);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue