/** convenience for {@link #callerNiceClassAndMethod(int)} with depth 0 * <p> * useful for tests and other debug-facing log messages! */ public static String niceClassAndMethod() { return callerNiceClassAndMethod(0); }
public void other() { String result = JavaClassNames.callerNiceClassAndMethod(1); Assert.assertEquals(result, "JavaClassNamesCallerTest.testCallerIsYou"); }
private long timediff() { Long d1 = getRunTimeUtc(p1); Long d2 = getRunTimeUtc(p2); log.info("timestamps for "+JavaClassNames.callerNiceClassAndMethod(1)+" have difference "+(d2-d1)); return d2 - d1; }
String message = "Populating catalog for "+nodeState+", needsInitial="+needsInitialItemsLoaded+", needsAdditional="+needsAdditionsLoaded+", explicitItems="+(optionalExplicitItemsForResettingCatalog==null ? "null" : optionalExplicitItemsForResettingCatalog.size())+"; from "+JavaClassNames.callerNiceClassAndMethod(1); if (!ManagementNodeState.isHotProxy(nodeState)) { log.debug(message);
private void checkValidArchive(String url, long minSize) { byte[] bytes; try { bytes = Streams.readFullyAndClose(ResourceUtils.create(this).getResourceFromUrl(url)); log.info("read "+bytes.length+" bytes from "+url+" for "+JavaClassNames.callerNiceClassAndMethod(1)); } catch (Exception e) { log.warn("Unable to read URL "+url+" for " +JavaClassNames.callerNiceClassAndMethod(1)+ "; this test may require hosted (sonatype/mavencentral) repo to be populated"); Assert.fail("Unable to read URL "+url+"; this test may require hosted (sonatype/mavencentral) repo to be populated"); throw Exceptions.propagate(e); } // confirm this follow redirects! Assert.assertTrue(bytes.length > minSize, "download of "+url+" is suspect ("+Strings.makeSizeString(bytes.length)+")"); // (could also check it is a zip etc) }
protected EntitySpec<BrooklynNode> newBrooklynNodeSpecForTest() { // poor man's way to output which test is running log.info("Creating entity spec for "+JavaClassNames.callerNiceClassAndMethod(1)); return EntitySpec.create(BrooklynNode.class) .configure(BrooklynNode.WEB_CONSOLE_BIND_ADDRESS, Networking.ANY_NIC) .configure(BrooklynNode.ON_EXISTING_PROPERTIES_FILE, ExistingFileBehaviour.DO_NOT_USE); /* yaml equivalent, for testing: location: localhost services: - type: org.apache.brooklyn.entity.brooklynnode.BrooklynNode bindAddress: 127.0.0.1 onExistingProperties: do_not_use # some other options enabledHttpProtocols: [ https ] managementPassword: s3cr3t brooklynLocalPropertiesContents: | brooklyn.webconsole.security.https.required=true brooklyn.webconsole.security.users=admin brooklyn.webconsole.security.user.admin.password=s3cr3t brooklyn.location.localhost.enabled=false */ }
private void prep(ChildStartableMode mode) { String parentCmd = "echo utc `date +%s` > DATE ; echo human `date` >> DATE ; " + "{ nohup sleep 60 & } ; echo $! > $PID_FILE ; sleep "+PARENT_TASK_SLEEP_LENGTH_SECS; String childCmd = "echo utc `date +%s` > DATE ; echo human `date` >> DATE ; " + "{ nohup sleep 60 & } ; echo $! > $PID_FILE ; sleep "+CHILD_TASK_SLEEP_LENGTH_SECS; p1 = app.createAndManageChild(EntitySpec.create(VanillaSoftwareProcess.class) .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, parentCmd) .configure(VanillaSoftwareProcess.CHILDREN_STARTABLE_MODE, mode) ); p2 = p1.addChild(EntitySpec.create(VanillaSoftwareProcess.class) .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, childCmd)); log.info("testing "+JavaClassNames.callerNiceClassAndMethod(1)+", using "+p1+" and "+p2); }