本文整理了Java中org.apache.brooklyn.util.text.Strings.lines()
方法的一些代码示例,展示了Strings.lines()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.lines()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.text.Strings
类名称:Strings
方法名:lines
[英]convenience for joining lines together
[中]方便将线路连接在一起
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** convenience for joining lines together */
public static String lines(String ...lines) {
if (lines==null) return null;
return lines(Arrays.asList(lines));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public static String removeLines(String multiline, Predicate<CharSequence> patternToRemove) {
if (multiline==null) return null;
return lines(Iterables.filter(Arrays.asList(multiline.split("\n")), Predicates.not(patternToRemove)));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
static String bomForLegacySiblingLibraries() {
return Strings.lines("brooklyn.catalog:",
" bundle: test-items",
" version: 2.0-test_java",
" items:",
" - scanJavaAnnotations: true",
" item:",
" id: here-item",
" type: "+OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
" libraries:",
" - classpath://" + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH,
" - classpath://" + OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
static String bomAnonymous() {
return Strings.lines("brooklyn.catalog:",
" items:",
" - item:",
" id: sample",
" type: "+BasicEntity.class.getName());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testLines() {
Assert.assertEquals(Strings.lines("a", "b"), "a\nb");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** Returns the original YAML with the found item replaced by the given replacement YAML.
* @param replacement YAML to put in for the found item;
* this YAML typically should not have any special indentation -- if required when replacing it will be inserted.
* <p>
* if replacing an inline map entry, the supplied entry must follow the structure being replaced;
* for example, if replacing the value in <code>key: value</code> with a map,
* supplying a replacement <code>subkey: value</code> would result in invalid yaml;
* the replacement must be supplied with a newline, either before the subkey or after.
* (if unsure we believe it is always valid to include an initial newline or comment with newline.)
*/
public String getFullYamlTextWithExtractReplaced(String replacement) {
if (!found()) throw new IllegalStateException("Cannot perform replacement when item was not matched.");
String result = yaml.substring(0, getStartOfThis());
String[] newLines = replacement.split("\n");
for (int i=1; i<newLines.length; i++)
newLines[i] = Strings.makePaddedString("", getStartColumnOfThis(), "", " ") + newLines[i];
result += Strings.lines(newLines);
if (replacement.endsWith("\n")) result += "\n";
int end = getEndOfThis();
result += yaml.substring(end);
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testRemoveLines() {
Assert.assertEquals(Strings.removeLines(Strings.lines("a", "b"), StringPredicates.containsLiteralIgnoreCase("A")), "b");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testDeleteEmptyBundleRemovedFromPersistence() throws Exception {
recreateOrigManagementContextWithOsgi();
String bom = Strings.lines(
"brooklyn.catalog:",
" itemType: entity",
" items:",
" - id: sample",
" item:",
" type: " + BasicEntity.class.getName());
addCatalogItems(bom);
addCatalogItems(bom);
rebind();
// should only contain one bundle / bundle.jar pair
Asserts.assertSize(Arrays.asList( new File(mementoDir, "bundles").list() ), 2);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
static void installJavaScanningMoreEntitiesV2(ManagementContext mgmt, Object context) throws FileNotFoundException {
// scanning bundle functionality added in 0.12.0, relatively new compared to non-osgi scanning
TestResourceUnavailableException.throwIfResourceUnavailable(context.getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
TestResourceUnavailableException.throwIfResourceUnavailable(context.getClass(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
CampYamlLiteTest.installWithoutCatalogBom(mgmt, OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
BundleMaker bm = new BundleMaker(mgmt);
File f = Os.newTempFile(context.getClass(), "jar");
Streams.copy(ResourceUtils.create(context).getResourceFromUrl(OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_V2_PATH), new FileOutputStream(f));
f = bm.copyRemoving(f, MutableSet.of("catalog.bom"));
f = bm.copyAdding(f, MutableMap.of(new ZipEntry("catalog.bom"),
new ByteArrayInputStream( Strings.lines(
"brooklyn.catalog:",
" scanJavaAnnotations: true").getBytes() ) ));
((ManagementContextInternal)mgmt).getOsgiManager().get().install(new FileInputStream(f)).checkNoError();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testCatalogBomLoadsFileInBundle() throws Exception {
bm.setDefaultClassForLoading(getClass());
File jf = bm.createJarFromClasspathDir("osgi/catalog-bundle-1");
// add a file in the bundle
String customText = "Sample data "+Identifiers.makeRandomId(4);
jf = bm.copyAdding(jf, MutableMap.of(
new ZipEntry("sample.txt"), (InputStream) new ByteArrayInputStream(customText.getBytes())));
installBundle(jf);
String yaml = Strings.lines("name: simple-app-yaml",
"services:",
"- type: " + "basic1",
" brooklyn.initializers:",
" - type: "+GetFileContentsEffector.class.getName());
Entity app = createAndStartApplication(yaml);
Entity basic1 = Iterables.getOnlyElement( app.getChildren() );
// check the file put in the bundle gets loaded without needing to do anything special
String contents = basic1.invoke(GetFileContentsEffector.GET_FILE_CONTENTS, MutableMap.of(GetFileContentsEffector.FILENAME.getName(), "classpath://sample.txt")).get();
Asserts.assertEquals(contents, customText);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups={"Integration", "Broken"})
public void testAuthenticationAndHttps() throws Exception {
String adminPassword = "p4ssw0rd";
BrooklynNode brooklynNode = app.createAndManageChild(newBrooklynNodeSpecForTest()
.configure(BrooklynNode.ENABLED_HTTP_PROTOCOLS, ImmutableList.of("https"))
.configure(BrooklynNode.MANAGEMENT_PASSWORD, adminPassword)
.configure(BrooklynNode.BROOKLYN_LOCAL_PROPERTIES_CONTENTS,
Strings.lines(
"brooklyn.webconsole.security.https.required=true",
"brooklyn.webconsole.security.users=admin",
"brooklyn.webconsole.security.user.admin.password="+adminPassword,
"brooklyn.location.localhost.enabled=false") )
);
app.start(locs);
log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod());
URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
Assert.assertTrue(webConsoleUri.toString().startsWith("https://"), "web console not https: "+webConsoleUri);
Integer httpsPort = brooklynNode.getAttribute(BrooklynNode.HTTPS_PORT);
Assert.assertTrue(httpsPort!=null && httpsPort >= 8443 && httpsPort <= 8500);
Assert.assertTrue(webConsoleUri.toString().contains(""+httpsPort), "web console not using right https port ("+httpsPort+"): "+webConsoleUri);
HttpTestUtils.assertHttpStatusCodeEquals(webConsoleUri.toString(), 401);
HttpClient http = HttpTool.httpClientBuilder()
.trustAll()
.uri(webConsoleUri)
.laxRedirect(true)
.credentials(new UsernamePasswordCredentials("admin", adminPassword))
.build();
HttpToolResponse response = HttpTool.httpGet(http, webConsoleUri, MutableMap.<String,String>of());
Assert.assertEquals(response.getResponseCode(), 200);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
" brooklyn.config:",
" name: add",
(includeDeclaredParameters ? Strings.lines(indent(" ",
"parameters:",
" p.param1:",
" p.param2:",
" defaultValue: default")) : ""),
Strings.lines(indent(" ", lines))
);
waitForApplicationTasks(app);
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
String yaml = Strings.lines("name: simple-app-yaml",
"services:",
"- type: " + BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
Assert.assertEquals(b2a.getCode(), OsgiBundleInstallationResult.ResultCode.INSTALLED_NEW_BUNDLE);
String yaml = Strings.lines("name: simple-app-yaml",
"services:",
"- type: " + BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
内容来源于网络,如有侵权,请联系作者删除!