protected static WebArchive getTckDeployment() { return getTckDeployment(new TestContext()); }
protected void enhance(TestContext context) { if (context.isSubdeployment() == false) { context.setArchiveName("ROOT.war"); context.setContextRoot(CapeDwarfContextRoot.INSTANCE); } }
private static <T extends TempData> T readTempData(Class<T> type, Entity entity, DatastoreService ds) throws Exception { markRead(entity, ds); return entityToTempData(entity, type, ds); }
protected static WebArchive getBytemanDeployment() { TestContext context = new TestContext(); context.setWebXmlFile("bm-web.xml"); context.setAppEngineWebXmlFile("bm-appengine-web.xml"); WebArchive war = getTckDeployment(context); war.addClass(BytemanTestBase.class); war.addClasses(ConcurrentTxServlet.class, Poke.class); return war; } }
protected static TestContext newTestContext() { return new TestContext(); }
protected Environment getEnvironment() { Environment env = instance(Environment.class); return (env != null) ? env : Environment.UNKNOWN; }
public static String getTestSystemProperty(String key) { return getTestSystemProperty(key, null); }
/** * Poll for data. * * @param type the temp data type * @param timeout timeout in seconds * @return data or null, if no such data in timeout period */ public <T extends TempData> T pollForTempData(Class<T> type, int timeout) { int secondsElapsed = 0; while (secondsElapsed <= timeout) { T data = getLastTempData(type); if (data != null) { return data; } sync(1000); secondsElapsed += 1; } return null; }
public <T extends TempData> T pollForTempData(Class<T> type, int timeout, TempDataFilter<T> filter) { int secondsElapsed = 0; while (secondsElapsed <= timeout) { List<T> list = getAllUnreadTempData(type); for (T t : list) { boolean accepted = filter.accept(t); if (accepted) { return t; } } sync(1000); secondsElapsed += 1; } return null; }
protected static Long readTimestamp(Class<?> clazz) { Object ts = readTimestampInternal(clazz); return (ts instanceof Long) ? (Long) ts : null; }
public static <T extends TempData> List<T> getAllUnreadTempData(Class<T> type) { return getAllTempData(type, true); }
protected static void sync() { sync(DEFAULT_SLEEP); }
@SuppressWarnings("deprecation") @Deprecated // use assumeEnvironment instead protected boolean execute(String context) { Boolean result = executeRaw(context); return (result != null && result); }
protected static <T extends TempData> String getKind(Class<T> type) { return type.getSimpleName() + readTimestamp(type); }
protected boolean required(String propertyName) { Property result = property(propertyName); Boolean required = result.required(); return (required == null || required); // by default null means it's required }
public static Environment getEnvironment(Class<?> testClass) { Environment env = instance(testClass, Environment.class); return (env != null) ? env : Environment.UNKNOWN; }
protected synchronized Long readTimestamp() { return readTimestampInternal(); }
public static <T extends TempData> List<T> getAllTempData(Class<T> type) { return getAllTempData(type, false); }
protected <T> T instance(Class<T> instanceType) { return instance(getClass(), instanceType); }
private Long readTimestampInternal() { if (timestamp != null) { return (timestamp instanceof Long) ? (Long) timestamp : null; } timestamp = readTimestampInternal(getClass()); return readTimestampInternal(); }