diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java index 256ea3fa2..351832fba 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java @@ -400,7 +400,7 @@ public class SmackIntegrationTestFramework { | Modifier.STATIC)); // See if there are any methods that have the @AfterClassAnnotation but a wrong signature - Set allAfterClassMethods = getAllMethods(testClass, withAnnotation(BeforeClass.class)); + Set allAfterClassMethods = getAllMethods(testClass, withAnnotation(AfterClass.class)); allAfterClassMethods.removeAll(afterClassMethods); if (!allAfterClassMethods.isEmpty()) { LOGGER.warning("@AfterClass methods with wrong signature found"); diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smack/ChatTest.java b/smack-integration-test/src/main/java/org/jivesoftware/smack/ChatTest.java index 0e17c5e76..f097d199f 100644 --- a/smack-integration-test/src/main/java/org/jivesoftware/smack/ChatTest.java +++ b/smack-integration-test/src/main/java/org/jivesoftware/smack/ChatTest.java @@ -55,12 +55,12 @@ public class ChatTest extends AbstractSmackIntegrationTest { } @BeforeClass - public void setUp() { + public static void setUp() { JivePropertiesManager.setJavaObjectEnabled(true); } @AfterClass - public void tearDown() { + public static void tearDown() { JivePropertiesManager.setJavaObjectEnabled(false); } diff --git a/smack-integration-test/src/test/java/org/igniterealtime/smack/inttest/unittest/SmackIntegrationTestFrameworkUnitTest.java b/smack-integration-test/src/test/java/org/igniterealtime/smack/inttest/unittest/SmackIntegrationTestFrameworkUnitTest.java index 831da5fce..e44395c74 100644 --- a/smack-integration-test/src/test/java/org/igniterealtime/smack/inttest/unittest/SmackIntegrationTestFrameworkUnitTest.java +++ b/smack-integration-test/src/test/java/org/igniterealtime/smack/inttest/unittest/SmackIntegrationTestFrameworkUnitTest.java @@ -18,6 +18,7 @@ package org.igniterealtime.smack.inttest.unittest; import static org.igniterealtime.smack.inttest.SmackIntegrationTestUnitTestUtil.getFrameworkForUnitTest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -35,6 +36,8 @@ import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.packet.XMPPError; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -44,6 +47,9 @@ public class SmackIntegrationTestFrameworkUnitTest { @Rule public ExpectedException expectedException = ExpectedException.none(); + private static boolean beforeClassInvoked; + private static boolean afterClassInvoked; + @Test public void throwsRuntimeExceptionsTest() throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException { @@ -95,4 +101,40 @@ public class SmackIntegrationTestFrameworkUnitTest { 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); + } + } }