Upgrading dependency to Thrift 0.12.0
This commit is contained in:
parent
3e4590dcc0
commit
356978cb42
1302 changed files with 101701 additions and 26784 deletions
71
vendor/git.apache.org/thrift.git/lib/java/CMakeLists.txt
generated
vendored
71
vendor/git.apache.org/thrift.git/lib/java/CMakeLists.txt
generated
vendored
|
@ -17,19 +17,14 @@
|
|||
# under the License.
|
||||
#
|
||||
|
||||
file(GLOB java_sources src/**/*.java)
|
||||
|
||||
if(ANDROID)
|
||||
set(android_sources
|
||||
android/build.gradle
|
||||
android/settings.gradle
|
||||
android/src/main/AndroidManifest.xml
|
||||
)
|
||||
set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar)
|
||||
add_custom_command(
|
||||
OUTPUT ${THRIFT_AAR}
|
||||
COMMAND ${GRADLE_EXECUTABLE} -p"${CMAKE_CURRENT_SOURCE_DIR}/android" -PbuildDir="${CMAKE_CURRENT_BINARY_DIR}" assemble
|
||||
DEPENDS ${java_sources} ${android_sources})
|
||||
COMMAND ${GRADLE_EXECUTABLE}
|
||||
-p "${CMAKE_CURRENT_SOURCE_DIR}/android"
|
||||
"-PbuildDir=${CMAKE_CURRENT_BINARY_DIR}/android/build" assemble
|
||||
)
|
||||
add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR})
|
||||
|
||||
else(ANDROID)
|
||||
|
@ -46,35 +41,47 @@ else(ANDROID)
|
|||
set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE ThriftJava_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.java)
|
||||
set(ThriftJava_ARTIFACTS
|
||||
libthrift-${thrift_VERSION}.jar
|
||||
libthrift-${thrift_VERSION}.pom
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${ThriftJava_ARTIFACTS}
|
||||
COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir="${CMAKE_CURRENT_BINARY_DIR}" -f build.xml
|
||||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/build.xml
|
||||
DEPENDS ${ThriftJava_SOURCES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(ThriftJava ALL
|
||||
COMMENT "Building Java library using Ant"
|
||||
DEPENDS ${ThriftJava_ARTIFACTS}
|
||||
COMMENT "Building Java library using Gradle Wrapper"
|
||||
COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} assemble
|
||||
--console=plain --no-daemon
|
||||
-Prelease=true
|
||||
-Pthrift.version=${thrift_VERSION}
|
||||
"-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Hook the ant install task into CMake install
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install
|
||||
-Dbuild.dir=\"${CMAKE_CURRENT_BINARY_DIR}\"
|
||||
-Dinstall.path=\"${JAVA_INSTALL_DIR}\" -Dinstall.javadoc.path=\"${JAVA_DOC_INSTALL_DIR}\" -f build.xml
|
||||
# Enable publishing from CMake if the publishing information is provided
|
||||
add_custom_target(MavenPublish
|
||||
COMMENT "Publishing Java Library to Apache Maven staging"
|
||||
COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean uploadArchives
|
||||
--console=plain --no-daemon
|
||||
-Prelease=true
|
||||
-Pthrift.version=${thrift_VERSION}
|
||||
"-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)")
|
||||
)
|
||||
|
||||
# Hook the CMake install process to the results from make ALL.
|
||||
# This works best when 'make all && sudo make install/fast' is used.
|
||||
# Using slash to end the source location to avoid copying the directory path.
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/libs/
|
||||
DESTINATION ${JAVA_INSTALL_DIR}
|
||||
FILES_MATCHING PATTERN "libthrift-${thrift_VERSION}.jar")
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/deps/
|
||||
DESTINATION ${JAVA_INSTALL_DIR}
|
||||
FILES_MATCHING PATTERN "*.jar")
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/docs/javadoc/
|
||||
DESTINATION ${JAVA_DOC_INSTALL_DIR})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test(NAME JavaTest
|
||||
COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir="${CMAKE_CURRENT_BINARY_DIR}" -Dthrift.compiler="${THRIFT_COMPILER}" -f build.xml test
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
|
||||
--console=plain --no-daemon
|
||||
-Prelease=true
|
||||
-Pthrift.version=${thrift_VERSION}
|
||||
"-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
|
||||
"-Pthrift.compiler=${THRIFT_COMPILER}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
endif(ANDROID)
|
||||
|
|
48
vendor/git.apache.org/thrift.git/lib/java/Makefile.am
generated
vendored
48
vendor/git.apache.org/thrift.git/lib/java/Makefile.am
generated
vendored
|
@ -19,32 +19,54 @@
|
|||
|
||||
export CLASSPATH
|
||||
|
||||
THRIFT = $(top_builddir)/compiler/cpp/thrift
|
||||
|
||||
all-local:
|
||||
$(ANT) $(ANT_FLAGS)
|
||||
./gradlew $(GRADLE_OPTS) assemble \
|
||||
-Prelease=true \
|
||||
-Pthrift.version=$(PACKAGE_VERSION) \
|
||||
--console=plain
|
||||
|
||||
install-exec-hook:
|
||||
$(ANT) $(ANT_FLAGS) install -Dinstall.path=$(DESTDIR)$(JAVA_PREFIX) \
|
||||
-Dinstall.javadoc.path=$(DESTDIR)$(docdir)/java
|
||||
./gradlew $(GRADLE_OPTS) install \
|
||||
-Prelease=true \
|
||||
-Pinstall.path=$(DESTDIR)$(JAVA_PREFIX) \
|
||||
-Pinstall.javadoc.path=$(DESTDIR)$(docdir)/java \
|
||||
-Pthrift.version=$(PACKAGE_VERSION) \
|
||||
--console=plain
|
||||
|
||||
# Make sure this doesn't fail if ant is not configured.
|
||||
clean-local:
|
||||
ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \
|
||||
$$ANT $(ANT_FLAGS) clean
|
||||
./gradlew $(GRADLE_OPTS) clean --console=plain
|
||||
|
||||
precross: $(THRIFT)
|
||||
$(ANT) $(ANT_FLAGS) compile-test
|
||||
./gradlew $(GRADLE_OPTS) shadowJar \
|
||||
-Prelease=true \
|
||||
-Pthrift.version=$(PACKAGE_VERSION) \
|
||||
-Pthrift.compiler=$(THRIFT) \
|
||||
--console=plain
|
||||
|
||||
check-local: all
|
||||
$(ANT) $(ANT_FLAGS) test
|
||||
check-local: $(THRIFT)
|
||||
./gradlew $(GRADLE_OPTS) test \
|
||||
-Prelease=true \
|
||||
-Pthrift.version=$(PACKAGE_VERSION) \
|
||||
-Pthrift.compiler=$(THRIFT) \
|
||||
--console=plain
|
||||
|
||||
maven-publish:
|
||||
./gradlew $(GRADLE_OPTS) uploadArchives \
|
||||
-Prelease=true \
|
||||
-Pthrift.version=$(PACKAGE_VERSION) \
|
||||
--console=plain
|
||||
|
||||
EXTRA_DIST = \
|
||||
build.xml \
|
||||
build.properties \
|
||||
build.gradle \
|
||||
gradle.properties \
|
||||
settings.gradle \
|
||||
gradle \
|
||||
gradlew \
|
||||
gradlew.bat \
|
||||
CMakeLists.txt \
|
||||
coding_standards.md \
|
||||
android \
|
||||
src \
|
||||
test \
|
||||
code_quality_tools \
|
||||
README.md
|
||||
|
|
128
vendor/git.apache.org/thrift.git/lib/java/README.md
generated
vendored
128
vendor/git.apache.org/thrift.git/lib/java/README.md
generated
vendored
|
@ -20,18 +20,59 @@ KIND, either express or implied. See the License for the
|
|||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Using Thrift with Java
|
||||
======================
|
||||
Building and installing from source
|
||||
===================================
|
||||
|
||||
When using a CMake build from the source distribution on Linux the
|
||||
easiest way to build and install is this simple command line:
|
||||
|
||||
make all && sudo make install/fast
|
||||
|
||||
It is important to use the install/fast option to eliminate
|
||||
the automatic rebuild by dependency that causes issues because
|
||||
the build tooling is designed to work with cached files in the
|
||||
user home directory during the build process. Instead this builds
|
||||
the code in the expected local build tree and then uses CMake
|
||||
install code to copy to the target destination.
|
||||
|
||||
Building Thrift with Gradle without CMake/Autoconf
|
||||
==================================================
|
||||
|
||||
The Thrift Java source is not build using the GNU tools, but rather uses
|
||||
the Apache Ant build system, which tends to be predominant amongst Java
|
||||
the Gradle build system, which tends to be predominant amongst Java
|
||||
developers.
|
||||
|
||||
To compile the Java Thrift libraries, simply do the following:
|
||||
|
||||
ant
|
||||
./gradlew
|
||||
|
||||
Yep, that's easy. Look for libthrift.jar in the base directory.
|
||||
Yep, that's easy. Look for libthrift-<version>.jar in the build/libs directory.
|
||||
|
||||
The default build will run the unit tests which expect a usable
|
||||
Thrift compiler to exist on the system. You have two choices for
|
||||
that.
|
||||
|
||||
* Build the Thrift executable from source at the default
|
||||
location in the source tree. The project is configured
|
||||
to look for it there.
|
||||
* Install the published binary distribution to have Thrift
|
||||
executable in a known location and add the path to the
|
||||
~/.gradle/gradle.properties file using the property name
|
||||
"thrift.compiler". For example this would set the path in
|
||||
a Windows box if Thrift was installed under C:\Thrift
|
||||
|
||||
thrift.compiler=C:/Thrift/thrift.exe
|
||||
|
||||
To just build the library without running unit tests you simply do this.
|
||||
|
||||
./gradlew assemble
|
||||
|
||||
To install the library in the local Maven repository location
|
||||
where other Maven or Gradle builds can reference it simply do this.
|
||||
|
||||
./gradlew install
|
||||
|
||||
The library will be placed in your home directory under .m2/repository
|
||||
|
||||
To include Thrift in your applications simply add libthrift.jar to your
|
||||
classpath, or install if in your default system classpath of choice.
|
||||
|
@ -39,15 +80,84 @@ classpath, or install if in your default system classpath of choice.
|
|||
|
||||
Build Thrift behind a proxy:
|
||||
|
||||
ant -Dproxy.enabled=1 -Dproxy.host=myproxyhost -Dproxy.user=thriftuser -Dproxy.pass=topsecret
|
||||
./gradlew -Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret
|
||||
|
||||
or via
|
||||
|
||||
./configure --with-java ANT_FLAGS='-Dproxy.enabled=1 -Dproxy.host=myproxyhost -Dproxy.user=thriftuser -Dproxy.pass=topsecret'
|
||||
./configure --with-java GRADLE_OPTS='-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret'
|
||||
|
||||
|
||||
Unit Test HTML Reports
|
||||
======================
|
||||
|
||||
The build will automatically generate an HTML Unit Test report. This can be found
|
||||
under build/reports/tests/test/index.html. It can be viewed with a browser
|
||||
directly from that location.
|
||||
|
||||
|
||||
Clover Code Coverage for Thrift
|
||||
===============================
|
||||
|
||||
The build will optionally generate Clover Code coverage if the Gradle property
|
||||
`cloverEnabled=true` is set in ~/.gradle/gradle.properties or on the command line
|
||||
via `-PcloverEnabled=true`. The generated report can be found under the location
|
||||
build/reports/clover/html/index.html. It can be viewed with a browser
|
||||
directly from that location. Additionally, a PDF report is generated and is found
|
||||
under the location build/reports/clover/clover.pdf.
|
||||
|
||||
The following command will build, unit test, and generate Clover reports:
|
||||
|
||||
./gradlew -PcloverEnabled=true
|
||||
|
||||
|
||||
Publishing Maven Artifacts to Maven Central
|
||||
===========================================
|
||||
|
||||
The Automake build generates a Makefile that provides the correct parameters
|
||||
when you run the build provided the configure.ac has been set with the correct
|
||||
version number. The Gradle build will receive the correct value for the build.
|
||||
The same applies to the CMake build, the value from the configure.ac file will
|
||||
be used if you execute these commands:
|
||||
|
||||
make maven-publish -- This is for an Automake Linux build
|
||||
make MavenPublish -- This is for a CMake generated build
|
||||
|
||||
The uploadArchives task in Gradle is preconfigured with all necessary details
|
||||
to sign and publish the artifacts from the build to the Apache Maven staging
|
||||
repository. The task requires the following externally provided properties to
|
||||
authenticate to the repository and sign the artifacts. The preferred approach
|
||||
is to create or edit the ~/.gradle/gradle.properties file and add the following
|
||||
properties to it.
|
||||
|
||||
# Signing key information for artifacts PGP signature (values are examples)
|
||||
signing.keyId=24875D73
|
||||
signing.password=secret
|
||||
signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg
|
||||
|
||||
# Apache Maven staging repository user credentials
|
||||
mavenUser=meMyselfAndI
|
||||
mavenPassword=MySuperAwesomeSecretPassword
|
||||
|
||||
It is also possible to manually publish using the Gradle build directly.
|
||||
With the key information and credentials in place the following will generate
|
||||
if needed the build artifacts and proceed to publish the results.
|
||||
|
||||
./gradlew -Prelease=true -Pthrift.version=0.11.0 uploadArchives
|
||||
|
||||
It is also possible to override the target repository for the Maven Publication
|
||||
by using a Gradle property, for example you can publish signed JAR files to your
|
||||
company internal server if you add this to the command line or in the
|
||||
~/.gradle/gradle.properties file. The URL below assumes a Nexus Repository.
|
||||
|
||||
maven-repository-url=https://my.company.com/service/local/staging/deploy/maven2
|
||||
|
||||
Or the same on the command line:
|
||||
|
||||
./gradlew -Pmaven-repository-url=https://my.company.com/service/local/staging/deploy/maven2 -Prelease=true -Pthrift.version=0.11.0 uploadArchives
|
||||
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
Apache Ant
|
||||
http://ant.apache.org/
|
||||
Gradle
|
||||
http://gradle.org/
|
||||
|
|
38
vendor/git.apache.org/thrift.git/lib/java/android/build.gradle
generated
vendored
38
vendor/git.apache.org/thrift.git/lib/java/android/build.gradle
generated
vendored
|
@ -20,31 +20,31 @@
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
sourceSets.main.java {
|
||||
srcDir '../src'
|
||||
exclude 'org/apache/thrift/transport/TSaslClientTransport.java'
|
||||
exclude 'org/apache/thrift/transport/TSaslServerTransport.java'
|
||||
exclude 'org/apache/thrift/transport/TSaslTransport.java'
|
||||
}
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
sourceSets.main.java {
|
||||
srcDir '../src'
|
||||
exclude 'org/apache/thrift/transport/TSaslClientTransport.java'
|
||||
exclude 'org/apache/thrift/transport/TSaslServerTransport.java'
|
||||
exclude 'org/apache/thrift/transport/TSaslTransport.java'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
compile 'org.slf4j:slf4j-api:1.7.13'
|
||||
compile 'javax.servlet:servlet-api:2.5'
|
||||
compile 'org.apache.httpcomponents:httpcore:4.4.4'
|
||||
compile 'org.slf4j:slf4j-api:1.7.13'
|
||||
compile 'javax.servlet:servlet-api:2.5'
|
||||
compile 'org.apache.httpcomponents:httpcore:4.4.4'
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||
}
|
||||
}
|
||||
|
|
64
vendor/git.apache.org/thrift.git/lib/java/build.gradle
generated
vendored
Normal file
64
vendor/git.apache.org/thrift.git/lib/java/build.gradle
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Using the legacy plugin classpath for Clover so it can be loaded optionally
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.bmuschko:gradle-clover-plugin:2.2.0'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'maven'
|
||||
id 'signing'
|
||||
id 'com.github.johnrengelman.shadow' version '2.0.2'
|
||||
}
|
||||
|
||||
description = 'Apache Thrift Java Library'
|
||||
|
||||
defaultTasks 'build'
|
||||
|
||||
// Version components for this project
|
||||
group = property('thrift.groupid')
|
||||
|
||||
// Drop the -dev suffix, we use the SNAPSHOT suffix for non-release versions
|
||||
def parsedVersion = property('thrift.version').toString().replace('-dev', '')
|
||||
if (Boolean.parseBoolean(project.release)) {
|
||||
version = parsedVersion
|
||||
} else {
|
||||
version = parsedVersion + '-SNAPSHOT'
|
||||
}
|
||||
|
||||
// Keeping the rest of the build logic in functional named scripts for clarity
|
||||
apply from: 'gradle/environment.gradle'
|
||||
apply from: 'gradle/sourceConfiguration.gradle'
|
||||
apply from: 'gradle/additionalArtifacts.gradle'
|
||||
apply from: 'gradle/generateTestThrift.gradle'
|
||||
apply from: 'gradle/unitTests.gradle'
|
||||
apply from: 'gradle/cloverCoverage.gradle'
|
||||
apply from: 'gradle/functionalTests.gradle'
|
||||
apply from: 'gradle/publishing.gradle'
|
||||
apply from: 'gradle/codeQualityChecks.gradle'
|
414
vendor/git.apache.org/thrift.git/lib/java/build.xml
generated
vendored
414
vendor/git.apache.org/thrift.git/lib/java/build.xml
generated
vendored
|
@ -1,414 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project name="libthrift" default="dist" basedir="."
|
||||
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
||||
|
||||
<description>Thrift Build File</description>
|
||||
<property name="thrift.root" location="../../"/>
|
||||
<property name="thrift.artifactid" value="libthrift"/>
|
||||
|
||||
<!-- Include the base properties file -->
|
||||
<property file="${basedir}/build.properties" />
|
||||
|
||||
<property environment="env"/>
|
||||
|
||||
<condition property="version" value="${thrift.version}">
|
||||
<isset property="release"/>
|
||||
</condition>
|
||||
<property name="version" value="${thrift.version}-snapshot"/>
|
||||
|
||||
<property name="final.name" value="${thrift.artifactid}-${version}"/>
|
||||
|
||||
<property name="thrift.compiler" location="../../compiler/cpp/thrift"/>
|
||||
<property name="src" location="${basedir}/src"/>
|
||||
<property name="build.dir" location="${basedir}/build"/>
|
||||
<property name="build.lib.dir" location="${build.dir}/lib"/>
|
||||
<property name="build.tools.dir" location="${build.dir}/tools"/>
|
||||
<property name="src.test" location="test"/>
|
||||
<property name="javadoc.dir" location="${build.dir}/javadoc"/>
|
||||
<property name="build.test.dir" location="${build.dir}/test"/>
|
||||
<property name="test.thrift.home" location="${thrift.root}/test"/>
|
||||
|
||||
<property name="gen" location="gen-java"/>
|
||||
<property name="genbean" location="gen-javabean"/>
|
||||
<property name="genreuse" location="gen-javareuse"/>
|
||||
<property name="genfullcamel" location="gen-fullcamel"/>
|
||||
|
||||
<property name="jar.file" location="${build.dir}/${final.name}.jar"/>
|
||||
<property name="test.jar.file" location="${build.dir}/${final.name}-test.jar"/>
|
||||
<property name="javadoc.jar.file" location="${build.dir}/${final.name}-javadoc.jar"/>
|
||||
<property name="source.jar.file" location="${build.dir}/${final.name}-sources.jar"/>
|
||||
|
||||
<!-- Junit properties -->
|
||||
<property name="test.junit.output.format" value="plain"/>
|
||||
<property name="test.timeout" value="2000000"/>
|
||||
<property name="test.src.dir" location="${basedir}/test"/>
|
||||
<property name="test.log.dir" value="${build.test.dir}/log"/>
|
||||
<property name="test.port" value="9090"/>
|
||||
|
||||
<!-- maven properties -->
|
||||
<property name="pom.xml" location="${build.dir}/${final.name}.pom"/>
|
||||
|
||||
<path id="compile.classpath">
|
||||
<fileset dir="${build.lib.dir}">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="test.classpath">
|
||||
<path refid="compile.classpath"/>
|
||||
<pathelement path="${env.CLASSPATH}"/>
|
||||
<pathelement location="${build.test.dir}"/>
|
||||
<pathelement location="${jar.file}"/>
|
||||
<pathelement location="${test.jar.file}"/>
|
||||
|
||||
</path>
|
||||
|
||||
<!-- Tasks -->
|
||||
<target name="init" depends="setup.init,mvn.init" unless="init.finished">
|
||||
<property name="init.finished" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="setup.init">
|
||||
<tstamp/>
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<mkdir dir="${build.lib.dir}"/>
|
||||
<mkdir dir="${build.tools.dir}"/>
|
||||
<mkdir dir="${build.test.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src}" destdir="${build.dir}" source="1.5" target="1.5"
|
||||
debug="true" classpathref="compile.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:unchecked"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="javadoc" depends="init">
|
||||
<javadoc sourcepath="${src}" destdir="${javadoc.dir}"
|
||||
version="true" windowtitle="Thrift Java API" doctitle="Thrift Java API"
|
||||
classpathref="test.classpath">
|
||||
</javadoc>
|
||||
<jar jarfile="${javadoc.jar.file}" basedir="${javadoc.dir}">
|
||||
<manifest>
|
||||
<attribute name="Implementation-Version" value="${version}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="compile">
|
||||
<mkdir dir="${build.dir}/META-INF"/>
|
||||
<copy file="${thrift.root}/LICENSE" tofile="${build.dir}/META-INF/LICENSE.txt"/>
|
||||
<copy file="${thrift.root}/NOTICE" tofile="${build.dir}/META-INF/NOTICE.txt"/>
|
||||
<jar jarfile="${jar.file}">
|
||||
<manifest>
|
||||
<attribute name="Implementation-Version" value="${version}"/>
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-SymbolicName" value="${thrift.groupid}"/>
|
||||
<attribute name="Bundle-Name" value="Apache Thrift"/>
|
||||
<attribute name="Bundle-Version" value="${version}"/>
|
||||
<attribute name="Bundle-Description" value="Apache Thrift library"/>
|
||||
<attribute name="Bundle-License" value="${license}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="${thrift.groupid}.async;uses:="${thrift.groupid}.protocol,${thrift.groupid}.transport,org.slf4j,${thrift.groupid}";version="${version}",${thrift.groupid}.protocol;uses:="${thrift.groupid}.transport,${thrift.groupid},${thrift.groupid}.scheme";version="${version}",${thrift.groupid}.server;uses:="${thrift.groupid}.transport,${thrift.groupid}.protocol,${thrift.groupid},org.slf4j,javax.servlet,javax.servlet.http";version="${version}",${thrift.groupid}.transport;uses:="${thrift.groupid}.protocol,${thrift.groupid},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback";version="${version}",${thrift.groupid};uses:="${thrift.groupid}.protocol,${thrift.groupid}.async,${thrift.groupid}.server,${thrift.groupid}.transport,org.slf4j,org.apache.log4j,${thrift.groupid}.scheme";version="${version}",${thrift.groupid}.meta_data;uses:="${thrift.groupid}";version="${version}",${thrift.groupid}.scheme;uses:="${thrift.groupid}.protocol,${thrift.groupid}";version="${version}""/>
|
||||
<attribute name="Import-Package" value="javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version="[1.4,2)",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional"/>
|
||||
</manifest>
|
||||
<fileset dir="${build.dir}">
|
||||
<include name="org/apache/thrift/**/*.class"/>
|
||||
<include name="META-INF/*.txt"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="pack.src">
|
||||
<jar jarfile="${source.jar.file}">
|
||||
<fileset dir="${src}">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="install" depends="dist,javadoc">
|
||||
<copy todir="${install.path}">
|
||||
<fileset dir="${build.dir}" includes="*.jar"/>
|
||||
<fileset dir="${build.lib.dir}" includes="*.jar"/>
|
||||
</copy>
|
||||
<copy todir="${install.javadoc.path}">
|
||||
<fileset dir="${javadoc.dir}" includes="**/*"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${gen}"/>
|
||||
<delete dir="${genbean}"/>
|
||||
<delete dir="${genreuse}"/>
|
||||
<delete dir="${genfullcamel}"/>
|
||||
</target>
|
||||
|
||||
<target name="optional-generate" unless="no-gen-thrift">
|
||||
<antcall target="generate">
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="compile-test" description="Build the test suite classes" depends="optional-generate,dist">
|
||||
<javac debug="true" srcdir="${gen}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
</javac>
|
||||
<javac debug="true" srcdir="${genbean}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
</javac>
|
||||
<javac debug="true" srcdir="${genreuse}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
</javac>
|
||||
<javac debug="true" srcdir="${genfullcamel}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
</javac>
|
||||
<javac debug="true" srcdir="${src.test}" destdir="${build.test.dir}" classpathref="test.classpath" includeantruntime="false" encoding="UTF-8">
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<!--<compilerarg value="-Xlint:unchecked"/>-->
|
||||
</javac>
|
||||
<copy todir="${build.test.dir}">
|
||||
<fileset dir="${src.test}" includes="log4j.properties"/>
|
||||
</copy>
|
||||
<jar jarfile="${test.jar.file}" basedir="${build.test.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
|
||||
<mkdir dir="${test.log.dir}"/>
|
||||
<junit printsummary="true" showoutput="${test.output}" timeout="${test.timeout}"
|
||||
haltonfailure="true" errorProperty="tests.failed" failureProperty="tests.failed"
|
||||
fork="true" forkmode="perTest" maxmemory="512m"
|
||||
>
|
||||
<sysproperty key="build.test" value="${build.test.dir}"/>
|
||||
<sysproperty key="test.port" value="${test.port}"/>
|
||||
<sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
|
||||
<sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
|
||||
<sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
|
||||
<sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
|
||||
<classpath refid="test.classpath"/>
|
||||
<formatter type="${test.junit.output.format}"/>
|
||||
<batchtest todir="${test.log.dir}" unless="testcase">
|
||||
<fileset dir="${test.src.dir}">
|
||||
<include name="**/Test*.java"/>
|
||||
<exclude name="**/TestClient.java"/>
|
||||
<exclude name="**/TestServer.java"/>
|
||||
<exclude name="**/TestNonblockingServer.java"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
<batchtest todir="${test.log.dir}" if="testcase">
|
||||
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
|
||||
</batchtest>
|
||||
</junit>
|
||||
<fail if="tests.failed">Tests failed!</fail>
|
||||
</target>
|
||||
|
||||
<target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
|
||||
<java classname="org.apache.thrift.test.EqualityTest" classpathref="test.classpath" failonerror="true"/>
|
||||
<java classname="org.apache.thrift.test.JavaBeansTest" classpathref="test.classpath" failonerror="true"/>
|
||||
</target>
|
||||
|
||||
<target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
|
||||
|
||||
<target name="testclient" description="Run a test client" depends="compile-test, run-testclient"/>
|
||||
<target name="run-testclient" description="Run a test client">
|
||||
<java classname="org.apache.thrift.test.TestClient"
|
||||
classpathref="test.classpath" failonerror="true" fork="true">
|
||||
<sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
|
||||
<sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
|
||||
<arg line="${testargs}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="testserver" description="Run a test server" depends="compile-test, run-testserver"/>
|
||||
<target name="run-testserver" description="Run a test server">
|
||||
<java classname="org.apache.thrift.test.TestServer"
|
||||
classpathref="test.classpath" failonerror="true" fork="true">
|
||||
<sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
|
||||
<sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
|
||||
<arg line="${testargs}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="testnonblockingserver" description="Run a test nonblocking server" depends="compile-test, run-testnonblockingserver"/>
|
||||
<target name="run-testnonblockingserver" description="Run a test nonblocking server">
|
||||
<java classname="org.apache.thrift.test.TestNonblockingServer"
|
||||
classpathref="test.classpath" failonerror="true">
|
||||
<arg line="${testargs}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="generate">
|
||||
<!-- Generate the thrift gen-java source -->
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java ${test.thrift.home}/ThriftTest.thrift"/>
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java ${test.thrift.home}/JavaTypes.thrift"/>
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java ${test.thrift.home}/DebugProtoTest.thrift"/>
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java ${test.thrift.home}/OptionalRequiredTest.thrift"/>
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift"/>
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java ${test.thrift.home}/ManyOptionals.thrift"/>
|
||||
</exec>
|
||||
<mkdir dir="${genfullcamel}"/>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java:fullcamel -out ${genfullcamel} ${test.thrift.home}/FullCamelTest.thrift"/>
|
||||
</exec>
|
||||
<mkdir dir="${genreuse}"/>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen java:reuse-objects -out ${genreuse} ${test.thrift.home}/ReuseObjects.thrift"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="proxy" if="proxy.enabled">
|
||||
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
|
||||
proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
|
||||
</target>
|
||||
|
||||
<target name="mvn.ant.tasks.download" depends="setup.init,mvn.ant.tasks.check,proxy" unless="mvn.ant.tasks.found">
|
||||
<get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
<target name="mvn.ant.tasks.check">
|
||||
<condition property="mvn.ant.tasks.found">
|
||||
<typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="mvn.init" depends="mvn.ant.tasks.download" unless="mvn.finished">
|
||||
<!-- Download mvn ant tasks, download dependencies, and setup pom file -->
|
||||
<typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${build.tools.dir}/${mvn.ant.task.jar}"/>
|
||||
|
||||
<!-- remote repositories used to download dependencies from -->
|
||||
<artifact:remoteRepository id="central" url="${mvn.repo}"/>
|
||||
<artifact:remoteRepository id="apache" url="${apache.repo}"/>
|
||||
|
||||
<!-- Pom file information -->
|
||||
<artifact:pom id="pom"
|
||||
groupId="${thrift.groupid}"
|
||||
artifactId="${thrift.artifactid}"
|
||||
version="${version}"
|
||||
url="http://thrift.apache.org"
|
||||
name="Apache Thrift"
|
||||
description="Thrift is a software framework for scalable cross-language services development."
|
||||
packaging="pom"
|
||||
>
|
||||
<remoteRepository refid="central"/>
|
||||
<remoteRepository refid="apache"/>
|
||||
<license name="The Apache Software License, Version 2.0" url="${license}"/>
|
||||
<scm connection="scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git"
|
||||
developerConnection="scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git"
|
||||
url="https://git-wip-us.apache.org/repos/asf?p=thrift.git"
|
||||
/>
|
||||
<!-- Thrift Developers -->
|
||||
<developer id="mcslee" name="Mark Slee"/>
|
||||
<developer id="dreiss" name="David Reiss"/>
|
||||
<developer id="aditya" name="Aditya Agarwal"/>
|
||||
<developer id="marck" name="Marc Kwiatkowski"/>
|
||||
<developer id="jwang" name="James Wang"/>
|
||||
<developer id="cpiro" name="Chris Piro"/>
|
||||
<developer id="bmaurer" name="Ben Maurer"/>
|
||||
<developer id="kclark" name="Kevin Clark"/>
|
||||
<developer id="jake" name="Jake Luciani"/>
|
||||
<developer id="bryanduxbury" name="Bryan Duxbury"/>
|
||||
<developer id="esteve" name="Esteve Fernandez"/>
|
||||
<developer id="todd" name="Todd Lipcon"/>
|
||||
<developer id="geechorama" name="Andrew McGeachie"/>
|
||||
<developer id="molinaro" name="Anthony Molinaro"/>
|
||||
<developer id="roger" name="Roger Meier"/>
|
||||
<developer id="jfarrell" name="Jake Farrell"/>
|
||||
<developer id="jensg" name="Jens Geyer"/>
|
||||
<developer id="carl" name="Carl Yeksigian"/>
|
||||
|
||||
<!-- Thrift dependencies list -->
|
||||
<dependency groupId="org.slf4j" artifactId="slf4j-api" version="${slf4j.version}"/>
|
||||
<dependency groupId="javax.servlet" artifactId="servlet-api" version="${servlet.version}" scope="provided"/>
|
||||
<dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="${httpclient.version}"/>
|
||||
<dependency groupId="org.apache.httpcomponents" artifactId="httpcore" version="${httpcore.version}"/>
|
||||
</artifact:pom>
|
||||
|
||||
<!-- Generate the pom file -->
|
||||
<artifact:writepom pomRefId="pom" file="${pom.xml}"/>
|
||||
|
||||
<!-- Download the dependencies -->
|
||||
<artifact:dependencies filesetId="build-dependency-jars" pomRefId="pom"/>
|
||||
|
||||
<!-- Copy the dependencies to the build/lib dir -->
|
||||
<copy todir="${build.dir}/lib">
|
||||
<fileset refid="build-dependency-jars"/>
|
||||
<mapper type="flatten"/>
|
||||
</copy>
|
||||
|
||||
<!-- Dependencies needed for testing -->
|
||||
<artifact:dependencies filesetId="test-dependency-jars" useScope="runtime">
|
||||
<dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="${slf4j.version}"/>
|
||||
<dependency groupId="junit" artifactId="junit" version="4.4"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
<!-- Copy the test dependencies to the build/lib dir -->
|
||||
<copy todir="${build.dir}/lib">
|
||||
<fileset refid="test-dependency-jars"/>
|
||||
<mapper type="flatten"/>
|
||||
</copy>
|
||||
|
||||
<property name="mvn.finished" value="true"/>
|
||||
</target>
|
||||
|
||||
<macrodef name="signAndDeploy">
|
||||
<!-- Sign and deploy jars to apache repo -->
|
||||
<attribute name="file"/>
|
||||
<attribute name="classifier" default=""/>
|
||||
<attribute name="packaging" default="jar"/>
|
||||
<attribute name="pom" default=""/>
|
||||
<sequential>
|
||||
<artifact:mvn fork="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.6:sign-and-deploy-file"/>
|
||||
<arg value="-DrepositoryId=${maven-repository-id}"/>
|
||||
<arg value="-Durl=${maven-repository-url}"/>
|
||||
<arg value="-DpomFile=@{pom}"/>
|
||||
<arg value="-Dfile=@{file}"/>
|
||||
<arg value="-Dclassifier=@{classifier}"/>
|
||||
<arg value="-Dpackaging=@{packaging}"/>
|
||||
<arg value="-Pgpg"/>
|
||||
</artifact:mvn>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="publish" depends="clean,init,test,dist,javadoc,pack.src">
|
||||
<!-- Compile, package, test and then send release to apache maven repo -->
|
||||
<!-- run with: ant -Drelease=true publish-->
|
||||
<signAndDeploy file="${pom.xml}" packaging="pom" classifier="" pom="${pom.xml}"/>
|
||||
<signAndDeploy file="${jar.file}" classifier="" pom="${pom.xml}"/>
|
||||
<signAndDeploy file="${javadoc.jar.file}" classifier="javadoc" pom="${pom.xml}"/>
|
||||
<signAndDeploy file="${source.jar.file}" classifier="sources" pom="${pom.xml}"/>
|
||||
</target>
|
||||
</project>
|
51
vendor/git.apache.org/thrift.git/lib/java/code_quality_tools/findbugs-filter.xml
generated
vendored
Normal file
51
vendor/git.apache.org/thrift.git/lib/java/code_quality_tools/findbugs-filter.xml
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
<FindBugsFilter>
|
||||
<!--
|
||||
This file controls filtering some of the more obnoxious findbugs reports.
|
||||
Some may be worthy of examination and resolution, others are too nit-picky.
|
||||
-->
|
||||
<Match>
|
||||
<Or>
|
||||
<!-- Filter the missing serialVersionUID errors -->
|
||||
<Bug code="SnVI" />
|
||||
<!-- Filter Malicious code vulnerability Warnings -->
|
||||
<Bug code="EI,EI2" />
|
||||
<!-- Filter Unchecked/unconfirmed cast -->
|
||||
<Bug code="BC" />
|
||||
<!-- Filter Should return a zero length array rather than null? -->
|
||||
<Bug code="PZLA" />
|
||||
<!-- Filter Redundant nullcheck -->
|
||||
<Bug code="RCN" />
|
||||
<!-- Filter Exception is caught when Exception is not thrown -->
|
||||
<Bug code="REC" />
|
||||
<!-- Filter Switch statement found where default case is missing -->
|
||||
<Bug code="SF" />
|
||||
<!-- Filter Unread public/protected field -->
|
||||
<Bug code="UrF" />
|
||||
<!-- Filter Field not initialized in constructor and dereferenced -->
|
||||
<Bug code="UwF" />
|
||||
</Or>
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- Filter method invokes System.exit(...), which shuts down the entire virtual machine -->
|
||||
<Class name="org.apache.thrift.transport.TFileTransport" />
|
||||
<Method name="printUsage" />
|
||||
<Bug code="Dm" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- Filter method might ignore java.lang.Exception -->
|
||||
<Class name="org.apache.thrift.transport.TSimpleFileTransport" />
|
||||
<Method name="close" />
|
||||
<Bug code="DE" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- Filter method might ignore java.lang.Exception -->
|
||||
<Class name="org.apache.thrift.TNonblockingMultiFetchClient$MultiFetch" />
|
||||
<Method name="run" />
|
||||
<Bug code="DE" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- Filter Class defines non-transient non-serializable instance field -->
|
||||
<Class name="org.apache.thrift.server.TServlet" />
|
||||
<Bug code="Se" />
|
||||
</Match>
|
||||
</FindBugsFilter>
|
|
@ -1,31 +1,33 @@
|
|||
thrift.version=0.10.0
|
||||
# This file is shared currently between this Gradle build and the
|
||||
# Ant builds for fd303 and JavaScript. Keep the dotted notation for
|
||||
# the properties to minimize the changes in the dependencies.
|
||||
thrift.version=1.0.0
|
||||
thrift.groupid=org.apache.thrift
|
||||
release=false
|
||||
|
||||
# Jar Versions
|
||||
mvn.ant.task.version=2.1.3
|
||||
|
||||
# Local Install paths
|
||||
install.path=/usr/local/lib
|
||||
install.javadoc.path=${install.path}
|
||||
install.javadoc.path=/usr/local/lib
|
||||
|
||||
# Test execution properties
|
||||
testPort=9090
|
||||
|
||||
# Test with Clover Code coverage (disabled by default)
|
||||
cloverEnabled=false
|
||||
|
||||
# Maven dependency download locations
|
||||
mvn.repo=http://repo1.maven.org/maven2
|
||||
apache.repo=https://repository.apache.org/content/repositories/releases
|
||||
mvn.ant.task.url=${mvn.repo}/org/apache/maven/maven-ant-tasks/${mvn.ant.task.version}
|
||||
mvn.ant.task.jar=maven-ant-tasks-${mvn.ant.task.version}.jar
|
||||
|
||||
# Apache Maven publish
|
||||
license=http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
maven-repository-url=https://repository.apache.org/service/local/staging/deploy/maven2
|
||||
maven-repository-id=apache.releases.https
|
||||
|
||||
# Jar Versions
|
||||
mvn.ant.task.version=2.1.3
|
||||
|
||||
# Dependency versions
|
||||
httpclient.version=4.4.1
|
||||
httpcore.version=4.4.1
|
||||
slf4j.version=1.7.12
|
||||
servlet.version=2.5
|
||||
|
||||
junit.version=4.12
|
||||
mockito.version=1.9.5
|
40
vendor/git.apache.org/thrift.git/lib/java/gradle/additionalArtifacts.gradle
generated
vendored
Normal file
40
vendor/git.apache.org/thrift.git/lib/java/gradle/additionalArtifacts.gradle
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
task sourcesJar(type: Jar, group: 'Build') {
|
||||
description = 'Assembles a jar archive containing the main Java sources.'
|
||||
|
||||
classifier 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc, group: 'Build') {
|
||||
description = 'Assembles a jar archive containing the JavaDoc.'
|
||||
|
||||
classifier 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
}
|
||||
|
48
vendor/git.apache.org/thrift.git/lib/java/gradle/cloverCoverage.gradle
generated
vendored
Normal file
48
vendor/git.apache.org/thrift.git/lib/java/gradle/cloverCoverage.gradle
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// Keep this as an optional feature for now, disabled by default
|
||||
if (Boolean.parseBoolean(project.cloverEnabled)) {
|
||||
apply plugin: 'com.bmuschko.clover'
|
||||
|
||||
dependencies {
|
||||
clover 'org.openclover:clover:4.2.+'
|
||||
}
|
||||
|
||||
clover {
|
||||
|
||||
testIncludes = ['**/Test*.java']
|
||||
// Exclude the generated test code from code coverage
|
||||
testExcludes = ['thrift/test/Test*.java']
|
||||
|
||||
compiler {
|
||||
encoding = 'UTF-8'
|
||||
debug = true
|
||||
}
|
||||
|
||||
report {
|
||||
html = true
|
||||
pdf = true
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn cloverGenerateReport
|
||||
}
|
40
vendor/git.apache.org/thrift.git/lib/java/gradle/codeQualityChecks.gradle
generated
vendored
Normal file
40
vendor/git.apache.org/thrift.git/lib/java/gradle/codeQualityChecks.gradle
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
// =================================================================
|
||||
// Configure the Gradle code quality plugins here.
|
||||
//
|
||||
|
||||
apply plugin: 'findbugs'
|
||||
|
||||
findbugs {
|
||||
ignoreFailures = true
|
||||
toolVersion = '3.0.1'
|
||||
sourceSets = [ sourceSets.main ]
|
||||
effort = 'max'
|
||||
reportLevel = 'low'
|
||||
excludeFilter = file('code_quality_tools/findbugs-filter.xml')
|
||||
}
|
||||
|
||||
tasks.withType(FindBugs) {
|
||||
reports {
|
||||
text.enabled = false
|
||||
html.enabled = true
|
||||
xml.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'pmd'
|
||||
|
||||
pmd {
|
||||
ignoreFailures = true
|
||||
toolVersion = '6.0.0'
|
||||
sourceSets = [ sourceSets.main ]
|
||||
targetJdk = sourceCompatibility
|
||||
ruleSets = [ 'java-basic' ]
|
||||
}
|
||||
|
||||
tasks.withType(Pmd) {
|
||||
reports {
|
||||
html.enabled = true
|
||||
xml.enabled = false
|
||||
}
|
||||
}
|
73
vendor/git.apache.org/thrift.git/lib/java/gradle/environment.gradle
generated
vendored
Normal file
73
vendor/git.apache.org/thrift.git/lib/java/gradle/environment.gradle
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// Override the build directory if CMake is used (allows for out-of-tree-builds)
|
||||
if (hasProperty('build.dir')) {
|
||||
buildDir = file(property('build.dir'))
|
||||
}
|
||||
|
||||
// In order to remain compatible with other Ant based builds in the system
|
||||
// we convert the gradle.properties into DSL friendly camelCased properties
|
||||
ext.installPath = property('install.path')
|
||||
ext.installJavadocPath = property('install.javadoc.path')
|
||||
|
||||
ext.thriftRoot = file('../..')
|
||||
|
||||
if (hasProperty('thrift.compiler')) {
|
||||
ext.thriftCompiler = property('thrift.compiler')
|
||||
} else {
|
||||
ext.thriftCompiler = "$thriftRoot/compiler/cpp/thrift"
|
||||
}
|
||||
|
||||
ext.mvnRepo = property('mvn.repo')
|
||||
ext.apacheRepo = property('apache.repo')
|
||||
ext.mavenRepositoryUrl = property('maven-repository-url')
|
||||
|
||||
// Versions used in this project
|
||||
ext.httpclientVersion = property('httpclient.version')
|
||||
ext.httpcoreVersion = property('httpcore.version')
|
||||
ext.servletVersion = property('servlet.version')
|
||||
ext.slf4jVersion = property('slf4j.version')
|
||||
ext.junitVersion = property('junit.version')
|
||||
ext.mockitoVersion = property('mockito.version')
|
||||
|
||||
// In this section you declare where to find the dependencies of your project
|
||||
repositories {
|
||||
maven {
|
||||
name 'Maven Central Repository'
|
||||
url mvnRepo
|
||||
}
|
||||
maven {
|
||||
name 'Apache Maven Repository'
|
||||
url apacheRepo
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
compile "org.apache.httpcomponents:httpclient:${httpclientVersion}"
|
||||
compile "org.apache.httpcomponents:httpcore:${httpcoreVersion}"
|
||||
compile "javax.servlet:servlet-api:${servletVersion}"
|
||||
|
||||
testCompile "junit:junit:${junitVersion}"
|
||||
testCompile "org.mockito:mockito-all:${mockitoVersion}"
|
||||
testRuntime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
|
||||
}
|
155
vendor/git.apache.org/thrift.git/lib/java/gradle/functionalTests.gradle
generated
vendored
Normal file
155
vendor/git.apache.org/thrift.git/lib/java/gradle/functionalTests.gradle
generated
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Functional testing harness creation. This helps run the cross-check tests.
|
||||
// The Makefile precross target invokes the shadowJar task and the tests.json
|
||||
// code is changed to call runclient or runserver as needed.
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Cross Test sources are separated in their own sourceSet
|
||||
//
|
||||
sourceSets {
|
||||
crossTest {
|
||||
java {
|
||||
srcDir 'test'
|
||||
include '**/test/TestClient.java'
|
||||
include '**/test/TestServer.java'
|
||||
include '**/test/TestNonblockingServer.java'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
crossTestCompile { extendsFrom testCompile }
|
||||
crossTestRuntime { extendsFrom crossTestCompile, testRuntime }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
crossTestCompile sourceSets.main.output
|
||||
crossTestCompile sourceSets.test.output
|
||||
}
|
||||
|
||||
// I am using shadow plugin to make a self contained functional test Uber JAR that
|
||||
// eliminates startup problems with wrapping the cross-check harness in Gradle.
|
||||
// This is used by the runner scripts as the single classpath entry which
|
||||
// allows the process to be as lightweight as it can.
|
||||
shadowJar {
|
||||
description = 'Assemble a test JAR file for cross-check execution'
|
||||
// make sure the runners are created when this runs
|
||||
dependsOn 'generateRunnerScriptForClient', 'generateRunnerScriptForServer', 'generateRunnerScriptForNonblockingServer'
|
||||
|
||||
baseName = 'functionalTest'
|
||||
destinationDir = file("$buildDir/functionalTestJar")
|
||||
classifier = null
|
||||
|
||||
// We do not need a version number for this internal jar
|
||||
version = null
|
||||
|
||||
// Bundle the complete set of unit test classes including generated code
|
||||
// and the runtime dependencies in one JAR to expedite execution.
|
||||
from sourceSets.test.output
|
||||
from sourceSets.crossTest.output
|
||||
configurations = [project.configurations.testRuntime]
|
||||
}
|
||||
|
||||
// Common script runner configuration elements
|
||||
def scriptExt = ''
|
||||
def execExt = ''
|
||||
def scriptHead = '#!/bin/bash'
|
||||
def args = '$*'
|
||||
|
||||
// Although this is marked internal it is an available and stable interface
|
||||
if (org.gradle.internal.os.OperatingSystem.current().windows) {
|
||||
scriptExt = '.bat'
|
||||
execExt = '.exe'
|
||||
scriptHead = '@echo off'
|
||||
args = '%*'
|
||||
}
|
||||
|
||||
// The Java executable to use with the runner scripts
|
||||
def javaExe = file("${System.getProperty('java.home')}/bin/java${execExt}").canonicalPath
|
||||
// The common Uber jar path
|
||||
def jarPath = shadowJar.archivePath.canonicalPath
|
||||
def trustStore = file('test/.truststore').canonicalPath
|
||||
def keyStore = file('test/.keystore').canonicalPath
|
||||
|
||||
task generateRunnerScriptForClient(group: 'Build') {
|
||||
description = 'Generate a runner script for cross-check tests with TestClient'
|
||||
|
||||
def clientFile = file("$buildDir/runclient${scriptExt}")
|
||||
|
||||
def runClientText = """\
|
||||
${scriptHead}
|
||||
|
||||
"${javaExe}" -cp "$jarPath" "-Djavax.net.ssl.trustStore=$trustStore" -Djavax.net.ssl.trustStorePassword=thrift org.apache.thrift.test.TestClient $args
|
||||
"""
|
||||
inputs.property 'runClientText', runClientText
|
||||
outputs.file clientFile
|
||||
|
||||
doLast {
|
||||
clientFile.parentFile.mkdirs()
|
||||
clientFile.text = runClientText
|
||||
clientFile.setExecutable(true, false)
|
||||
}
|
||||
}
|
||||
|
||||
task generateRunnerScriptForServer(group: 'Build') {
|
||||
description = 'Generate a runner script for cross-check tests with TestServer'
|
||||
|
||||
def serverFile = file("$buildDir/runserver${scriptExt}")
|
||||
|
||||
def runServerText = """\
|
||||
${scriptHead}
|
||||
|
||||
"${javaExe}" -cp "$jarPath" "-Djavax.net.ssl.keyStore=$keyStore" -Djavax.net.ssl.keyStorePassword=thrift org.apache.thrift.test.TestServer $args
|
||||
"""
|
||||
|
||||
inputs.property 'runServerText', runServerText
|
||||
outputs.file serverFile
|
||||
|
||||
doLast {
|
||||
serverFile.parentFile.mkdirs()
|
||||
serverFile.text = runServerText
|
||||
serverFile.setExecutable(true, false)
|
||||
}
|
||||
}
|
||||
|
||||
task generateRunnerScriptForNonblockingServer(group: 'Build') {
|
||||
description = 'Generate a runner script for cross-check tests with TestNonblockingServer'
|
||||
|
||||
def serverFile = file("$buildDir/runnonblockingserver${scriptExt}")
|
||||
|
||||
def runServerText = """\
|
||||
${scriptHead}
|
||||
|
||||
"${javaExe}" -cp "$jarPath" "-Djavax.net.ssl.keyStore=$keyStore" -Djavax.net.ssl.keyStorePassword=thrift org.apache.thrift.test.TestNonblockingServer $args
|
||||
"""
|
||||
|
||||
inputs.property 'runServerText', runServerText
|
||||
outputs.file serverFile
|
||||
|
||||
doLast {
|
||||
serverFile.parentFile.mkdirs()
|
||||
serverFile.text = runServerText
|
||||
serverFile.setExecutable(true, false)
|
||||
}
|
||||
}
|
119
vendor/git.apache.org/thrift.git/lib/java/gradle/generateTestThrift.gradle
generated
vendored
Normal file
119
vendor/git.apache.org/thrift.git/lib/java/gradle/generateTestThrift.gradle
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// Generated code locations for Unit tests
|
||||
ext.genSrc = file("$buildDir/gen-java")
|
||||
ext.genBeanSrc = file("$buildDir/gen-javabean")
|
||||
ext.genReuseSrc = file("$buildDir/gen-javareuse")
|
||||
ext.genFullCamelSrc = file("$buildDir/gen-fullcamel")
|
||||
ext.genUnsafeSrc = file("$buildDir/gen-unsafe")
|
||||
|
||||
// Add the generated code directories to the test source set
|
||||
sourceSets {
|
||||
test.java.srcDirs genSrc, genBeanSrc, genReuseSrc, genFullCamelSrc, genUnsafeSrc
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Code generation for Unit Testing
|
||||
|
||||
// A callable closure to make this easier
|
||||
ext.thriftCompile = { Task task, String thriftFileName, String generator = 'java', File outputDir = genSrc ->
|
||||
def thriftFile = file("$thriftRoot/test/$thriftFileName")
|
||||
assert thriftFile.exists()
|
||||
|
||||
task.inputs.file thriftFile
|
||||
task.outputs.dir outputDir
|
||||
|
||||
task.doLast {
|
||||
outputDir.mkdirs()
|
||||
def result = exec {
|
||||
executable file(thriftCompiler)
|
||||
args '--gen', generator
|
||||
args '-out', outputDir
|
||||
args thriftFile
|
||||
standardOutput = task.outputBuffer
|
||||
errorOutput = task.outputBuffer
|
||||
ignoreExitValue = true
|
||||
}
|
||||
if (result.exitValue != 0) {
|
||||
// Only show the Thrift compiler output on failures, cuts down on noise!
|
||||
println task.outputBuffer.toString()
|
||||
result.rethrowFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task generate(group: 'Build') {
|
||||
description = 'Generate all unit test Thrift sources'
|
||||
compileTestJava.dependsOn it
|
||||
}
|
||||
|
||||
task generateJava(group: 'Build') {
|
||||
description = 'Generate the thrift gen-java source'
|
||||
generate.dependsOn it
|
||||
|
||||
ext.outputBuffer = new ByteArrayOutputStream()
|
||||
|
||||
thriftCompile(it, 'ThriftTest.thrift')
|
||||
thriftCompile(it, 'JavaTypes.thrift')
|
||||
thriftCompile(it, 'DebugProtoTest.thrift')
|
||||
thriftCompile(it, 'DoubleConstantsTest.thrift')
|
||||
thriftCompile(it, 'OptionalRequiredTest.thrift')
|
||||
thriftCompile(it, 'ManyOptionals.thrift')
|
||||
thriftCompile(it, 'JavaDeepCopyTest.thrift')
|
||||
thriftCompile(it, 'EnumContainersTest.thrift')
|
||||
}
|
||||
|
||||
task generateBeanJava(group: 'Build') {
|
||||
description = 'Generate the thrift gen-javabean source'
|
||||
generate.dependsOn it
|
||||
|
||||
ext.outputBuffer = new ByteArrayOutputStream()
|
||||
|
||||
thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel', genBeanSrc)
|
||||
}
|
||||
|
||||
task generateReuseJava(group: 'Build') {
|
||||
description = 'Generate the thrift gen-javareuse source'
|
||||
generate.dependsOn it
|
||||
|
||||
ext.outputBuffer = new ByteArrayOutputStream()
|
||||
|
||||
thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel', genFullCamelSrc)
|
||||
}
|
||||
|
||||
task generateFullCamelJava(group: 'Build') {
|
||||
description = 'Generate the thrift gen-fullcamel source'
|
||||
generate.dependsOn it
|
||||
|
||||
ext.outputBuffer = new ByteArrayOutputStream()
|
||||
|
||||
thriftCompile(it, 'ReuseObjects.thrift', 'java:reuse-objects', genReuseSrc)
|
||||
}
|
||||
|
||||
task generateUnsafeBinariesJava(group: 'Build') {
|
||||
description = 'Generate the thrift gen-unsafebinaries source'
|
||||
generate.dependsOn it
|
||||
|
||||
ext.outputBuffer = new ByteArrayOutputStream()
|
||||
|
||||
thriftCompile(it, 'UnsafeTypes.thrift', 'java:unsafe_binaries', genUnsafeSrc)
|
||||
}
|
119
vendor/git.apache.org/thrift.git/lib/java/gradle/publishing.gradle
generated
vendored
Normal file
119
vendor/git.apache.org/thrift.git/lib/java/gradle/publishing.gradle
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Installation subtasks, not used currently, we use "make install/fast"
|
||||
task installDist(type: Copy, group: 'Install') {
|
||||
description = "Copy Thrift JAR and dependencies into $installPath location"
|
||||
|
||||
destinationDir = file(installPath)
|
||||
|
||||
from jar
|
||||
from configurations.compile
|
||||
}
|
||||
|
||||
task installJavadoc(type: Copy, group: 'Install', dependsOn: javadoc) {
|
||||
description = "Install Thrift JavaDoc into $installJavadocPath location"
|
||||
|
||||
destinationDir = file(installJavadocPath)
|
||||
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
// This is not needed by Gradle builds but the remaining Ant builds seem to
|
||||
// need access to the generated test classes for Thrift unit tests so we
|
||||
// assist them to use it this way.
|
||||
task copyDependencies(type: Copy, group: 'Build') {
|
||||
description = 'Copy runtime dependencies in a common location for other Ant based projects'
|
||||
project.assemble.dependsOn it
|
||||
|
||||
destinationDir = file("$buildDir/deps")
|
||||
from configurations.testRuntime
|
||||
// exclude some very specific unit test dependencies
|
||||
exclude '**/junit*.jar', '**/mockito*.jar', '**/hamcrest*.jar'
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Allow this configuration to be shared between install and uploadArchives tasks
|
||||
def configurePom(pom) {
|
||||
pom.project {
|
||||
name 'Apache Thrift'
|
||||
description 'Thrift is a software framework for scalable cross-language services development.'
|
||||
packaging 'jar'
|
||||
url 'http://thrift.apache.org'
|
||||
|
||||
scm {
|
||||
url 'https://git-wip-us.apache.org/repos/asf?p=thrift.git'
|
||||
connection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git'
|
||||
developerConnection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git'
|
||||
}
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url "${project.license}"
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id 'dev'
|
||||
name 'Apache Thrift Developers'
|
||||
email 'dev@thrift.apache.org'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pom.whenConfigured {
|
||||
// Fixup the scope for servlet-api to be 'provided' instead of 'compile'
|
||||
dependencies.find { dep -> dep.groupId == 'javax.servlet' && dep.artifactId == 'servlet-api' }.with {
|
||||
// it.optional = true
|
||||
it.scope = 'provided'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
configurePom(pom)
|
||||
}
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
dependsOn test // make sure we run unit tests when publishing
|
||||
repositories.mavenDeployer {
|
||||
// signPom will silently do nothing when no signing information is provided
|
||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||
repository(url: project.mavenRepositoryUrl) {
|
||||
if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
|
||||
authentication(userName: mavenUser, password: mavenPassword)
|
||||
}
|
||||
}
|
||||
configurePom(pom)
|
||||
}
|
||||
}
|
||||
|
||||
// Signing configuration, optional, only when release and uploadArchives is activated
|
||||
signing {
|
||||
required { !version.endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("uploadArchives") }
|
||||
sign configurations.archives
|
||||
}
|
84
vendor/git.apache.org/thrift.git/lib/java/gradle/sourceConfiguration.gradle
generated
vendored
Normal file
84
vendor/git.apache.org/thrift.git/lib/java/gradle/sourceConfiguration.gradle
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// source sets for main and test sources
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src'
|
||||
}
|
||||
}
|
||||
test {
|
||||
java {
|
||||
srcDir 'test'
|
||||
// see functionalTests.gradle for these files
|
||||
exclude '**/test/TestClient.java'
|
||||
exclude '**/test/TestServer.java'
|
||||
exclude '**/test/TestNonblockingServer.java'
|
||||
}
|
||||
resources {
|
||||
srcDir 'test'
|
||||
include 'log4j.properties'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Compiler configuration details
|
||||
|
||||
sourceCompatibility = '1.6'
|
||||
targetCompatibility = '1.6'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.debug = true
|
||||
options.deprecation = true
|
||||
// options.compilerArgs.addAll('-Xlint:unchecked')
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Jar packaging details
|
||||
processResources {
|
||||
into('META-INF') {
|
||||
from "$thriftRoot/LICENSE"
|
||||
from "$thriftRoot/NOTICE"
|
||||
rename('(.+)', '$1.txt')
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
project.test.dependsOn it
|
||||
manifest {
|
||||
attributes([
|
||||
"Implementation-Version": "${project.version}",
|
||||
"Bundle-ManifestVersion": "2",
|
||||
"Bundle-SymbolicName": "${project.group}",
|
||||
"Bundle-Name": "Apache Thrift",
|
||||
"Bundle-Version": "${project.version}",
|
||||
"Bundle-Description": "Apache Thrift library",
|
||||
"Bundle-License": "${project.license}",
|
||||
"Bundle-ActivationPolicy": "lazy",
|
||||
"Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${version}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${version}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${version}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${version}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${version}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${version}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${version}\"",
|
||||
"Import-Package": "javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version=\"[1.4,2)\",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional"
|
||||
])
|
||||
}
|
||||
}
|
82
vendor/git.apache.org/thrift.git/lib/java/gradle/unitTests.gradle
generated
vendored
Normal file
82
vendor/git.apache.org/thrift.git/lib/java/gradle/unitTests.gradle
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Following Gradle best practices to keep build logic organized
|
||||
|
||||
// Bundle the test classes in a JAR for other Ant based builds
|
||||
task testJar(type: Jar, group: 'Build') {
|
||||
description = 'Assembles a jar archive containing the test classes.'
|
||||
project.test.dependsOn it
|
||||
|
||||
classifier 'test'
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Unit test tasks and configurations
|
||||
|
||||
// Help the up to date algorithm to make these tests done
|
||||
ext.markTaskDone = { task ->
|
||||
def buildFile = file("$buildDir/${task.name}.flag")
|
||||
task.inputs.files task.classpath
|
||||
task.outputs.file buildFile
|
||||
task.doLast {
|
||||
buildFile.text = 'Passed!'
|
||||
}
|
||||
}
|
||||
|
||||
task deprecatedEqualityTest(type: JavaExec, group: 'Verification') {
|
||||
description = 'Run the non-JUnit test suite '
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
main 'org.apache.thrift.test.EqualityTest'
|
||||
markTaskDone(it)
|
||||
}
|
||||
|
||||
task deprecatedJavaBeansTest(type: JavaExec, group: 'Verification') {
|
||||
description = 'Run the non-JUnit test suite '
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
main 'org.apache.thrift.test.JavaBeansTest'
|
||||
markTaskDone(it)
|
||||
}
|
||||
|
||||
// Main Unit Test task configuration
|
||||
test {
|
||||
description="Run the full test suite"
|
||||
dependsOn deprecatedEqualityTest, deprecatedJavaBeansTest
|
||||
|
||||
// Allow repeating tests even after successful execution
|
||||
if (project.hasProperty('rerunTests')) {
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
include '**/Test*.class'
|
||||
exclude '**/Test*\$*.class'
|
||||
|
||||
maxHeapSize = '512m'
|
||||
forkEvery = 1
|
||||
|
||||
systemProperties = [
|
||||
'build.test': "${compileTestJava.destinationDir}",
|
||||
'test.port': "${testPort}",
|
||||
'javax.net.ssl.trustStore': "${projectDir}/test/.truststore",
|
||||
'javax.net.ssl.trustStorePassword': 'thrift',
|
||||
'javax.net.ssl.keyStore': "${projectDir}/test/.keystore",
|
||||
'javax.net.ssl.keyStorePassword': 'thrift'
|
||||
]
|
||||
}
|
5
vendor/git.apache.org/thrift.git/lib/java/gradle/wrapper/gradle-wrapper.properties
generated
vendored
Normal file
5
vendor/git.apache.org/thrift.git/lib/java/gradle/wrapper/gradle-wrapper.properties
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
|
172
vendor/git.apache.org/thrift.git/lib/java/gradlew
generated
vendored
Executable file
172
vendor/git.apache.org/thrift.git/lib/java/gradlew
generated
vendored
Executable file
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
vendor/git.apache.org/thrift.git/lib/java/gradlew.bat
generated
vendored
Normal file
84
vendor/git.apache.org/thrift.git/lib/java/gradlew.bat
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
20
vendor/git.apache.org/thrift.git/lib/java/settings.gradle
generated
vendored
Normal file
20
vendor/git.apache.org/thrift.git/lib/java/settings.gradle
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
rootProject.name = 'libthrift'
|
|
@ -20,7 +20,6 @@ package org.apache.thrift;
|
|||
|
||||
import org.apache.thrift.async.AsyncMethodCallback;
|
||||
import org.apache.thrift.protocol.TMessage;
|
||||
import org.apache.thrift.protocol.TMessageType;
|
||||
import org.apache.thrift.protocol.TProtocol;
|
||||
import org.apache.thrift.server.AbstractNonblockingServer;
|
||||
|
||||
|
|
48
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/ProcessFunction.java
generated
vendored
48
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/ProcessFunction.java
generated
vendored
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.apache.thrift;
|
||||
|
||||
import org.apache.thrift.protocol.TMessage;
|
||||
import org.apache.thrift.protocol.TMessageType;
|
||||
import org.apache.thrift.protocol.TProtocol;
|
||||
import org.apache.thrift.protocol.TProtocolException;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -33,31 +31,51 @@ public abstract class ProcessFunction<I, T extends TBase> {
|
|||
return;
|
||||
}
|
||||
iprot.readMessageEnd();
|
||||
TBase result = null;
|
||||
TSerializable result = null;
|
||||
byte msgType = TMessageType.REPLY;
|
||||
|
||||
try {
|
||||
result = getResult(iface, args);
|
||||
} catch(TException tex) {
|
||||
LOGGER.error("Internal error processing " + getMethodName(), tex);
|
||||
if (!isOneway()) {
|
||||
TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR,
|
||||
"Internal error processing " + getMethodName());
|
||||
oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
|
||||
x.write(oprot);
|
||||
oprot.writeMessageEnd();
|
||||
oprot.getTransport().flush();
|
||||
} catch (TTransportException ex) {
|
||||
LOGGER.error("Transport error while processing " + getMethodName(), ex);
|
||||
throw ex;
|
||||
} catch (TApplicationException ex) {
|
||||
LOGGER.error("Internal application error processing " + getMethodName(), ex);
|
||||
result = ex;
|
||||
msgType = TMessageType.EXCEPTION;
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Internal error processing " + getMethodName(), ex);
|
||||
if(rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex);
|
||||
if(!isOneway()) {
|
||||
result = new TApplicationException(TApplicationException.INTERNAL_ERROR,
|
||||
"Internal error processing " + getMethodName());
|
||||
msgType = TMessageType.EXCEPTION;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isOneway()) {
|
||||
oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.REPLY, seqid));
|
||||
oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid));
|
||||
result.write(oprot);
|
||||
oprot.writeMessageEnd();
|
||||
oprot.getTransport().flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleException(int seqid, TProtocol oprot) throws TException {
|
||||
if (!isOneway()) {
|
||||
TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR,
|
||||
"Internal error processing " + getMethodName());
|
||||
oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
|
||||
x.write(oprot);
|
||||
oprot.writeMessageEnd();
|
||||
oprot.getTransport().flush();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean rethrowUnhandledExceptions(){
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract boolean isOneway();
|
||||
|
||||
public abstract TBase getResult(I iface, T args) throws TException;
|
||||
|
|
9
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TAsyncProcessor.java
generated
vendored
9
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TAsyncProcessor.java
generated
vendored
|
@ -18,14 +18,7 @@
|
|||
*/
|
||||
package org.apache.thrift;
|
||||
|
||||
import org.apache.thrift.protocol.*;
|
||||
|
||||
import org.apache.thrift.server.AbstractNonblockingServer.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer;
|
||||
|
||||
public interface TAsyncProcessor {
|
||||
/**
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TEnumHelper.java
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TEnumHelper.java
generated
vendored
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.apache.thrift;
|
||||
|
||||
import java.lang.InstantiationException;
|
||||
import java.lang.NoSuchMethodException;
|
||||
import java.lang.IllegalAccessException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
|
@ -52,6 +52,7 @@ public class TMultiplexedProcessor implements TProcessor {
|
|||
|
||||
private final Map<String,TProcessor> SERVICE_PROCESSOR_MAP
|
||||
= new HashMap<String,TProcessor>();
|
||||
private TProcessor defaultProcessor;
|
||||
|
||||
/**
|
||||
* 'Register' a service with this <code>TMultiplexedProcessor</code>. This
|
||||
|
@ -67,6 +68,14 @@ public class TMultiplexedProcessor implements TProcessor {
|
|||
SERVICE_PROCESSOR_MAP.put(serviceName, processor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a service to be called to process queries without service name
|
||||
* @param processor
|
||||
*/
|
||||
public void registerDefault(TProcessor processor) {
|
||||
defaultProcessor = processor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation of <code>process</code> performs the following steps:
|
||||
*
|
||||
|
@ -77,7 +86,7 @@ public class TMultiplexedProcessor implements TProcessor {
|
|||
* <li>Dispatch to the processor, with a decorated instance of TProtocol
|
||||
* that allows readMessageBegin() to return the original TMessage.</li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* @throws TException If the message type is not CALL or ONEWAY, if
|
||||
* the service name was not found in the message, or if the service
|
||||
* name was not found in the service map. You called {@link #registerProcessor(String, TProcessor) registerProcessor}
|
||||
|
@ -92,14 +101,16 @@ public class TMultiplexedProcessor implements TProcessor {
|
|||
TMessage message = iprot.readMessageBegin();
|
||||
|
||||
if (message.type != TMessageType.CALL && message.type != TMessageType.ONEWAY) {
|
||||
// TODO Apache Guys - Can the server ever get an EXCEPTION or REPLY?
|
||||
// TODO Should we check for this here?
|
||||
throw new TException("This should not have happened!?");
|
||||
}
|
||||
|
||||
// Extract the service name
|
||||
int index = message.name.indexOf(TMultiplexedProtocol.SEPARATOR);
|
||||
if (index < 0) {
|
||||
if (defaultProcessor != null) {
|
||||
// Dispatch processing to the stored processor
|
||||
return defaultProcessor.process(new StoredMessageProtocol(iprot, message), oprot);
|
||||
}
|
||||
throw new TException("Service name not found in message name: " + message.name + ". Did you " +
|
||||
"forget to use a TMultiplexProtocol in your client?");
|
||||
}
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TServiceClient.java
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/TServiceClient.java
generated
vendored
|
@ -81,7 +81,6 @@ public abstract class TServiceClient {
|
|||
iprot_.readMessageEnd();
|
||||
throw x;
|
||||
}
|
||||
System.out.format("Received %d%n", msg.seqid);
|
||||
if (msg.seqid != seqid_) {
|
||||
throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID,
|
||||
String.format("%s failed: out of sequence response: expected %d but got %d", methodName, seqid_, msg.seqid));
|
||||
|
|
33
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/annotation/Nullable.java
generated
vendored
Normal file
33
vendor/git.apache.org/thrift.git/lib/java/src/org/apache/thrift/annotation/Nullable.java
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Annotation indicating a field, method return, or method parameter may be {@code null}.
|
||||
* We package our own annotation to avoid a mandatory third-party dependency.
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface Nullable {
|
||||
|
||||
}
|
|
@ -373,6 +373,7 @@ public class TBinaryProtocol extends TProtocol {
|
|||
}
|
||||
|
||||
public String readStringBody(int size) throws TException {
|
||||
checkStringReadLength(size);
|
||||
try {
|
||||
byte[] buf = new byte[size];
|
||||
trans_.readAll(buf, 0, size);
|
||||
|
|
|
@ -141,7 +141,8 @@ public class TProtocolUtil {
|
|||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
throw new TProtocolException(TProtocolException.INVALID_DATA,
|
||||
"Unrecognized type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,6 @@
|
|||
|
||||
package org.apache.thrift.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.thrift.TAsyncProcessor;
|
||||
import org.apache.thrift.TByteArrayOutputStream;
|
||||
import org.apache.thrift.TException;
|
||||
|
@ -42,6 +33,15 @@ import org.apache.thrift.transport.TTransportException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Provides common methods and classes used by nonblocking TServer
|
||||
* implementations.
|
||||
|
@ -50,7 +50,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
protected final Logger LOGGER = LoggerFactory.getLogger(getClass().getName());
|
||||
|
||||
public static abstract class AbstractNonblockingServerArgs<T extends AbstractNonblockingServerArgs<T>> extends AbstractServerArgs<T> {
|
||||
public long maxReadBufferBytes = Long.MAX_VALUE;
|
||||
public long maxReadBufferBytes = 256 * 1024 * 1024;
|
||||
|
||||
public AbstractNonblockingServerArgs(TNonblockingServerTransport transport) {
|
||||
super(transport);
|
||||
|
@ -102,7 +102,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
|
||||
/**
|
||||
* Starts any threads required for serving.
|
||||
*
|
||||
*
|
||||
* @return true if everything went ok, false if threads could not be started.
|
||||
*/
|
||||
protected abstract boolean startThreads();
|
||||
|
@ -115,7 +115,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
|
||||
/**
|
||||
* Have the server transport start accepting connections.
|
||||
*
|
||||
*
|
||||
* @return true if we started listening successfully, false if something went
|
||||
* wrong.
|
||||
*/
|
||||
|
@ -139,7 +139,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
/**
|
||||
* Perform an invocation. This method could behave several different ways -
|
||||
* invoke immediately inline, queue for separate execution, etc.
|
||||
*
|
||||
*
|
||||
* @return true if invocation was successfully requested, which is not a
|
||||
* guarantee that invocation has completed. False if the request
|
||||
* failed.
|
||||
|
@ -152,7 +152,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
* corresponding to requests.
|
||||
*/
|
||||
protected abstract class AbstractSelectThread extends Thread {
|
||||
protected final Selector selector;
|
||||
protected Selector selector;
|
||||
|
||||
// List of FrameBuffers that want to change their selection interests.
|
||||
protected final Set<FrameBuffer> selectInterestChanges = new HashSet<FrameBuffer>();
|
||||
|
@ -285,21 +285,21 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
protected ByteBuffer buffer_;
|
||||
|
||||
protected final TByteArrayOutputStream response_;
|
||||
|
||||
|
||||
// the frame that the TTransport should wrap.
|
||||
protected final TMemoryInputTransport frameTrans_;
|
||||
|
||||
|
||||
// the transport that should be used to connect to clients
|
||||
protected final TTransport inTrans_;
|
||||
|
||||
|
||||
protected final TTransport outTrans_;
|
||||
|
||||
|
||||
// the input protocol to use on frames
|
||||
protected final TProtocol inProt_;
|
||||
|
||||
|
||||
// the output protocol to use on frames
|
||||
protected final TProtocol outProt_;
|
||||
|
||||
|
||||
// context associated with this connection
|
||||
protected final ServerContext context_;
|
||||
|
||||
|
@ -328,7 +328,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
/**
|
||||
* Give this FrameBuffer a chance to read. The selector loop should have
|
||||
* received a read event for this FrameBuffer.
|
||||
*
|
||||
*
|
||||
* @return true if the connection should live on, false if it should be
|
||||
* closed
|
||||
*/
|
||||
|
@ -455,7 +455,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
public void close() {
|
||||
// if we're being closed due to an error, we might have allocated a
|
||||
// buffer that we need to subtract for our memory accounting.
|
||||
if (state_ == FrameBufferState.READING_FRAME ||
|
||||
if (state_ == FrameBufferState.READING_FRAME ||
|
||||
state_ == FrameBufferState.READ_FRAME_COMPLETE ||
|
||||
state_ == FrameBufferState.AWAITING_CLOSE) {
|
||||
readBufferBytesAllocated.addAndGet(-buffer_.array().length);
|
||||
|
@ -510,7 +510,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
public void invoke() {
|
||||
frameTrans_.reset(buffer_.array());
|
||||
response_.reset();
|
||||
|
||||
|
||||
try {
|
||||
if (eventHandler_ != null) {
|
||||
eventHandler_.processContext(context_, inTrans_, outTrans_);
|
||||
|
@ -530,7 +530,7 @@ public abstract class AbstractNonblockingServer extends TServer {
|
|||
|
||||
/**
|
||||
* Perform a read into buffer.
|
||||
*
|
||||
*
|
||||
* @return true if the read succeeded, false if there was an error or the
|
||||
* connection closed.
|
||||
*/
|
||||
|
|
|
@ -63,7 +63,7 @@ public abstract class TExtensibleServlet extends HttpServlet {
|
|||
* Returns the appropriate {@link TProcessor}. This will be called <b>once</b> just
|
||||
* after the {@link #init()} method
|
||||
*
|
||||
* @return
|
||||
* @return the appropriate {@link TProcessor}
|
||||
*/
|
||||
protected abstract TProcessor getProcessor();
|
||||
|
||||
|
@ -71,7 +71,7 @@ public abstract class TExtensibleServlet extends HttpServlet {
|
|||
* Returns the appropriate in {@link TProtocolFactory}. This will be called
|
||||
* <b>once</b> just after the {@link #init()} method
|
||||
*
|
||||
* @return
|
||||
* @return the appropriate in {@link TProtocolFactory}
|
||||
*/
|
||||
protected abstract TProtocolFactory getInProtocolFactory();
|
||||
|
||||
|
@ -79,7 +79,7 @@ public abstract class TExtensibleServlet extends HttpServlet {
|
|||
* Returns the appropriate out {@link TProtocolFactory}. This will be called
|
||||
* <b>once</b> just after the {@link #init()} method
|
||||
*
|
||||
* @return
|
||||
* @return the appropriate out {@link TProtocolFactory}
|
||||
*/
|
||||
protected abstract TProtocolFactory getOutProtocolFactory();
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@ public class THsHaServer extends TNonblockingServer {
|
|||
return invoker;
|
||||
}
|
||||
|
||||
protected ExecutorService getInvoker() {
|
||||
return invoker;
|
||||
}
|
||||
|
||||
protected void gracefullyShutdownInvokerPool() {
|
||||
// try to gracefully shut down the executor service
|
||||
|
|
|
@ -75,6 +75,11 @@ public class TThreadPoolServer extends TServer {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Args stopTimeoutUnit(TimeUnit tu) {
|
||||
stopTimeoutUnit = tu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Args requestTimeout(int n) {
|
||||
requestTimeout = n;
|
||||
return this;
|
||||
|
@ -136,26 +141,44 @@ public class TThreadPoolServer extends TServer {
|
|||
return new ThreadPoolExecutor(args.minWorkerThreads,
|
||||
args.maxWorkerThreads,
|
||||
args.stopTimeoutVal,
|
||||
TimeUnit.SECONDS,
|
||||
args.stopTimeoutUnit,
|
||||
executorQueue);
|
||||
}
|
||||
|
||||
|
||||
public void serve() {
|
||||
try {
|
||||
protected ExecutorService getExecutorService() {
|
||||
return executorService_;
|
||||
}
|
||||
|
||||
protected boolean preServe() {
|
||||
try {
|
||||
serverTransport_.listen();
|
||||
} catch (TTransportException ttx) {
|
||||
LOGGER.error("Error occurred during listening.", ttx);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Run the preServe event
|
||||
if (eventHandler_ != null) {
|
||||
eventHandler_.preServe();
|
||||
}
|
||||
|
||||
stopped_ = false;
|
||||
setServing(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void serve() {
|
||||
if (!preServe()) {
|
||||
return;
|
||||
}
|
||||
|
||||
execute();
|
||||
waitForShutdown();
|
||||
|
||||
setServing(false);
|
||||
}
|
||||
|
||||
protected void execute() {
|
||||
int failureCount = 0;
|
||||
while (!stopped_) {
|
||||
try {
|
||||
|
@ -208,8 +231,10 @@ public class TThreadPoolServer extends TServer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
executorService_.shutdown();
|
||||
}
|
||||
|
||||
protected void waitForShutdown() {
|
||||
executorService_.shutdown();
|
||||
|
||||
// Loop until awaitTermination finally does return without a interrupted
|
||||
// exception. If we don't do this, then we'll shut down prematurely. We want
|
||||
|
@ -227,7 +252,6 @@ public class TThreadPoolServer extends TServer {
|
|||
now = newnow;
|
||||
}
|
||||
}
|
||||
setServing(false);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
@ -269,7 +293,7 @@ public class TThreadPoolServer extends TServer {
|
|||
inputTransport = inputTransportFactory_.getTransport(client_);
|
||||
outputTransport = outputTransportFactory_.getTransport(client_);
|
||||
inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
|
||||
outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
|
||||
outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
|
||||
|
||||
eventHandler = getEventHandler();
|
||||
if (eventHandler != null) {
|
||||
|
@ -287,14 +311,24 @@ public class TThreadPoolServer extends TServer {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} catch (TSaslTransportException ttx) {
|
||||
// Something thats not SASL was in the stream, continue silently
|
||||
} catch (TTransportException ttx) {
|
||||
// Assume the client died and continue silently
|
||||
} catch (TException tx) {
|
||||
LOGGER.error("Thrift error occurred during processing of message.", tx);
|
||||
} catch (Exception x) {
|
||||
LOGGER.error("Error occurred during processing of message.", x);
|
||||
// We'll usually receive RuntimeException types here
|
||||
// Need to unwrap to ascertain real causing exception before we choose to ignore
|
||||
Throwable realCause = x.getCause();
|
||||
// Ignore err-logging all transport-level/type exceptions
|
||||
if ((realCause != null && realCause instanceof TTransportException)
|
||||
|| (x instanceof TTransportException)) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
// Write to debug, just in case the exception gets required
|
||||
LOGGER
|
||||
.debug("Received TTransportException during processing of message, ignoring: ", x);
|
||||
}
|
||||
} else {
|
||||
// Log the exception at error level and continue
|
||||
LOGGER.error("Error occurred during processing of message.", x);
|
||||
}
|
||||
} finally {
|
||||
if (eventHandler != null) {
|
||||
eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
|
||||
|
|
|
@ -19,7 +19,15 @@
|
|||
|
||||
package org.apache.thrift.server;
|
||||
|
||||
import org.apache.thrift.transport.TNonblockingServerTransport;
|
||||
import org.apache.thrift.transport.TNonblockingTransport;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
|
@ -37,24 +45,18 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.thrift.transport.TNonblockingServerTransport;
|
||||
import org.apache.thrift.transport.TNonblockingTransport;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A Half-Sync/Half-Async server with a separate pool of threads to handle
|
||||
* non-blocking I/O. Accepts are handled on a single thread, and a configurable
|
||||
* number of nonblocking selector threads manage reading and writing of client
|
||||
* connections. A synchronous worker thread pool handles processing of requests.
|
||||
*
|
||||
*
|
||||
* Performs better than TNonblockingServer/THsHaServer in multi-core
|
||||
* environments when the the bottleneck is CPU on the single selector thread
|
||||
* handling I/O. In addition, because the accept handling is decoupled from
|
||||
* reads/writes and invocation, the server has better ability to handle back-
|
||||
* pressure from new connections (e.g. stop accepting when busy).
|
||||
*
|
||||
*
|
||||
* Like TNonblockingServer, it relies on the use of TFramedTransport.
|
||||
*/
|
||||
public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
||||
|
@ -205,7 +207,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
|
||||
/**
|
||||
* Start the accept and selector threads running to deal with clients.
|
||||
*
|
||||
*
|
||||
* @return true if everything went ok, false if we couldn't start for some
|
||||
* reason.
|
||||
*/
|
||||
|
@ -349,7 +351,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
|
||||
/**
|
||||
* Set up the AcceptThead
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public AcceptThread(TNonblockingServerTransport serverTransport,
|
||||
|
@ -478,10 +480,13 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
|
||||
// Accepted connections added by the accept thread.
|
||||
private final BlockingQueue<TNonblockingTransport> acceptedQueue;
|
||||
private int SELECTOR_AUTO_REBUILD_THRESHOLD = 512;
|
||||
private long MONITOR_PERIOD = 1000L;
|
||||
private int jvmBug = 0;
|
||||
|
||||
/**
|
||||
* Set up the SelectorThread with an unbounded queue for incoming accepts.
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* if a selector cannot be created
|
||||
*/
|
||||
|
@ -491,7 +496,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
|
||||
/**
|
||||
* Set up the SelectorThread with an bounded queue for incoming accepts.
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* if a selector cannot be created
|
||||
*/
|
||||
|
@ -501,7 +506,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
|
||||
/**
|
||||
* Set up the SelectorThread with a specified queue for connections.
|
||||
*
|
||||
*
|
||||
* @param acceptedQueue
|
||||
* The BlockingQueue implementation for holding incoming accepted
|
||||
* connections.
|
||||
|
@ -515,7 +520,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
/**
|
||||
* Hands off an accepted connection to be handled by this thread. This
|
||||
* method will block if the queue for new connections is at capacity.
|
||||
*
|
||||
*
|
||||
* @param accepted
|
||||
* The connection that has been accepted.
|
||||
* @return true if the connection has been successfully added.
|
||||
|
@ -566,8 +571,8 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
*/
|
||||
private void select() {
|
||||
try {
|
||||
// wait for io events.
|
||||
selector.select();
|
||||
|
||||
doSelect();
|
||||
|
||||
// process the io events we received
|
||||
Iterator<SelectionKey> selectedKeys = selector.selectedKeys().iterator();
|
||||
|
@ -596,6 +601,77 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do select and judge epoll bug happen.
|
||||
* See : https://issues.apache.org/jira/browse/THRIFT-4251
|
||||
*/
|
||||
private void doSelect() throws IOException {
|
||||
long beforeSelect = System.currentTimeMillis();
|
||||
int selectedNums = selector.select();
|
||||
long afterSelect = System.currentTimeMillis();
|
||||
|
||||
if (selectedNums == 0) {
|
||||
jvmBug++;
|
||||
} else {
|
||||
jvmBug = 0;
|
||||
}
|
||||
|
||||
long selectedTime = afterSelect - beforeSelect;
|
||||
if (selectedTime >= MONITOR_PERIOD) {
|
||||
jvmBug = 0;
|
||||
} else if (jvmBug > SELECTOR_AUTO_REBUILD_THRESHOLD) {
|
||||
LOGGER.warn("In {} ms happen {} times jvm bug; rebuilding selector.", MONITOR_PERIOD, jvmBug);
|
||||
rebuildSelector();
|
||||
selector.selectNow();
|
||||
jvmBug = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the current Selector of this SelectorThread with newly created Selector to work
|
||||
* around the infamous epoll 100% CPU bug.
|
||||
*/
|
||||
private synchronized void rebuildSelector() {
|
||||
final Selector oldSelector = selector;
|
||||
if (oldSelector == null) {
|
||||
return;
|
||||
}
|
||||
Selector newSelector = null;
|
||||
try {
|
||||
newSelector = Selector.open();
|
||||
LOGGER.warn("Created new Selector.");
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Create new Selector error.", e);
|
||||
}
|
||||
|
||||
for (SelectionKey key : oldSelector.selectedKeys()) {
|
||||
if (!key.isValid() && key.readyOps() == 0)
|
||||
continue;
|
||||
SelectableChannel channel = key.channel();
|
||||
Object attachment = key.attachment();
|
||||
|
||||
try {
|
||||
if (attachment == null) {
|
||||
channel.register(newSelector, key.readyOps());
|
||||
} else {
|
||||
channel.register(newSelector, key.readyOps(), attachment);
|
||||
}
|
||||
} catch (ClosedChannelException e) {
|
||||
LOGGER.error("Register new selector key error.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
selector = newSelector;
|
||||
try {
|
||||
oldSelector.close();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Close old selector error.", e);
|
||||
}
|
||||
LOGGER.warn("Replace new selector success.");
|
||||
}
|
||||
|
||||
private void processAcceptedConnections() {
|
||||
// Register accepted connections
|
||||
while (!stopped_) {
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class TByteBuffer extends TTransport {
|
|||
final int n = Math.min(byteBuffer.remaining(), len);
|
||||
if (n > 0) {
|
||||
try {
|
||||
byteBuffer.get(buf, off, len);
|
||||
byteBuffer.get(buf, off, n);
|
||||
} catch (BufferUnderflowException e) {
|
||||
throw new TTransportException("Unexpected end of input buffer", e);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,8 @@ public class TFastFramedTransport extends TTransport {
|
|||
|
||||
private final TTransport underlying;
|
||||
private final AutoExpandingBufferWriteTransport writeBuffer;
|
||||
private final AutoExpandingBufferReadTransport readBuffer;
|
||||
private AutoExpandingBufferReadTransport readBuffer;
|
||||
private final int initialBufferCapacity;
|
||||
private final byte[] i32buf = new byte[4];
|
||||
private final int maxLength;
|
||||
|
||||
|
@ -104,6 +105,7 @@ public class TFastFramedTransport extends TTransport {
|
|||
public TFastFramedTransport(TTransport underlying, int initialBufferCapacity, int maxLength) {
|
||||
this.underlying = underlying;
|
||||
this.maxLength = maxLength;
|
||||
this.initialBufferCapacity = initialBufferCapacity;
|
||||
writeBuffer = new AutoExpandingBufferWriteTransport(initialBufferCapacity, 1.5);
|
||||
readBuffer = new AutoExpandingBufferReadTransport(initialBufferCapacity, 1.5);
|
||||
}
|
||||
|
@ -164,6 +166,10 @@ public class TFastFramedTransport extends TTransport {
|
|||
readBuffer.consumeBuffer(len);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
readBuffer = new AutoExpandingBufferReadTransport(initialBufferCapacity, 1.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws TTransportException {
|
||||
int length = writeBuffer.getPos();
|
||||
|
|
|
@ -366,7 +366,7 @@ public class TFileTransport extends TTransport {
|
|||
currentEvent_ = new Event(new byte [256]);
|
||||
|
||||
if(!readOnly_)
|
||||
outputStream_ = new BufferedOutputStream(inputFile_.getOutputStream(), 8192);
|
||||
outputStream_ = new BufferedOutputStream(inputFile_.getOutputStream());
|
||||
} catch (IOException iox) {
|
||||
throw new TTransportException(TTransportException.NOT_OPEN, iox);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ public class TFramedTransport extends TTransport {
|
|||
/**
|
||||
* Buffer for input
|
||||
*/
|
||||
private TMemoryInputTransport readBuffer_ = new TMemoryInputTransport(new byte[0]);
|
||||
private final TMemoryInputTransport readBuffer_ =
|
||||
new TMemoryInputTransport(new byte[0]);
|
||||
|
||||
public static class Factory extends TTransportFactory {
|
||||
private int maxLength_;
|
||||
|
@ -90,11 +91,9 @@ public class TFramedTransport extends TTransport {
|
|||
}
|
||||
|
||||
public int read(byte[] buf, int off, int len) throws TTransportException {
|
||||
if (readBuffer_ != null) {
|
||||
int got = readBuffer_.read(buf, off, len);
|
||||
if (got > 0) {
|
||||
return got;
|
||||
}
|
||||
int got = readBuffer_.read(buf, off, len);
|
||||
if (got > 0) {
|
||||
return got;
|
||||
}
|
||||
|
||||
// Read another frame of data
|
||||
|
@ -123,6 +122,10 @@ public class TFramedTransport extends TTransport {
|
|||
readBuffer_.consumeBuffer(len);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
readBuffer_.clear();
|
||||
}
|
||||
|
||||
private final byte[] i32buf = new byte[4];
|
||||
|
||||
private void readFrame() throws TTransportException {
|
||||
|
|
|
@ -304,6 +304,9 @@ public class THttpClient extends TTransport {
|
|||
throw new TTransportException(ioe);
|
||||
}
|
||||
}
|
||||
if (post != null) {
|
||||
post.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class TNonblockingServerSocket extends TNonblockingServerTransport {
|
|||
serverSocket_.bind(args.bindAddr, args.backlog);
|
||||
} catch (IOException ioe) {
|
||||
serverSocket_ = null;
|
||||
throw new TTransportException("Could not create ServerSocket on address " + args.bindAddr.toString() + ".");
|
||||
throw new TTransportException("Could not create ServerSocket on address " + args.bindAddr.toString() + ".", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,11 @@ public class TSSLTransportFactory {
|
|||
if (params.isTrustStoreSet) {
|
||||
tmf = TrustManagerFactory.getInstance(params.trustManagerType);
|
||||
KeyStore ts = KeyStore.getInstance(params.trustStoreType);
|
||||
in = getStoreAsStream(params.trustStore);
|
||||
if (params.trustStoreStream != null) {
|
||||
in = params.trustStoreStream;
|
||||
} else {
|
||||
in = getStoreAsStream(params.trustStore);
|
||||
}
|
||||
ts.load(in,
|
||||
(params.trustPass != null ? params.trustPass.toCharArray() : null));
|
||||
tmf.init(ts);
|
||||
|
@ -195,7 +199,11 @@ public class TSSLTransportFactory {
|
|||
if (params.isKeyStoreSet) {
|
||||
kmf = KeyManagerFactory.getInstance(params.keyManagerType);
|
||||
KeyStore ks = KeyStore.getInstance(params.keyStoreType);
|
||||
is = getStoreAsStream(params.keyStore);
|
||||
if (params.keyStoreStream != null) {
|
||||
is = params.keyStoreStream;
|
||||
} else {
|
||||
is = getStoreAsStream(params.keyStore);
|
||||
}
|
||||
ks.load(is, params.keyPass.toCharArray());
|
||||
kmf.init(ks, params.keyPass.toCharArray());
|
||||
}
|
||||
|
@ -273,10 +281,12 @@ public class TSSLTransportFactory {
|
|||
public static class TSSLTransportParameters {
|
||||
protected String protocol = "TLS";
|
||||
protected String keyStore;
|
||||
protected InputStream keyStoreStream;
|
||||
protected String keyPass;
|
||||
protected String keyManagerType = KeyManagerFactory.getDefaultAlgorithm();
|
||||
protected String keyStoreType = "JKS";
|
||||
protected String trustStore;
|
||||
protected InputStream trustStoreStream;
|
||||
protected String trustPass;
|
||||
protected String trustManagerType = TrustManagerFactory.getDefaultAlgorithm();
|
||||
protected String trustStoreType = "JKS";
|
||||
|
@ -332,7 +342,20 @@ public class TSSLTransportFactory {
|
|||
}
|
||||
isKeyStoreSet = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the keystore, password, certificate type and the store type
|
||||
*
|
||||
* @param keyStoreStream Keystore content input stream
|
||||
* @param keyPass Keystore password
|
||||
* @param keyManagerType The default is X509
|
||||
* @param keyStoreType The default is JKS
|
||||
*/
|
||||
public void setKeyStore(InputStream keyStoreStream, String keyPass, String keyManagerType, String keyStoreType) {
|
||||
this.keyStoreStream = keyStoreStream;
|
||||
setKeyStore("", keyPass, keyManagerType, keyStoreType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the keystore and password
|
||||
*
|
||||
|
@ -342,7 +365,17 @@ public class TSSLTransportFactory {
|
|||
public void setKeyStore(String keyStore, String keyPass) {
|
||||
setKeyStore(keyStore, keyPass, null, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the keystore and password
|
||||
*
|
||||
* @param keyStoreStream Keystore content input stream
|
||||
* @param keyPass Keystore password
|
||||
*/
|
||||
public void setKeyStore(InputStream keyStoreStream, String keyPass) {
|
||||
setKeyStore(keyStoreStream, keyPass, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the truststore, password, certificate type and the store type
|
||||
*
|
||||
|
@ -362,6 +395,19 @@ public class TSSLTransportFactory {
|
|||
}
|
||||
isTrustStoreSet = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the truststore, password, certificate type and the store type
|
||||
*
|
||||
* @param trustStoreStream Truststore content input stream
|
||||
* @param trustPass Truststore password
|
||||
* @param trustManagerType The default is X509
|
||||
* @param trustStoreType The default is JKS
|
||||
*/
|
||||
public void setTrustStore(InputStream trustStoreStream, String trustPass, String trustManagerType, String trustStoreType) {
|
||||
this.trustStoreStream = trustStoreStream;
|
||||
setTrustStore("", trustPass, trustManagerType, trustStoreType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the truststore and password
|
||||
|
@ -372,6 +418,16 @@ public class TSSLTransportFactory {
|
|||
public void setTrustStore(String trustStore, String trustPass) {
|
||||
setTrustStore(trustStore, trustPass, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the truststore and password
|
||||
*
|
||||
* @param trustStoreStream Truststore content input stream
|
||||
* @param trustPass Truststore password
|
||||
*/
|
||||
public void setTrustStore(InputStream trustStoreStream, String trustPass) {
|
||||
setTrustStore(trustStoreStream, trustPass, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if client authentication is required
|
||||
|
@ -380,6 +436,6 @@ public class TSSLTransportFactory {
|
|||
*/
|
||||
public void requireClientAuth(boolean clientAuth) {
|
||||
this.clientAuth = clientAuth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ abstract class TSaslTransport extends TTransport {
|
|||
if (message.status == NegotiationStatus.COMPLETE &&
|
||||
getRole() == SaslRole.CLIENT) {
|
||||
LOGGER.debug("{}: All done!", getRole());
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
sendSaslMessage(sasl.isComplete() ? NegotiationStatus.COMPLETE : NegotiationStatus.OK,
|
||||
|
@ -295,8 +295,6 @@ abstract class TSaslTransport extends TTransport {
|
|||
}
|
||||
LOGGER.debug("{}: Main negotiation loop complete", getRole());
|
||||
|
||||
assert sasl.isComplete();
|
||||
|
||||
// If we're the client, and we're complete, but the server isn't
|
||||
// complete yet, we need to wait for its response. This will occur
|
||||
// with ANONYMOUS auth, for example, where we send an initial response
|
||||
|
|
|
@ -111,7 +111,7 @@ public class TServerSocket extends TServerTransport {
|
|||
}
|
||||
|
||||
public void listen() throws TTransportException {
|
||||
// Make sure not to block on accept
|
||||
// Make sure to block on accept
|
||||
if (serverSocket_ != null) {
|
||||
try {
|
||||
serverSocket_.setSoTimeout(0);
|
||||
|
|
|
@ -80,8 +80,8 @@ public class TSocket extends TIOStreamTransport {
|
|||
|
||||
if (isOpen()) {
|
||||
try {
|
||||
inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
|
||||
outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
|
||||
inputStream_ = new BufferedInputStream(socket_.getInputStream());
|
||||
outputStream_ = new BufferedOutputStream(socket_.getOutputStream());
|
||||
} catch (IOException iox) {
|
||||
close();
|
||||
throw new TTransportException(TTransportException.NOT_OPEN, iox);
|
||||
|
@ -219,8 +219,8 @@ public class TSocket extends TIOStreamTransport {
|
|||
|
||||
try {
|
||||
socket_.connect(new InetSocketAddress(host_, port_), connectTimeout_);
|
||||
inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
|
||||
outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
|
||||
inputStream_ = new BufferedInputStream(socket_.getInputStream());
|
||||
outputStream_ = new BufferedOutputStream(socket_.getOutputStream());
|
||||
} catch (IOException iox) {
|
||||
close();
|
||||
throw new TTransportException(TTransportException.NOT_OPEN, iox);
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/Fixtures.java
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/Fixtures.java
generated
vendored
|
@ -277,7 +277,7 @@ public class Fixtures {
|
|||
nesting = new Nesting(bonk, oneOfEach);
|
||||
|
||||
holyMoley = new HolyMoley();
|
||||
ArrayList big = new ArrayList<OneOfEach>();
|
||||
List<OneOfEach> big = new ArrayList<OneOfEach>();
|
||||
big.add(new OneOfEach(oneOfEach));
|
||||
big.add(nesting.my_ooe);
|
||||
holyMoley.setBig(big);
|
||||
|
|
34
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestDeepCopy.java
generated
vendored
Normal file
34
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestDeepCopy.java
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
package org.apache.thrift;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import thrift.test.DeepCopyBar;
|
||||
import thrift.test.DeepCopyFoo;
|
||||
|
||||
public class TestDeepCopy extends TestCase {
|
||||
|
||||
public void testDeepCopy() throws Exception {
|
||||
final DeepCopyFoo foo = new DeepCopyFoo();
|
||||
|
||||
foo.addToL(new DeepCopyBar());
|
||||
foo.addToS(new DeepCopyBar());
|
||||
foo.putToM("test 3", new DeepCopyBar());
|
||||
|
||||
foo.addToLi(new thrift.test.Object());
|
||||
foo.addToSi(new thrift.test.Object());
|
||||
foo.putToMi("test 3", new thrift.test.Object());
|
||||
|
||||
foo.setBar(new DeepCopyBar());
|
||||
|
||||
final DeepCopyFoo deepCopyFoo = foo.deepCopy();
|
||||
|
||||
assertNotSame(foo.getBar(), deepCopyFoo.getBar());
|
||||
|
||||
assertNotSame(foo.getL().get(0), deepCopyFoo.getL().get(0));
|
||||
assertNotSame(foo.getS().toArray(new DeepCopyBar[0])[0], deepCopyFoo.getS().toArray(new DeepCopyBar[0])[0]);
|
||||
assertNotSame(foo.getM().get("test 3"), deepCopyFoo.getM().get("test 3"));
|
||||
|
||||
assertNotSame(foo.getLi().get(0), deepCopyFoo.getLi().get(0));
|
||||
assertNotSame(foo.getSi().toArray(new thrift.test.Object[0])[0], deepCopyFoo.getSi().toArray(new thrift.test.Object[0])[0]);
|
||||
assertNotSame(foo.getMi().get("test 3"), deepCopyFoo.getMi().get("test 3"));
|
||||
}
|
||||
}
|
81
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestEnumContainers.java
generated
vendored
Normal file
81
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestEnumContainers.java
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import thrift.test.enumcontainers.EnumContainersTestConstants;
|
||||
import thrift.test.enumcontainers.GodBean;
|
||||
import thrift.test.enumcontainers.GreekGodGoddess;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TestEnumContainers extends TestCase {
|
||||
|
||||
public void testEnumContainers() throws Exception {
|
||||
final GodBean b1 = new GodBean();
|
||||
b1.addToGoddess(GreekGodGoddess.HERA);
|
||||
b1.getGoddess().add(GreekGodGoddess.APHRODITE);
|
||||
b1.putToPower(GreekGodGoddess.ZEUS, 1000);
|
||||
b1.getPower().put(GreekGodGoddess.HERA, 333);
|
||||
b1.putToByAlias("Mr. Z", GreekGodGoddess.ZEUS);
|
||||
b1.addToImages("Baths of Aphrodite 01.jpeg");
|
||||
|
||||
final GodBean b2 = new GodBean(b1);
|
||||
|
||||
final GodBean b3 = new GodBean();
|
||||
{
|
||||
final TSerializer serializer = new TSerializer();
|
||||
final TDeserializer deserializer = new TDeserializer();
|
||||
|
||||
final byte[] bytes = serializer.serialize(b1);
|
||||
deserializer.deserialize(b3, bytes);
|
||||
}
|
||||
|
||||
assertTrue(b1.getGoddess() != b2.getGoddess());
|
||||
assertTrue(b1.getPower() != b2.getPower());
|
||||
|
||||
assertTrue(b1.getGoddess() != b3.getGoddess());
|
||||
assertTrue(b1.getPower() != b3.getPower());
|
||||
|
||||
for (GodBean each : new GodBean[]{b1, b2, b3}) {
|
||||
assertTrue(each.getGoddess().contains(GreekGodGoddess.HERA));
|
||||
assertFalse(each.getGoddess().contains(GreekGodGoddess.POSEIDON));
|
||||
assertTrue(each.getGoddess() instanceof EnumSet);
|
||||
|
||||
assertEquals(Integer.valueOf(1000), each.getPower().get(GreekGodGoddess.ZEUS));
|
||||
assertEquals(Integer.valueOf(333), each.getPower().get(GreekGodGoddess.HERA));
|
||||
assertTrue(each.getPower() instanceof EnumMap);
|
||||
|
||||
assertTrue(each.getByAlias() instanceof HashMap);
|
||||
assertTrue(each.getImages() instanceof HashSet);
|
||||
}
|
||||
}
|
||||
|
||||
public void testEnumConstants() {
|
||||
assertEquals("lightning bolt", EnumContainersTestConstants.ATTRIBUTES.get(GreekGodGoddess.ZEUS));
|
||||
assertTrue(EnumContainersTestConstants.ATTRIBUTES instanceof EnumMap);
|
||||
|
||||
assertTrue(EnumContainersTestConstants.BEAUTY.contains(GreekGodGoddess.APHRODITE));
|
||||
assertTrue(EnumContainersTestConstants.BEAUTY instanceof EnumSet);
|
||||
}
|
||||
}
|
86
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java
generated
vendored
Normal file
86
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestMultiplexedProcessor.java
generated
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.thrift.protocol.TMessage;
|
||||
import org.apache.thrift.protocol.TMessageType;
|
||||
import org.apache.thrift.protocol.TProtocol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestMultiplexedProcessor {
|
||||
private TMultiplexedProcessor mp;
|
||||
private TProtocol iprot;
|
||||
private TProtocol oprot;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mp = new TMultiplexedProcessor();
|
||||
iprot = mock(TProtocol.class);
|
||||
oprot = mock(TProtocol.class);
|
||||
}
|
||||
|
||||
@Test(expected = TException.class)
|
||||
public void testWrongMessageType() throws TException {
|
||||
when (iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.REPLY, 42));
|
||||
mp.process(iprot, oprot);
|
||||
}
|
||||
|
||||
@Test(expected = TException.class)
|
||||
public void testNoSuchService() throws TException {
|
||||
when(iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.CALL, 42));
|
||||
|
||||
mp.process(iprot, oprot);
|
||||
}
|
||||
|
||||
static class StubProcessor implements TProcessor {
|
||||
@Override
|
||||
public boolean process(TProtocol in, TProtocol out) throws TException {
|
||||
TMessage msg = in.readMessageBegin();
|
||||
if (!"func".equals(msg.name) || msg.type!=TMessageType.CALL || msg.seqid!=42) {
|
||||
throw new TException("incorrect parameters");
|
||||
}
|
||||
out.writeMessageBegin(new TMessage("func", TMessageType.REPLY, 42));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingService() throws TException {
|
||||
when(iprot.readMessageBegin()).thenReturn(new TMessage("service:func", TMessageType.CALL, 42));
|
||||
mp.registerProcessor("service", new StubProcessor());
|
||||
mp.process(iprot, oprot);
|
||||
verify(oprot).writeMessageBegin(any(TMessage.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultService() throws TException {
|
||||
when(iprot.readMessageBegin()).thenReturn(new TMessage("func", TMessageType.CALL, 42));
|
||||
mp.registerDefault(new StubProcessor());
|
||||
mp.process(iprot, oprot);
|
||||
verify(oprot).writeMessageBegin(any(TMessage.class));
|
||||
}
|
||||
|
||||
}
|
179
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestRenderedDoubleConstants.java
generated
vendored
Normal file
179
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestRenderedDoubleConstants.java
generated
vendored
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift;
|
||||
|
||||
import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import thrift.test.DoubleConstantsTestConstants;
|
||||
|
||||
public class TestRenderedDoubleConstants extends TestCase {
|
||||
private static final double EPSILON = 0.0000001;
|
||||
private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST =
|
||||
"failed to verify a double constant generated by Thrift (expected = %f, got = %f)";
|
||||
private static final String ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST =
|
||||
"failed to verify a list item by Thrift (expected = %f, got = %f)";
|
||||
private static final String ASSERTION_MESSAGE_FOR_TYPE_CHECKS =
|
||||
"the rendered variable with name %s is not of double type";
|
||||
|
||||
// to make sure lists containing doubles are generated correctly
|
||||
public void testRenderedDoubleList() throws Exception {
|
||||
final double[] EXPECTED_LIST =
|
||||
{1d,-100d,100d,9223372036854775807d,-9223372036854775807d,3.14159265359,1000000.1,-1000000.1,1.7e+308,
|
||||
-1.7e+308,9223372036854775816.43,-9223372036854775816.43};
|
||||
assertEquals(EXPECTED_LIST.length, DoubleConstantsTestConstants.DOUBLE_LIST_TEST.size());
|
||||
for (int i = 0; i < EXPECTED_LIST.length; ++i) {
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_LIST_TEST,
|
||||
EXPECTED_LIST[i],
|
||||
DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i)),
|
||||
EXPECTED_LIST[i], DoubleConstantsTestConstants.DOUBLE_LIST_TEST.get(i), EPSILON);
|
||||
}
|
||||
}
|
||||
|
||||
// to make sure the variables inside Thrift files are generated correctly
|
||||
public void testRenderedDoubleConstants() throws Exception {
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT = 1.0;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT = -100.0;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT = 9223372036854775807.0;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT = -9223372036854775807.0;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS = 3.14159265359;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE = 1000000.1;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE = -1000000.1;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE = 1.7e+308;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE = 9223372036854775816.43;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE = -1.7e+308;
|
||||
final double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE = -9223372036854775816.43;
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST, EPSILON);
|
||||
assertEquals(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_RENDERED_DOUBLE_CONSTANTS_TEST,
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST),
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE,
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST, EPSILON);
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST));
|
||||
//assertTrue(
|
||||
// String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST"),
|
||||
// Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST));
|
||||
assertTrue(
|
||||
String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST"),
|
||||
Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST));
|
||||
//assertTrue(
|
||||
// String.format(ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST"),
|
||||
// Double.class.isInstance(DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST));
|
||||
assertTrue(
|
||||
String.format(
|
||||
ASSERTION_MESSAGE_FOR_TYPE_CHECKS, "DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST"),
|
||||
Double.class.isInstance(
|
||||
DoubleConstantsTestConstants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST));
|
||||
}
|
||||
}
|
3
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestReuse.java
generated
vendored
3
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestReuse.java
generated
vendored
|
@ -21,10 +21,7 @@ package org.apache.thrift;
|
|||
|
||||
import java.util.HashSet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.thrift.protocol.TBinaryProtocol;
|
||||
import org.apache.thrift.protocol.TType;
|
||||
|
||||
import thrift.test.Reuse;
|
||||
|
||||
|
|
146
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestUnsafeBinaries.java
generated
vendored
Normal file
146
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/TestUnsafeBinaries.java
generated
vendored
Normal file
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import thrift.test.SafeBytes;
|
||||
import thrift.test.UnsafeBytes;
|
||||
|
||||
// test generating types with un-copied byte[]/ByteBuffer input/output
|
||||
//
|
||||
public class TestUnsafeBinaries extends TestStruct {
|
||||
|
||||
private static byte[] input() {
|
||||
return new byte[]{1, 1};
|
||||
}
|
||||
|
||||
//
|
||||
// verify that the unsafe_binaries option modifies behavior
|
||||
//
|
||||
|
||||
// constructor doesn't copy
|
||||
public void testUnsafeConstructor() throws Exception {
|
||||
|
||||
byte[] input = input();
|
||||
UnsafeBytes struct = new UnsafeBytes(ByteBuffer.wrap(input));
|
||||
|
||||
input[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{2, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// getter doesn't copy
|
||||
// note: this behavior is the same with/without the flag, but if this default ever changes, the current behavior
|
||||
// should be retained when using this flag
|
||||
public void testUnsafeGetter(){
|
||||
UnsafeBytes struct = new UnsafeBytes(ByteBuffer.wrap(input()));
|
||||
|
||||
byte[] val = struct.getBytes();
|
||||
val[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{2, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// setter doesn't copy
|
||||
public void testUnsafeSetter(){
|
||||
UnsafeBytes struct = new UnsafeBytes();
|
||||
|
||||
byte[] val = input();
|
||||
struct.setBytes(val);
|
||||
|
||||
val[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{2, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// buffer doens't copy
|
||||
public void testUnsafeBufferFor(){
|
||||
UnsafeBytes struct = new UnsafeBytes(ByteBuffer.wrap(input()));
|
||||
|
||||
ByteBuffer val = struct.bufferForBytes();
|
||||
val.array()[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{2, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// verify that the default generator does not change behavior
|
||||
//
|
||||
|
||||
public void testSafeConstructor() {
|
||||
|
||||
byte[] input = input();
|
||||
SafeBytes struct = new SafeBytes(ByteBuffer.wrap(input));
|
||||
|
||||
input[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{1, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public void testSafeSetter() {
|
||||
|
||||
byte[] input = input();
|
||||
SafeBytes struct = new SafeBytes(ByteBuffer.wrap(input));
|
||||
|
||||
input[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{1, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public void testSafeBufferFor(){
|
||||
SafeBytes struct = new SafeBytes(ByteBuffer.wrap(input()));
|
||||
|
||||
ByteBuffer val = struct.bufferForBytes();
|
||||
val.array()[0] = 2;
|
||||
|
||||
assertTrue(Arrays.equals(
|
||||
new byte[]{1, 1},
|
||||
struct.getBytes())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -18,24 +18,10 @@
|
|||
*/
|
||||
package org.apache.thrift.protocol;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.thrift.Fixtures;
|
||||
import org.apache.thrift.TBase;
|
||||
import org.apache.thrift.TDeserializer;
|
||||
import org.apache.thrift.TException;
|
||||
import org.apache.thrift.TSerializer;
|
||||
import org.apache.thrift.transport.TMemoryBuffer;
|
||||
|
||||
import thrift.test.CompactProtoTestStruct;
|
||||
import thrift.test.HolyMoley;
|
||||
import thrift.test.Nesting;
|
||||
import thrift.test.OneOfEach;
|
||||
import thrift.test.Srv;
|
||||
import thrift.test.GuessProtocolStruct;
|
||||
|
||||
public class TestTProtocolUtil extends TestCase {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class TestTSimpleJSONProtocol extends TestCase {
|
|||
struct.unsetDouble_byte_map();
|
||||
struct.unsetString_byte_map();
|
||||
struct.write(proto);
|
||||
assertEquals("{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.0},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]}}", bufToString());
|
||||
assertEquals("{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.1},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]}}", bufToString());
|
||||
}
|
||||
|
||||
public void testThrowsOnCollectionKeys() throws TException {
|
||||
|
|
|
@ -54,13 +54,13 @@ import thrift.test.Xtruct2;
|
|||
public abstract class ServerTestBase extends TestCase {
|
||||
|
||||
public static class TestHandler implements ThriftTest.Iface {
|
||||
|
||||
|
||||
public TestHandler() {}
|
||||
|
||||
|
||||
public void testVoid() {
|
||||
System.out.print("testVoid()\n");
|
||||
}
|
||||
|
||||
|
||||
public String testString(String thing) {
|
||||
System.out.print("testString(\"" + thing + "\")\n");
|
||||
return thing;
|
||||
|
@ -70,22 +70,22 @@ public abstract class ServerTestBase extends TestCase {
|
|||
System.out.print("testBool(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public byte testByte(byte thing) {
|
||||
System.out.print("testByte(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public int testI32(int thing) {
|
||||
System.out.print("testI32(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public long testI64(long thing) {
|
||||
System.out.print("testI64(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public double testDouble(double thing) {
|
||||
System.out.print("testDouble(" + thing + ")\n");
|
||||
return thing;
|
||||
|
@ -110,7 +110,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
thing.i64_thing + "})\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public Xtruct2 testNest(Xtruct2 nest) {
|
||||
Xtruct thing = nest.struct_thing;
|
||||
System.out.print("testNest({" +
|
||||
|
@ -122,7 +122,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
nest.i32_thing + "})\n");
|
||||
return nest;
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer,Integer> testMap(Map<Integer,Integer> thing) {
|
||||
System.out.print("testMap({");
|
||||
System.out.print(thing);
|
||||
|
@ -136,7 +136,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
System.out.print("})\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public Set<Integer> testSet(Set<Integer> thing) {
|
||||
System.out.print("testSet({");
|
||||
boolean first = true;
|
||||
|
@ -151,7 +151,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
System.out.print("})\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public List<Integer> testList(List<Integer> thing) {
|
||||
System.out.print("testList({");
|
||||
boolean first = true;
|
||||
|
@ -166,58 +166,58 @@ public abstract class ServerTestBase extends TestCase {
|
|||
System.out.print("})\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public Numberz testEnum(Numberz thing) {
|
||||
System.out.print("testEnum(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public long testTypedef(long thing) {
|
||||
System.out.print("testTypedef(" + thing + ")\n");
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer,Map<Integer,Integer>> testMapMap(int hello) {
|
||||
System.out.print("testMapMap(" + hello + ")\n");
|
||||
Map<Integer,Map<Integer,Integer>> mapmap =
|
||||
new HashMap<Integer,Map<Integer,Integer>>();
|
||||
|
||||
|
||||
HashMap<Integer,Integer> pos = new HashMap<Integer,Integer>();
|
||||
HashMap<Integer,Integer> neg = new HashMap<Integer,Integer>();
|
||||
for (int i = 1; i < 5; i++) {
|
||||
pos.put(i, i);
|
||||
neg.put(-i, -i);
|
||||
}
|
||||
|
||||
|
||||
mapmap.put(4, pos);
|
||||
mapmap.put(-4, neg);
|
||||
|
||||
|
||||
return mapmap;
|
||||
}
|
||||
|
||||
|
||||
public Map<Long, Map<Numberz,Insanity>> testInsanity(Insanity argument) {
|
||||
System.out.print("testInsanity()\n");
|
||||
|
||||
|
||||
HashMap<Numberz,Insanity> first_map = new HashMap<Numberz, Insanity>();
|
||||
HashMap<Numberz,Insanity> second_map = new HashMap<Numberz, Insanity>();;
|
||||
|
||||
|
||||
first_map.put(Numberz.TWO, argument);
|
||||
first_map.put(Numberz.THREE, argument);
|
||||
|
||||
|
||||
Insanity looney = new Insanity();
|
||||
second_map.put(Numberz.SIX, looney);
|
||||
|
||||
|
||||
Map<Long,Map<Numberz,Insanity>> insane =
|
||||
new HashMap<Long, Map<Numberz,Insanity>>();
|
||||
insane.put((long)1, first_map);
|
||||
insane.put((long)2, second_map);
|
||||
|
||||
|
||||
return insane;
|
||||
}
|
||||
|
||||
|
||||
public Xtruct testMulti(byte arg0, int arg1, long arg2, Map<Short,String> arg3, Numberz arg4, long arg5) {
|
||||
System.out.print("testMulti()\n");
|
||||
|
||||
|
||||
Xtruct hello = new Xtruct();;
|
||||
hello.string_thing = "Hello2";
|
||||
hello.byte_thing = arg0;
|
||||
|
@ -225,7 +225,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
hello.i64_thing = arg2;
|
||||
return hello;
|
||||
}
|
||||
|
||||
|
||||
public void testException(String arg) throws Xception, TException {
|
||||
System.out.print("testException("+arg+")\n");
|
||||
if ("Xception".equals(arg)) {
|
||||
|
@ -234,14 +234,15 @@ public abstract class ServerTestBase extends TestCase {
|
|||
x.message = arg;
|
||||
throw x;
|
||||
} else if ("TException".equals(arg)) {
|
||||
throw new TException(arg);
|
||||
// Unspecified exception should yield a TApplicationException on client side
|
||||
throw new RuntimeException(arg);
|
||||
} else {
|
||||
Xtruct result = new Xtruct();
|
||||
result.string_thing = arg;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public Xtruct testMultiException(String arg0, String arg1) throws Xception, Xception2 {
|
||||
System.out.print("testMultiException(" + arg0 + ", " + arg1 + ")\n");
|
||||
if (arg0.equals("Xception")) {
|
||||
|
@ -256,17 +257,17 @@ public abstract class ServerTestBase extends TestCase {
|
|||
x.struct_thing.string_thing = "This is an Xception2";
|
||||
throw x;
|
||||
}
|
||||
|
||||
|
||||
Xtruct result = new Xtruct();
|
||||
result.string_thing = arg1;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void testOneway(int sleepFor) {
|
||||
System.out.println("testOneway(" + Integer.toString(sleepFor) +
|
||||
") => sleeping...");
|
||||
try {
|
||||
Thread.sleep(sleepFor * 1000);
|
||||
Thread.sleep(sleepFor * SLEEP_DELAY);
|
||||
System.out.println("Done sleeping!");
|
||||
} catch (InterruptedException ie) {
|
||||
throw new RuntimeException(ie);
|
||||
|
@ -281,6 +282,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
public static final String HOST = "localhost";
|
||||
public static final int PORT = Integer.valueOf(
|
||||
System.getProperty("test.port", "9090"));
|
||||
protected static final int SLEEP_DELAY = 1000;
|
||||
protected static final int SOCKET_TIMEOUT = 1500;
|
||||
private static final Xtruct XSTRUCT = new Xtruct("Zero", (byte) 1, -3, -5);
|
||||
private static final Xtruct2 XSTRUCT2 = new Xtruct2((byte)1, XSTRUCT, 5);
|
||||
|
@ -333,7 +335,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
// todo: add assertions
|
||||
private void testInsanity(ThriftTest.Client testClient) throws TException {
|
||||
Insanity insane;
|
||||
|
||||
|
||||
insane = new Insanity();
|
||||
insane.userMap = new HashMap<Numberz, Long>();
|
||||
insane.userMap.put(Numberz.FIVE, (long)5000);
|
||||
|
@ -351,7 +353,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
for (long key : whoa.keySet()) {
|
||||
Map<Numberz,Insanity> val = whoa.get(key);
|
||||
System.out.print(key + " => {");
|
||||
|
||||
|
||||
for (Numberz k2 : val.keySet()) {
|
||||
Insanity v2 = val.get(k2);
|
||||
System.out.print(k2 + " => {");
|
||||
|
@ -363,7 +365,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
}
|
||||
}
|
||||
System.out.print("}, ");
|
||||
|
||||
|
||||
List<Xtruct> xtructs = v2.xtructs;
|
||||
System.out.print("{");
|
||||
if (xtructs != null) {
|
||||
|
@ -372,7 +374,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
}
|
||||
}
|
||||
System.out.print("}");
|
||||
|
||||
|
||||
System.out.print("}, ");
|
||||
}
|
||||
System.out.print("}, ");
|
||||
|
@ -387,7 +389,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
public void testIt() throws Exception {
|
||||
|
||||
for (TProtocolFactory protoFactory : getProtocols()) {
|
||||
TProcessor processor = useAsyncProcessor() ? new ThriftTest.AsyncProcessor(new AsyncTestHandler()) : new ThriftTest.Processor(new TestHandler());
|
||||
TProcessor processor = useAsyncProcessor() ? new ThriftTest.AsyncProcessor<AsyncTestHandler>(new AsyncTestHandler()) : new ThriftTest.Processor<TestHandler>(new TestHandler());
|
||||
|
||||
startServer(processor, protoFactory);
|
||||
|
||||
|
@ -420,6 +422,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
testOneway(testClient);
|
||||
testI32(testClient);
|
||||
transport.close();
|
||||
socket.close();
|
||||
|
||||
stopServer();
|
||||
}
|
||||
|
@ -430,7 +433,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
}
|
||||
|
||||
public List<TProtocolFactory> getProtocols() {
|
||||
return PROTOCOLS;
|
||||
return PROTOCOLS;
|
||||
}
|
||||
|
||||
private void testList(ThriftTest.Client testClient) throws TException {
|
||||
|
@ -466,14 +469,14 @@ public abstract class ServerTestBase extends TestCase {
|
|||
testClient.testMapMap(1);
|
||||
Map<Integer,Map<Integer,Integer>> mapmap =
|
||||
new HashMap<Integer,Map<Integer,Integer>>();
|
||||
|
||||
|
||||
HashMap<Integer,Integer> pos = new HashMap<Integer,Integer>();
|
||||
HashMap<Integer,Integer> neg = new HashMap<Integer,Integer>();
|
||||
for (int i = 1; i < 5; i++) {
|
||||
pos.put(i, i);
|
||||
neg.put(-i, -i);
|
||||
}
|
||||
|
||||
|
||||
mapmap.put(4, pos);
|
||||
mapmap.put(-4, neg);
|
||||
assertEquals(mapmap, mm);
|
||||
|
@ -535,7 +538,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
public void testTransportFactory() throws Exception {
|
||||
for (TProtocolFactory protoFactory : getProtocols()) {
|
||||
TestHandler handler = new TestHandler();
|
||||
ThriftTest.Processor processor = new ThriftTest.Processor(handler);
|
||||
ThriftTest.Processor<TestHandler> processor = new ThriftTest.Processor<TestHandler>(handler);
|
||||
|
||||
final CallCountingTransportFactory factory = new CallCountingTransportFactory(new TFramedTransport.Factory());
|
||||
|
||||
|
@ -551,6 +554,7 @@ public abstract class ServerTestBase extends TestCase {
|
|||
ThriftTest.Client testClient = new ThriftTest.Client(protocol);
|
||||
assertEquals(0, testClient.testByte((byte) 0));
|
||||
assertEquals(2, factory.count);
|
||||
socket.close();
|
||||
stopServer();
|
||||
}
|
||||
}
|
||||
|
@ -679,13 +683,15 @@ public abstract class ServerTestBase extends TestCase {
|
|||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
// throw and onError yield the same result.
|
||||
// resultHandler.onError(x);
|
||||
// return;
|
||||
throw x;
|
||||
} else if ("TException".equals(arg)) {
|
||||
// throw new TException(arg);
|
||||
resultHandler.onError(new TException(arg));
|
||||
// throw x;
|
||||
resultHandler.onError(x);
|
||||
return;
|
||||
} else if ("TException".equals(arg)) {
|
||||
// throw and onError yield the same result.
|
||||
// resultHandler.onError(new TException(arg));
|
||||
// return;
|
||||
// Unspecified exception should yield a TApplicationException on client side
|
||||
throw new RuntimeException(arg);
|
||||
}
|
||||
resultHandler.onComplete(null);
|
||||
}
|
||||
|
|
34
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/test/TestClient.java
generated
vendored
34
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/test/TestClient.java
generated
vendored
|
@ -33,6 +33,7 @@ import org.apache.thrift.TSerializer;
|
|||
import org.apache.thrift.protocol.TBinaryProtocol;
|
||||
import org.apache.thrift.protocol.TCompactProtocol;
|
||||
import org.apache.thrift.protocol.TJSONProtocol;
|
||||
import org.apache.thrift.protocol.TMultiplexedProtocol;
|
||||
import org.apache.thrift.protocol.TProtocol;
|
||||
import org.apache.thrift.protocol.TSimpleJSONProtocol;
|
||||
import org.apache.thrift.transport.TFastFramedTransport;
|
||||
|
@ -46,6 +47,7 @@ import org.apache.thrift.transport.TTransportException;
|
|||
// Generated code
|
||||
import thrift.test.Insanity;
|
||||
import thrift.test.Numberz;
|
||||
import thrift.test.SecondService;
|
||||
import thrift.test.ThriftTest;
|
||||
import thrift.test.Xception;
|
||||
import thrift.test.Xception2;
|
||||
|
@ -64,6 +66,7 @@ public class TestClient {
|
|||
private static int ERR_STRUCTS = 2;
|
||||
private static int ERR_CONTAINERS = 4;
|
||||
private static int ERR_EXCEPTIONS = 8;
|
||||
private static int ERR_PROTOCOLS = 16;
|
||||
private static int ERR_UNKNOWN = 64;
|
||||
|
||||
public static void main(String [] args) {
|
||||
|
@ -102,7 +105,7 @@ public class TestClient {
|
|||
System.out.println(" --host=arg (=" + host + ")\tHost to connect");
|
||||
System.out.println(" --port=arg (=" + port + ")\tPort number to connect");
|
||||
System.out.println(" --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed, http");
|
||||
System.out.println(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, json, compact");
|
||||
System.out.println(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
|
||||
System.out.println(" --ssl\t\t\tEncrypted Transport using SSL");
|
||||
System.out.println(" --testloops[--n]=arg (=" + numTests + ")\tNumber of Tests");
|
||||
System.exit(0);
|
||||
|
@ -117,6 +120,9 @@ public class TestClient {
|
|||
if (protocol_type.equals("binary")) {
|
||||
} else if (protocol_type.equals("compact")) {
|
||||
} else if (protocol_type.equals("json")) {
|
||||
} else if (protocol_type.equals("multi")) {
|
||||
} else if (protocol_type.equals("multic")) {
|
||||
} else if (protocol_type.equals("multij")) {
|
||||
} else {
|
||||
throw new Exception("Unknown protocol type! " + protocol_type);
|
||||
}
|
||||
|
@ -163,16 +169,21 @@ public class TestClient {
|
|||
}
|
||||
|
||||
TProtocol tProtocol = null;
|
||||
if (protocol_type.equals("json")) {
|
||||
TProtocol tProtocol2 = null;
|
||||
if (protocol_type.equals("json") || protocol_type.equals("multij")) {
|
||||
tProtocol = new TJSONProtocol(transport);
|
||||
} else if (protocol_type.equals("compact")) {
|
||||
} else if (protocol_type.equals("compact") || protocol_type.equals("multic")) {
|
||||
tProtocol = new TCompactProtocol(transport);
|
||||
} else {
|
||||
tProtocol = new TBinaryProtocol(transport);
|
||||
}
|
||||
|
||||
ThriftTest.Client testClient =
|
||||
new ThriftTest.Client(tProtocol);
|
||||
if (protocol_type.startsWith("multi")) {
|
||||
tProtocol2 = new TMultiplexedProtocol(tProtocol, "SecondService");
|
||||
tProtocol = new TMultiplexedProtocol(tProtocol, "ThriftTest");
|
||||
}
|
||||
|
||||
ThriftTest.Client testClient = new ThriftTest.Client(tProtocol);
|
||||
Insanity insane = new Insanity();
|
||||
|
||||
long timeMin = 0;
|
||||
|
@ -222,6 +233,19 @@ public class TestClient {
|
|||
System.out.println("*** FAILURE ***\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplexed test
|
||||
*/
|
||||
if (protocol_type.startsWith("multi")) {
|
||||
SecondService.Client secondClient = new SecondService.Client(tProtocol2);
|
||||
System.out.print("secondtestString(\"Test2\")");
|
||||
s = secondClient.secondtestString("Test2");
|
||||
System.out.print(" = \"" + s + "\"\n");
|
||||
if (!s.equals("testString(\"Test2\")")) {
|
||||
returnCode |= ERR_PROTOCOLS;
|
||||
System.out.println("*** FAILURE ***\n");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* BYTE TEST
|
||||
*/
|
||||
|
|
72
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/test/TestServer.java
generated
vendored
72
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/test/TestServer.java
generated
vendored
|
@ -30,6 +30,7 @@ import org.apache.thrift.protocol.TCompactProtocol;
|
|||
import org.apache.thrift.protocol.TJSONProtocol;
|
||||
import org.apache.thrift.protocol.TProtocol;
|
||||
import org.apache.thrift.protocol.TProtocolFactory;
|
||||
import org.apache.thrift.protocol.TMultiplexedProtocol;
|
||||
import org.apache.thrift.server.ServerContext;
|
||||
import org.apache.thrift.server.TServer;
|
||||
import org.apache.thrift.server.TServer.Args;
|
||||
|
@ -46,10 +47,11 @@ import org.apache.thrift.transport.TSSLTransportFactory;
|
|||
import org.apache.thrift.transport.TTransport;
|
||||
import org.apache.thrift.transport.TTransportFactory;
|
||||
import org.apache.thrift.transport.TNonblockingServerSocket;
|
||||
|
||||
import org.apache.thrift.TMultiplexedProcessor;
|
||||
|
||||
import thrift.test.Insanity;
|
||||
import thrift.test.Numberz;
|
||||
import thrift.test.SecondService;
|
||||
import thrift.test.ThriftTest;
|
||||
import thrift.test.Xception;
|
||||
import thrift.test.Xception2;
|
||||
|
@ -58,6 +60,24 @@ import thrift.test.Xtruct2;
|
|||
|
||||
public class TestServer {
|
||||
|
||||
// Multiplexed Protocol Support Details:
|
||||
//
|
||||
// For multiplexed testing we always use binary protocol underneath.
|
||||
//
|
||||
// "ThriftTest" named service implements "ThriftTest" from ThriftTest.thrift
|
||||
// "SecondService" named service implements "SecondService" from ThriftTest.thrift
|
||||
// In addition, to support older non-multiplexed clients using the same concrete protocol
|
||||
// the multiplexed processor is taught to use "ThriftTest" if the incoming request has no
|
||||
// multiplexed call name decoration.
|
||||
|
||||
static class SecondHandler implements thrift.test.SecondService.Iface {
|
||||
|
||||
@Override
|
||||
public java.lang.String secondtestString(java.lang.String thing) throws org.apache.thrift.TException
|
||||
{ return "testString(\"" + thing + "\")"; }
|
||||
|
||||
}
|
||||
|
||||
static class TestServerContext implements ServerContext {
|
||||
|
||||
int connectionId;
|
||||
|
@ -139,7 +159,7 @@ public class TestServer {
|
|||
System.out.println(" --help\t\t\tProduce help message");
|
||||
System.out.println(" --port=arg (=" + port + ")\tPort number to connect");
|
||||
System.out.println(" --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed");
|
||||
System.out.println(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, json, compact");
|
||||
System.out.println(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
|
||||
System.out.println(" --ssl\t\t\tEncrypted Transport using SSL");
|
||||
System.out.println(" --server-type=arg (=" + server_type +")\n\t\t\t\tType of server: simple, thread-pool, nonblocking, threaded-selector");
|
||||
System.out.println(" --string-limit=arg (=" + string_limit + ")\tString read length limit");
|
||||
|
@ -167,8 +187,11 @@ public class TestServer {
|
|||
throw new Exception("Unknown server type! " + server_type);
|
||||
}
|
||||
if (protocol_type.equals("binary")) {
|
||||
} else if (protocol_type.equals("json")) {
|
||||
} else if (protocol_type.equals("compact")) {
|
||||
} else if (protocol_type.equals("json")) {
|
||||
} else if (protocol_type.equals("multi")) {
|
||||
} else if (protocol_type.equals("multic")) {
|
||||
} else if (protocol_type.equals("multij")) {
|
||||
} else {
|
||||
throw new Exception("Unknown protocol type! " + protocol_type);
|
||||
}
|
||||
|
@ -183,19 +206,20 @@ public class TestServer {
|
|||
System.exit(1);
|
||||
}
|
||||
|
||||
// Processor
|
||||
TestHandler testHandler =
|
||||
new TestHandler();
|
||||
ThriftTest.Processor testProcessor =
|
||||
new ThriftTest.Processor(testHandler);
|
||||
// Processors
|
||||
TestHandler testHandler = new TestHandler();
|
||||
ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
|
||||
|
||||
SecondHandler secondHandler = new SecondHandler();
|
||||
SecondService.Processor secondProcessor = new SecondService.Processor(secondHandler);
|
||||
|
||||
// Protocol factory
|
||||
TProtocolFactory tProtocolFactory = null;
|
||||
if (protocol_type.equals("json")) {
|
||||
if (protocol_type.equals("json") || protocol_type.equals("multij")) {
|
||||
tProtocolFactory = new TJSONProtocol.Factory();
|
||||
} else if (protocol_type.equals("compact")) {
|
||||
} else if (protocol_type.equals("compact") || protocol_type.equals("multic")) {
|
||||
tProtocolFactory = new TCompactProtocol.Factory(string_limit, container_limit);
|
||||
} else {
|
||||
} else { // also covers multi
|
||||
tProtocolFactory = new TBinaryProtocol.Factory(string_limit, container_limit);
|
||||
}
|
||||
|
||||
|
@ -211,6 +235,11 @@ public class TestServer {
|
|||
|
||||
TServer serverEngine = null;
|
||||
|
||||
// If we are multiplexing services in one server...
|
||||
TMultiplexedProcessor multiplexedProcessor = new TMultiplexedProcessor();
|
||||
multiplexedProcessor.registerDefault (testProcessor);
|
||||
multiplexedProcessor.registerProcessor("ThriftTest", testProcessor);
|
||||
multiplexedProcessor.registerProcessor("SecondService", secondProcessor);
|
||||
|
||||
if (server_type.equals("nonblocking") ||
|
||||
server_type.equals("threaded-selector")) {
|
||||
|
@ -218,23 +247,21 @@ public class TestServer {
|
|||
TNonblockingServerSocket tNonblockingServerSocket =
|
||||
new TNonblockingServerSocket(new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(port));
|
||||
|
||||
if (server_type.equals("nonblocking")) {
|
||||
if (server_type.contains("nonblocking")) {
|
||||
// Nonblocking Server
|
||||
TNonblockingServer.Args tNonblockingServerArgs
|
||||
= new TNonblockingServer.Args(tNonblockingServerSocket);
|
||||
tNonblockingServerArgs.processor(testProcessor);
|
||||
tNonblockingServerArgs.processor(protocol_type.startsWith("multi") ? multiplexedProcessor : testProcessor);
|
||||
tNonblockingServerArgs.protocolFactory(tProtocolFactory);
|
||||
tNonblockingServerArgs.transportFactory(tTransportFactory);
|
||||
|
||||
serverEngine = new TNonblockingServer(tNonblockingServerArgs);
|
||||
} else { // server_type.equals("threaded-selector")
|
||||
// ThreadedSelector Server
|
||||
TThreadedSelectorServer.Args tThreadedSelectorServerArgs
|
||||
= new TThreadedSelectorServer.Args(tNonblockingServerSocket);
|
||||
tThreadedSelectorServerArgs.processor(testProcessor);
|
||||
tThreadedSelectorServerArgs.processor(protocol_type.startsWith("multi") ? multiplexedProcessor : testProcessor);
|
||||
tThreadedSelectorServerArgs.protocolFactory(tProtocolFactory);
|
||||
tThreadedSelectorServerArgs.transportFactory(tTransportFactory);
|
||||
|
||||
serverEngine = new TThreadedSelectorServer(tThreadedSelectorServerArgs);
|
||||
}
|
||||
} else {
|
||||
|
@ -251,29 +278,28 @@ public class TestServer {
|
|||
if (server_type.equals("simple")) {
|
||||
// Simple Server
|
||||
TServer.Args tServerArgs = new TServer.Args(tServerSocket);
|
||||
tServerArgs.processor(testProcessor);
|
||||
tServerArgs.processor(protocol_type.startsWith("multi") ? multiplexedProcessor : testProcessor);
|
||||
tServerArgs.protocolFactory(tProtocolFactory);
|
||||
tServerArgs.transportFactory(tTransportFactory);
|
||||
|
||||
serverEngine = new TSimpleServer(tServerArgs);
|
||||
} else { // server_type.equals("threadpool")
|
||||
// ThreadPool Server
|
||||
TThreadPoolServer.Args tThreadPoolServerArgs
|
||||
= new TThreadPoolServer.Args(tServerSocket);
|
||||
tThreadPoolServerArgs.processor(testProcessor);
|
||||
tThreadPoolServerArgs.processor(protocol_type.startsWith("multi") ? multiplexedProcessor : testProcessor);
|
||||
tThreadPoolServerArgs.protocolFactory(tProtocolFactory);
|
||||
tThreadPoolServerArgs.transportFactory(tTransportFactory);
|
||||
|
||||
serverEngine = new TThreadPoolServer(tThreadPoolServerArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Set server event handler
|
||||
// Set server event handler
|
||||
serverEngine.setServerEventHandler(new TestServerEventHandler());
|
||||
|
||||
// Run it
|
||||
System.out.println("Starting the server on port " + port + "...");
|
||||
System.out.println("Starting the " + (ssl ? "ssl server" : "server") +
|
||||
" [" + protocol_type + "/" + transport_type + "/" + server_type + "] on " +
|
||||
((domain_socket == "") ? ("port " + port) : ("unix socket " + domain_socket)));
|
||||
serverEngine.serve();
|
||||
|
||||
} catch (Exception x) {
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
package org.apache.thrift.transport;
|
||||
|
||||
public class TestTFastFramedTransport extends TestTFramedTransport {
|
||||
protected final static int INITIAL_CAPACITY = 50;
|
||||
|
||||
@Override
|
||||
protected TTransport getTransport(TTransport underlying) {
|
||||
return new TFastFramedTransport(underlying, 50, 10 * 1024 * 1024);
|
||||
return new TFastFramedTransport(underlying, INITIAL_CAPACITY, 10 * 1024 * 1024);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TTransport getTransport(TTransport underlying, int maxLength) {
|
||||
return new TFastFramedTransport(underlying, 50, maxLength);
|
||||
return new TFastFramedTransport(underlying, INITIAL_CAPACITY, maxLength);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,4 +183,32 @@ public class TestTFramedTransport extends TestCase {
|
|||
assertEquals(65, trans.getBytesRemainingInBuffer());
|
||||
assertEquals(10, trans.getBufferPosition());
|
||||
}
|
||||
|
||||
public void testClear() throws IOException, TTransportException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(baos);
|
||||
dos.writeInt(220);
|
||||
dos.write(byteSequence(0, 219));
|
||||
|
||||
TMemoryBuffer membuf = new TMemoryBuffer(0);
|
||||
membuf.write(baos.toByteArray());
|
||||
|
||||
ReadCountingTransport countTrans = new ReadCountingTransport(membuf);
|
||||
TTransport trans = getTransport(countTrans);
|
||||
|
||||
byte[] readBuf = new byte[220];
|
||||
trans.read(readBuf, 0, 220);
|
||||
assertTrue(Arrays.equals(readBuf, byteSequence(0,219)));
|
||||
|
||||
assertTrue(trans instanceof TFramedTransport || trans instanceof TFastFramedTransport);
|
||||
if (trans instanceof TFramedTransport) {
|
||||
assertTrue(trans.getBuffer() != null && trans.getBuffer().length > 0);
|
||||
((TFramedTransport) trans).clear();
|
||||
assertTrue(trans.getBuffer() == null);
|
||||
} else if (trans instanceof TFastFramedTransport) {
|
||||
assertTrue(trans.getBuffer().length > TestTFastFramedTransport.INITIAL_CAPACITY);
|
||||
((TFastFramedTransport) trans).clear();
|
||||
assertTrue(trans.getBuffer().length == TestTFastFramedTransport.INITIAL_CAPACITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ public class TestTSSLTransportFactory extends ServerTestBase {
|
|||
throws Exception {
|
||||
return TSSLTransportFactory.getClientSocket(HOST, PORT);
|
||||
}
|
||||
|
||||
protected TServerSocket getServerTransport() throws Exception {
|
||||
return TSSLTransportFactory.getServerSocket(PORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startServer(final TProcessor processor, final TProtocolFactory protoFactory, final TTransportFactory factory)
|
||||
|
@ -52,11 +56,11 @@ public class TestTSSLTransportFactory extends ServerTestBase {
|
|||
serverThread = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(PORT);
|
||||
TServerTransport serverTransport = getServerTransport();
|
||||
final Args args = new Args(serverTransport).processor(processor);
|
||||
server = new TSimpleServer(args);
|
||||
server.serve();
|
||||
} catch (TTransportException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
assert false;
|
||||
}
|
||||
|
@ -64,7 +68,7 @@ public class TestTSSLTransportFactory extends ServerTestBase {
|
|||
};
|
||||
|
||||
serverThread.start();
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(SLEEP_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
62
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java
generated
vendored
Normal file
62
vendor/git.apache.org/thrift.git/lib/java/test/org/apache/thrift/transport/TestTSSLTransportFactoryStreamedStore.java
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.thrift.transport;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.net.InetAddress;
|
||||
|
||||
public class TestTSSLTransportFactoryStreamedStore extends TestTSSLTransportFactory {
|
||||
private static String keyStoreLocation = System.getProperty("javax.net.ssl.keyStore");
|
||||
private static String trustStoreLocation = System.getProperty("javax.net.ssl.trustStore");
|
||||
|
||||
public TestTSSLTransportFactoryStreamedStore() {
|
||||
super();
|
||||
|
||||
/**
|
||||
* Override system properties to be able to test passing
|
||||
* the trustStore and keyStore as input stream
|
||||
*/
|
||||
System.setProperty("javax.net.ssl.trustStore", "");
|
||||
System.setProperty("javax.net.ssl.keyStore", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TTransport getClientTransport(TTransport underlyingTransport)
|
||||
throws Exception {
|
||||
TSSLTransportFactory.TSSLTransportParameters params = new
|
||||
TSSLTransportFactory.TSSLTransportParameters();
|
||||
|
||||
params.setTrustStore(new FileInputStream(trustStoreLocation),
|
||||
System.getProperty("javax.net.ssl.trustStorePassword"));
|
||||
|
||||
return TSSLTransportFactory.getClientSocket(HOST, PORT, 0/*timeout*/, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TServerSocket getServerTransport() throws Exception {
|
||||
TSSLTransportFactory.TSSLTransportParameters params = new
|
||||
TSSLTransportFactory.TSSLTransportParameters();
|
||||
|
||||
params.setKeyStore(new FileInputStream(keyStoreLocation),
|
||||
System.getProperty("javax.net.ssl.keyStorePassword"));
|
||||
|
||||
return TSSLTransportFactory.getServerSocket(PORT, 0/*timeout*/, InetAddress.getByName(HOST), params);
|
||||
}
|
||||
}
|
|
@ -27,21 +27,21 @@ public class TestTSimpleFileTransport extends TestCase {
|
|||
public void testFresh() throws Exception {
|
||||
//Test write side
|
||||
Path tempFilePathName = Files.createTempFile("TSimpleFileTransportTest", null);
|
||||
Files.delete(tempFilePathName);
|
||||
Files.delete(tempFilePathName);
|
||||
byte[] input_buf = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
TSimpleFileTransport trans_write = new TSimpleFileTransport(tempFilePathName.toString(),false, true, false);
|
||||
assert (!trans_write.isOpen());
|
||||
trans_write.open();
|
||||
assert(trans_write.isOpen());
|
||||
trans_write.write(input_buf);
|
||||
trans_write.write(input_buf,2,2);
|
||||
trans_write.write(input_buf,2,2);
|
||||
trans_write.flush();
|
||||
trans_write.close();
|
||||
|
||||
|
||||
//Test read side
|
||||
TSimpleFileTransport trans = new TSimpleFileTransport(tempFilePathName.toString(),true, false);
|
||||
assert(trans_write.isOpen());
|
||||
|
||||
assert(trans.isOpen());
|
||||
|
||||
//Simple file trans provides no buffer access
|
||||
assert(0 == trans.getBufferPosition());
|
||||
assert(null == trans.getBuffer());
|
||||
|
@ -56,19 +56,19 @@ public class TestTSimpleFileTransport extends TestCase {
|
|||
trans.readAll(buf1, 0, BUFSIZ);
|
||||
assert(BUFSIZ == trans.getFilePointer());
|
||||
assert(Arrays.equals(new byte[]{1, 2, 3, 4}, buf1));
|
||||
|
||||
|
||||
int bytesRead = trans.read(buf1, 0, BUFSIZ);
|
||||
assert(bytesRead > 0);
|
||||
for (int i = 0; i < bytesRead; ++i) {
|
||||
assert(buf1[i] == i+5);
|
||||
assert(buf1[i] == i+5);
|
||||
}
|
||||
|
||||
|
||||
trans.seek(0);
|
||||
assert(0 == trans.getFilePointer());
|
||||
trans.readAll(buf1, 0, BUFSIZ);
|
||||
assert(Arrays.equals(new byte[]{1, 2, 3, 4}, buf1));
|
||||
assert(BUFSIZ == trans.getFilePointer());
|
||||
trans.close();
|
||||
Files.delete(tempFilePathName);
|
||||
Files.delete(tempFilePathName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue