Created
April 3, 2011 19:21
-
-
Save YoniTsafir/900694 to your computer and use it in GitHub Desktop.
Code Sheriff's Code Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ConditionTester { | |
boolean isTrue(); | |
} | |
public static void delayedAssert(ConditionTester tester, | |
long timeout, | |
long pollingInterval) | |
throws InterruptedException { | |
long startTime = System.currentTimeMillis(); | |
while (System.currentTimeMillis() - startTime < timeout) { | |
if (tester.isTrue()) { | |
return; | |
} | |
Thread.sleep(pollingInterval); | |
} | |
fail("Timeout passed and condition failed!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def testDevicePrettifierForAllLocalDevices(self): | |
dev_strings = get_all_device_strings() | |
for dev_str in dev_strings: | |
try: | |
device = Device.from_path(dev_str) | |
except DeviceAccessPermissionsError: | |
# Chained: a trick we made to raise nested exceptions in Python 2.x | |
raise chained(SkipTest("No permissions to file (are you root?)")) | |
dev_prettifier = DevicePrettifier(device) | |
print dev_str | |
print dev_prettifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringSerializer { | |
private DBSerializer dbDumper; | |
public StringSerializer(String tableName) throws SQLException { | |
Connection conn = ConnectionManager.instance().getAvailableConnection(); | |
dbDumper = new DBSerializer(conn, tableName); | |
} | |
public void serializeString(String str) throws DumpException { | |
dbDumper.dump(str); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringSerializer { | |
private Serializer dumper; | |
public StringSerializer(Serializer dumper) { | |
this.dumper = dumper; | |
} | |
public void serializeString(String str) throws DumpException { | |
dumper.dump(str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment