本文整理汇总了Java中org.takes.facets.fork.TkFork类的典型用法代码示例。如果您正苦于以下问题:Java TkFork类的具体用法?Java TkFork怎么用?Java TkFork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TkFork类属于org.takes.facets.fork包,在下文中一共展示了TkFork类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TkRefresh
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* Ctor.
* @param path Path
* @throws IOException If fails
*/
public TkRefresh(final File path) throws IOException {
this.take = new TkFork(
new FkHitRefresh(
path,
() -> new VerboseProcess(
new ProcessBuilder(
"mvn",
"generate-resources"
)
).stdout(),
new TkFiles("./target/classes")
),
new FkFixed(new TkClasspath())
);
}
示例2: refresh
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* Ctor.
* @param path Path of files
* @return Take
* @throws IOException If fails
*/
private static Take refresh(final String path) throws IOException {
return new TkFork(
new FkHitRefresh(
new File(path),
() -> new VerboseProcess(
new ProcessBuilder(
"mvn",
"generate-resources"
)
).stdout(),
new TkFiles("./target/classes")
),
new FkFixed(new TkClasspath())
);
}
示例3: TkRefresh
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* Ctor.
* @param path Path of files
* @throws IOException If fails
*/
TkRefresh(final String path) throws IOException {
super(
new TkFork(
new FkHitRefresh(
new File(path),
() -> new VerboseProcess(
new ProcessBuilder(
"mvn",
"generate-resources"
)
).stdout(),
new TkFiles("./target/classes")
),
new FkFixed(new TkClasspath())
)
);
}
示例4: refresh
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* Hit refresh fork.
* @param path Path of files
* @return Fork
* @throws IOException If fails
*/
private static Take refresh(final String path) throws IOException {
return new TkFork(
new FkHitRefresh(
new File(path),
() -> new VerboseProcess(
new ProcessBuilder(
"mvn",
"generate-resources"
)
).stdout(),
new TkFiles("./target/classes")
),
new FkFixed(new TkClasspath())
);
}
示例5: justWorks
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* FtBasic can work.
* @throws Exception If some problem inside
*/
@Test
public void justWorks() throws Exception {
new FtRemote(
new TkFork(new FkRegex(FtBasicTest.ROOT_PATH, "hello, world!"))
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith("hello"));
}
}
);
}
示例6: returnsProperResponseCodeOnInvalidUrl
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* BkBasic can return HTTP status 404 when accessing invalid URL.
*
* @throws IOException if any I/O error occurs.
*/
@Test
public void returnsProperResponseCodeOnInvalidUrl() throws IOException {
new FtRemote(
new TkFork(
new FkRegex("/path/a", new TkText("a")),
new FkRegex("/path/b", new TkText("b"))
)
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
new JdkRequest(String.format("%s/path/c", home))
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_NOT_FOUND);
}
}
);
}
示例7: justWorks
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* TkProxy can just work.
* @throws Exception If some problem inside
*/
@Test
public void justWorks() throws Exception {
new FtRemote(
new TkFork(
new FkMethods(this.method, new TkFixed(this.expected))
)
).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
MatcherAssert.assertThat(
new RsPrint(
new TkProxy(home).act(
new RqFake(TkProxyTest.this.method)
)
).print(),
Matchers.containsString(
TkProxyTest.this.expected
)
);
}
}
);
}
示例8: refresh
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* Hit refresh fork.
* @param path Path of files
* @return Fork
* @throws IOException If fails
*/
@SuppressWarnings("PMD.DoNotUseThreads")
private static Take refresh(final String path) throws IOException {
return new TkFork(
new FkHitRefresh(
new File(path),
new Runnable() {
@Override
public void run() {
new VerboseProcess(
new ProcessBuilder(
"mvn",
"generate-resources"
)
).stdout();
}
},
new TkFiles("./target/classes")
),
new FkFixed(new TkClasspath())
);
}
示例9: make
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
private static Take make(Base base) {
return new TkAppFallback(
new TkSlf4j(
new TkForward(
new TkFork(
new FkRegex("/", "try /categories"),
new FkRegex("/categories", new TkFork(
new FkMethods("GET", new TkCategories(base)),
new FkMethods("POST,PUT", new TkCategoryAdd(base))
)),
new FkRegex("/categories/(?<number>[^/]+)", new TkFork(
new FkMethods("GET", new TkCategory(base)),
new FkMethods("POST,PUT", new TkCategoryUpdate(base)),
new FkMethods("DELETE", new TkCategoryDelete(base))
)),
new FkRegex("/products", new TkFork(
new FkMethods("GET", new TkProducts(base)),
new FkMethods("POST,PUT", new TkProductAdd(base))
)),
new FkRegex("/products/(?<number>[^/]+)", new TkFork(
new FkMethods("GET", new TkProduct(base)),
new FkMethods("POST,PUT", new TkProductUpdate(base)),
new FkMethods("DELETE", new TkProductDelete(base))
)),
new FkRegex("/categories/(?<number>[^/]+)/products", new TkFork(
new FkMethods("GET", new TkCategoryProducts(base)),
new FkMethods("POST,PUT", new TkCategoryProductsAdd(base))
)),
new FkRegex("/categories/(?<ctgId>[^/]+)/products/(?<prdId>[^/]+)", new TkFork(
new FkMethods("POST,PUT", new TkCategoryProductAdd(base)),
new FkMethods("DELETE", new TkCategoryProductDelete(base))
))
)
)
)
);
}
示例10: sendsRequestThroughToHome
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* TkRelay can send the request through.
* @throws Exception If some problem inside
*/
@Test
public void sendsRequestThroughToHome() throws Exception {
final Take target = new TkFork(
new FkRegex(
"/alpha/.*",
(Take) req -> new RsText(
new RqHref.Base(req).href().toString()
)
)
);
new FtRemote(target).exec(
home -> MatcherAssert.assertThat(
new RsPrint(
new TkRelay(new FkBase()).act(
TkRelayTest.fake(
home, "/alpha/%D0%B4%D0%B0?abc=cde"
)
)
).printBody(),
Matchers.equalTo(
String.format(
"%s/alpha/%%D0%%B4%%D0%%B0?abc=cde",
home
)
)
)
);
}
示例11: TkRoot
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
public TkRoot(final Services services) {
super(
new TkSlf4j(
new TkFallback(
new TkFork(
new FkRegex("/health", new TkHealth()),
new FkRegex("/service(/.*)?", new TkServices(services))
),
new FbFixed(new RsWithStatus(new RsText("404 Not Found"), HttpURLConnection.HTTP_NOT_FOUND))
)
)
);
}
示例12: act
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
@Override
public Response act(final RqRegex req) throws IOException {
String name = req.matcher().group("name");
String environment = req.matcher().group("environment");
return new TkFork(
new FkMethods("GET", getEndpoint(name, environment)),
new FkMethods("POST,PUT", register(name, environment)),
new FkMethods("DELETE", unregister(name, environment))
).act(req);
}
示例13: TkServices
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
public TkServices(final Services services) {
super(
new TkFork(
new FkRegex("/service/(?<name>.*)/(?<environment>.*)", new TkServiceRequest(services)),
new FkFixed(new TkAllServices(services))
)
);
}
示例14: act
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
return new TkFork(
new FkRegex("/", new TkRedirect("/f")),
new FkRegex(
"/about",
new TkHtml(App.class.getResource("about.html"))
),
new FkRegex("/robots.txt", ""),
new FkRegex("/f(.*)", new TkDir(this.home))
).act(request);
}
示例15: logins
import org.takes.facets.fork.TkFork; //导入依赖的package包/类
/**
* PsLinkedin can login.
* @throws IOException If some problem inside
*/
@Test
public void logins() throws IOException {
final String tokenpath = "/uas/oauth2/accessToken";
final String firstname = "firstName";
final String lastname = "lastName";
final String frodo = "Frodo";
final String baggins = "Baggins";
// @checkstyle MagicNumber (4 lines)
final String code = RandomStringUtils.randomAlphanumeric(10);
final String lapp = RandomStringUtils.randomAlphanumeric(10);
final String lkey = RandomStringUtils.randomAlphanumeric(10);
final String identifier = RandomStringUtils.randomAlphanumeric(10);
final Take take = new TkFork(
new FkRegex(
tokenpath,
new TokenTake(code, lapp, lkey, tokenpath)
),
new FkRegex(
"/v1/people",
new PeopleTake(identifier, firstname, lastname, frodo, baggins)
)
);
new FtRemote(take).exec(
new LinkedinScript(
code, lapp, lkey, identifier,
firstname, lastname, frodo, baggins
)
);
}