@Override public String toString() { return JavaClassNames.cleanSimpleClassName(this); } }
@Override public String toString() { return JavaClassNames.cleanSimpleClassName(this)+"["+JavaClassNames.cleanSimpleClassName(type)+" "+value+"]"; } }
@Override public String toString() { return JavaClassNames.cleanSimpleClassName(this)+"["+kind+","+expectedSuperType+","+encounteredTypes+"]"; } }
/** For {@link Throwable} instances where know {@link #isPrefixRequiredForMessageToMakeSense(Throwable)}, * this returns a nice message for use as a prefix; * returns empty string if {@link #isPrefixBoring(Throwable)} is true; * otherwise this returns the simplified class name. */ private static String getPrefixText(Throwable t) { if (t instanceof NoClassDefFoundError) return "Invalid java type"; if (isPrefixBoring(t)) return ""; return JavaClassNames.cleanSimpleClassName(t); }
/** as {@link #newTempFile(String, String)} using the class as the basis for a prefix */ public static File newTempFile(Class<?> clazz, String ext) { return newTempFile(JavaClassNames.cleanSimpleClassName(clazz), ext); }
/** as {@link #newTempDir(String)}, using the class as the basis for a prefix */ public static File newTempDir(Class<?> clazz) { return newTempDir(JavaClassNames.cleanSimpleClassName(clazz)); }
protected Entity loadEntityMemento(String label, String entityId) throws Exception { String mementoResourceName = JavaClassNames.cleanSimpleClassName(this) + "-" + label + "-entity-" + entityId+".memento"; String memento = Streams.readFullyString(getClass().getResourceAsStream(mementoResourceName)); File persistedEntityFile = new File(mementoDir, Os.mergePaths("entities", entityId)); Files.write(memento.getBytes(), persistedEntityFile); return newApp = rebind(); }
/** Method to facilitate creation of memento files */ private void createMemento() throws Exception { setUp(); origApp = super.createApp(); // edit this, run this class's main method, then use the log output for your test case origApp.config().set(TEST_KEY, new VersionedName("foo", Version.parseVersion("1.0.0.foo"))); RebindTestUtils.stopPersistence(origApp); String fn = mementoDir + File.separator + "entities" + File.separator + origApp.getApplicationId(); log.info("Persisted to "+fn); String yyyyMM = Time.makeDateString(new Date(), "yyyy-MM"); log.info("Set up your tests by copying from the persistence dir "+mementoDir+"\n\n"+ "cp "+fn+" "+ "src/test/resources/"+getClass().getPackage().getName().replaceAll("\\.", "/")+"/"+ JavaClassNames.cleanSimpleClassName(this)+"-"+yyyyMM+"-entity-"+origApp.getApplicationId()+".memento\n"); String content = Streams.readFullyString(new FileInputStream(new File(fn))); log.info("Or paste the following contents there:\n"+content); log.info("Then add the apache comment header there, and write your test doing loadEntityMemento(\""+yyyyMM+"\", \""+origApp.getApplicationId()+"\")"); }
@Override protected ManagementContext newPersistingManagementContext() { mementoDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this)); Os.deleteOnExitRecursively(mementoDir); return RebindTestUtils.managementContextBuilder(classLoader, new FileBasedObjectStore(mementoDir)) .persistPeriod(Duration.millis(10)).buildStarted(); }