Skip to content

Instantly share code, notes, and snippets.

@bdeggleston
Created April 10, 2019 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdeggleston/5622fcf30d31b42619868eacfed647f9 to your computer and use it in GitHub Desktop.
Save bdeggleston/5622fcf30d31b42619868eacfed647f9 to your computer and use it in GitHub Desktop.
/* BMSanityCheckTests.java */
package org.apache.cassandra;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.jboss.byteman.contrib.bmunit.BMRule;
import org.jboss.byteman.contrib.bmunit.BMRules;
import org.jboss.byteman.contrib.bmunit.BMUnitConfig;
import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
@RunWith(BMUnitRunner.class)
public class BMSanityCheckTest
{
@Test
@BMUnitConfig(debug = true, verbose = true, bmunitVerbose = true)
@BMRules(rules = {@BMRule (name="rule",
targetClass = "org.apache.cassandra.BMSanityHelper",
targetMethod = "doSomething",
targetLocation = "AT ENTRY",
action = "org.apache.cassandra.BMSanityHelper.ack()" )})
public void name()
{
BMSanityHelper helper = new BMSanityHelper();
Assert.assertFalse(helper.wasAcked);
helper.doSomething();
Assert.assertTrue(helper.wasAcked);
}
}
/* BMSanityHelper.java */
package org.apache.cassandra;
public class BMSanityHelper
{
static boolean wasAcked = false;
static void ack()
{
System.out.println("ack");
wasAcked = true;
}
void doSomething()
{
System.out.println("something");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment