예제 #1
0
void XmlResultPrinter::addFailure(const TestFailure& fail)
{
    auto test = tests.top();
    fail.isFailure() ? test->onFailure() : test->onError();

    builder->addChild("failure");
    builder->addAttribute("message", getExpectedMsg(fail.getExceptionMsg()));

    builder->addSibling("failure");
    builder->addAttribute("message", getExceptionMsg(fail.getExceptionMsg()));
}
예제 #2
0
파일: UrlLoader.cpp 프로젝트: Ahbee/Cinder
ci::BufferRef UrlLoader::loadUrl( const std::string& url )
{
	ci::BufferRef result;

	mUrl = url;

	if( JniHelper::Get()->AttachCurrentThread() ) {
		jstring jstrUrl = JniHelper::Get()->NewStringUTF( mUrl );

		jbyteArray jBytes = (jbyteArray)JniHelper::Get()->CallObjectMethod( mJavaObject, UrlLoader::sJavaMethodLoadUrl, jstrUrl );
		if( nullptr == jBytes ) {
			int resCode = getResponseCode();
			std::string resMsg = getResponseMsg();
			std::string excMsg = getExceptionMsg();
			std::stringstream ss;
			ss << "UrlLoader.loadUrl returned null (Response Code: " << resCode << ", Response Msg: " << resMsg << ", Exception Msg: " << excMsg << ")";
		    throw std::runtime_error( ss.str() );
		}

		size_t dataLength = JniHelper::Get()->GetArrayLength( jBytes );
		jbyte* dataPtr = (jbyte*)JniHelper::Get()->GetByteArrayElements( jBytes, NULL );
		if( nullptr == dataPtr ) {
			int resCode = getResponseCode();
			std::string resMsg = getResponseMsg();
			std::string excMsg = getExceptionMsg();
			std::stringstream ss;
			ss << "failed to get byte array (Response Code: " << resCode << ", Response Msg: " << resMsg << ", Exception Msg: " << excMsg << ")";
		    throw std::runtime_error( ss.str() );
		}

		if( dataLength > 0 ) {
			result = ci::Buffer::create( dataLength );
			memcpy( (void *)result->getData(), (const void *)dataPtr, dataLength );
		}

		JniHelper::Get()->ReleaseByteArrayElements( jBytes, dataPtr, 0 );
		JniHelper::Get()->DeleteLocalRef( jstrUrl );
	}

	return result;
}