本文整理了Java中org.boon.Exceptions.tryIt()
方法的一些代码示例,展示了Exceptions.tryIt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.tryIt()
方法的具体详情如下:
包路径:org.boon.Exceptions
类名称:Exceptions
方法名:tryIt
暂无
代码示例来源:origin: boonproject/boon
public static String postForm( final String url, final Map<String, ?> headers,
final Map<String, Object> formData
) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doPostFormData( url, headers, formData );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static Response postBodyTextWithContentTypeReturnResponse( final String url,
final String contentType,
final String body ) {
return Exceptions.tryIt( Response.class, new Exceptions.TrialWithReturn<Response>() {
@Override
public Response tryIt() throws Exception {
URLConnection connection;
connection = doPost( url, null, contentType, null, body );
return extractResponseObject( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static byte[] getBytesWithHeaders(
final String url, final String contentType, final Map<String, ?> headers ) {
return Exceptions.tryIt( byte[].class, new Exceptions.TrialWithReturn<byte[]>() {
@Override
public byte[] tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, contentType, null, true );
return extractResponseBytes( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static Response jsonRestCall(
final String url
) {
return Exceptions.tryIt( Response.class, new Exceptions.TrialWithReturn<Response>() {
@Override
public Response tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, null, APPLICATION_JSON, null );
return extractResponseObject( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String readPath( final Path path ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
return read( Files.newBufferedReader( path, DEFAULT_CHARSET ) );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String readPath( final Path path ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
return read( Files.newBufferedReader( path, DEFAULT_CHARSET ) );
}
} );
}
代码示例来源:origin: boonproject/boon
public static byte[] getBytes(
final String url, final String contentType ) {
return Exceptions.tryIt( byte[].class, new Exceptions.TrialWithReturn<byte[]>() {
@Override
public byte[] tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, null, contentType, null, true );
return extractResponseBytes( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String getWithHeaders(
final String url,
final Map<String, ?> headers ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, null, null );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String postForm( final String url, final Map<String, ?> headers,
final Map<String, Object> formData
) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doPostFormData( url, headers, formData );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String getJSONWithParams(
final String url,
final Map<String, ?> headers, final Map<String, ?> params
) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, APPLICATION_JSON, null, params );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String getWithContentType(
final String url,
final Map<String, ?> headers,
final String contentType ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, contentType, null );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String postBodyTextWithContentType(
final String url,
final String contentType,
final String body ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doPost( url, null, contentType, null, body );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static Response jsonRestCallWithHeaders(
final String url,
final Map<String, ?> headers
) {
return Exceptions.tryIt( Response.class, new Exceptions.TrialWithReturn<Response>() {
@Override
public Response tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, APPLICATION_JSON, null );
return extractResponseObject(connection);
}
} );
}
代码示例来源:origin: boonproject/boon
public static String getJSONWithParams(
final String url,
final Map<String, ?> headers, final Map<String, ?> params
) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, APPLICATION_JSON, null, params );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static byte[] getBytesWithHeaders(
final String url, final String contentType, final Map<String, ?> headers ) {
return Exceptions.tryIt( byte[].class, new Exceptions.TrialWithReturn<byte[]>() {
@Override
public byte[] tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, contentType, null, true );
return extractResponseBytes( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static String getWithHeaders(
final String url,
final Map<String, ?> headers ) {
return Exceptions.tryIt( String.class, new Exceptions.TrialWithReturn<String>() {
@Override
public String tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, headers, null, null );
return extractResponseString( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
public static Response jsonRestCall(
final String url
) {
return Exceptions.tryIt( Response.class, new Exceptions.TrialWithReturn<Response>() {
@Override
public Response tryIt() throws Exception {
URLConnection connection;
connection = doGet( url, null, APPLICATION_JSON, null );
return extractResponseObject( connection );
}
} );
}
代码示例来源:origin: boonproject/boon
@Test
public void testTryItNoOp2WithMessage() {
tryIt( "no op", new Exceptions.Trial() {
@Override
public void tryIt() throws Exception {
}
} );
}
代码示例来源:origin: boonproject/boon
@Test (expected = Exceptions.SoftenedException.class)
public void testTryItWithMessage() {
tryIt( "Calling method that throws exception", new Exceptions.Trial() {
@Override
public void tryIt() throws Exception {
methodThatThrowsException();
}
} );
}
代码示例来源:origin: boonproject/boon
@Test (expected = Exceptions.SoftenedException.class)
public void testTryIt() {
tryIt( new Exceptions.Trial() {
@Override
public void tryIt() throws Exception {
methodThatThrowsException();
}
} );
}
内容来源于网络,如有侵权,请联系作者删除!