Merge pull request #25520 from dotnet-maestro-bot/merge/release/5.0-to-release/5.0-rc2
[automated] Merge branch 'release/5.0' => 'release/5.0-rc2'
This commit is contained in:
commit
fe1a881b0e
|
|
@ -2,7 +2,7 @@
|
|||
.gradletasknamecache
|
||||
.gradle/
|
||||
build/
|
||||
/test-results
|
||||
test/test-results
|
||||
.settings/
|
||||
out/
|
||||
*.class
|
||||
|
|
|
|||
|
|
@ -15,32 +15,18 @@ plugins {
|
|||
id 'maven'
|
||||
}
|
||||
|
||||
apply plugin: "java-library"
|
||||
apply plugin: "com.diffplug.gradle.spotless"
|
||||
apply plugin: 'org.junit.platform.gradle.plugin'
|
||||
allprojects {
|
||||
apply plugin: "java-library"
|
||||
apply plugin: "com.diffplug.gradle.spotless"
|
||||
|
||||
group 'com.microsoft.signalr'
|
||||
// If we're run from outside MSBuild, just assign a bogus dev version.
|
||||
version project.findProperty('packageVersion') ?: "99.99.99-dev"
|
||||
|
||||
// If we're run from outside MSBuild, just assign a bogus dev version.
|
||||
version project.findProperty('packageVersion') ?: "99.99.99-dev"
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
|
||||
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1'
|
||||
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
|
||||
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
api 'io.reactivex.rxjava2:rxjava:2.2.3'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.25'
|
||||
compile 'org.msgpack:msgpack-core:0.8.20'
|
||||
compile 'org.msgpack:jackson-dataformat-msgpack:0.8.20'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
spotless {
|
||||
|
|
@ -48,7 +34,7 @@ spotless {
|
|||
licenseHeader '// Copyright (c) .NET Foundation. All rights reserved.\n' +
|
||||
'// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n\n' // License header
|
||||
|
||||
importOrder 'java', 'javax', 'org', 'com', 'com.diffplug', '' // A sequence of package names
|
||||
importOrder 'java', 'javax', 'org', 'com', 'com.diffplug', '' // A sequence of package names
|
||||
|
||||
replace 'Not enough space after if', 'if(', 'if ('
|
||||
replace 'Not enough space after else', 'else{', 'else {'
|
||||
|
|
@ -66,73 +52,4 @@ spotless {
|
|||
indentWithSpaces(4)
|
||||
removeUnusedImports() // removes any unused imports
|
||||
}
|
||||
}
|
||||
|
||||
junitPlatform {
|
||||
reportsDir file('test-results')
|
||||
}
|
||||
|
||||
task sourceJar(type: Jar) {
|
||||
classifier "sources"
|
||||
from sourceSets.main.allJava
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier "javadoc"
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task generatePOM {
|
||||
pom {
|
||||
project {
|
||||
inceptionYear '2018'
|
||||
description 'ASP.NET Core SignalR Client for Java applications'
|
||||
url 'https://github.com/dotnet/aspnetcore'
|
||||
name groupId + ':' + artifactId
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
developerConnection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
url 'http://github.com/dotnet/aspnetcore/tree/master'
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'microsoft'
|
||||
name 'Microsoft'
|
||||
}
|
||||
}
|
||||
}
|
||||
}.writeTo("${buildDir}/libs/signalr-${project.version}.pom")
|
||||
}
|
||||
|
||||
task createPackage(dependsOn: [jar,sourceJar,javadocJar,generatePOM])
|
||||
|
||||
task generateVersionClass {
|
||||
inputs.property "version", project.version
|
||||
outputs.dir "$buildDir/generated"
|
||||
doFirst {
|
||||
def versionFile = file("$buildDir/../src/main/java/com/microsoft/signalr/Version.java")
|
||||
versionFile.parentFile.mkdirs()
|
||||
versionFile.text =
|
||||
"""
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class Version {
|
||||
public static String getDetailedVersion() {
|
||||
return "$project.version";
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.dependsOn generateVersionClass
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
group 'com.microsoft.signalr'
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
api 'io.reactivex.rxjava2:rxjava:2.2.3'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.25'
|
||||
}
|
||||
|
||||
archivesBaseName = 'signalr'
|
||||
|
||||
task sourceJar(type: Jar) {
|
||||
classifier "sources"
|
||||
from sourceSets.main.allJava
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier "javadoc"
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task generatePOM {
|
||||
pom {
|
||||
project {
|
||||
inceptionYear '2018'
|
||||
description 'ASP.NET Core SignalR Client for Java applications'
|
||||
url 'https://github.com/dotnet/aspnetcore'
|
||||
name groupId + ':' + artifactId
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
developerConnection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
url 'http://github.com/dotnet/aspnetcore/tree/master'
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'microsoft'
|
||||
name 'Microsoft'
|
||||
}
|
||||
}
|
||||
}
|
||||
}.writeTo("${buildDir}/libs/signalr-${project.version}.pom")
|
||||
}
|
||||
|
||||
task createPackage(dependsOn: [jar,sourceJar,javadocJar,generatePOM])
|
||||
|
||||
task generateVersionClass {
|
||||
inputs.property "version", project.version
|
||||
outputs.dir "$buildDir/generated"
|
||||
doFirst {
|
||||
def versionFile = file("$buildDir/../src/main/java/com/microsoft/signalr/Version.java")
|
||||
versionFile.parentFile.mkdirs()
|
||||
versionFile.text =
|
||||
"""
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class Version {
|
||||
public static String getDetailedVersion() {
|
||||
return "$project.version";
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.dependsOn generateVersionClass
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<Project>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- This package ID is only ever used along with eng/PatchConfig.props to determine when to patch the Java client. -->
|
||||
<PackageId>java:signalr</PackageId>
|
||||
<!-- In servicing builds, this will be set to value if the Java client is not configured to be released in the currently building patch. -->
|
||||
<IsPackable>true</IsPackable>
|
||||
<IsTestProject>false</IsTestProject>
|
||||
<!-- Disable gradle daemon on CI since the CI seems to try to wait for the daemon to shut down, which it doesn't do :) -->
|
||||
<GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -Dorg.gradle.daemon=false</GradleOptions>
|
||||
<PublishDir>$(OutputPath)</PublishDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Jars Include="
|
||||
signalr-$(PackageVersion).jar;
|
||||
signalr-$(PackageVersion)-javadoc.jar;
|
||||
signalr-$(PackageVersion)-sources.jar;" />
|
||||
<PomFile Include="signalr-$(PackageVersion).pom" />
|
||||
<JavaBuildFiles Include="@(Jars);@(PomFile)"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Restore" />
|
||||
|
||||
<PropertyGroup>
|
||||
<PackDependsOn Condition=" '$(NoBuild)' != 'true' ">
|
||||
$(PackDependsOn);
|
||||
Build
|
||||
</PackDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GradleOptions>$(GradleOptions) -PpackageVersion="$(PackageVersion)"</GradleOptions>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Define Target overrides after importing Directory.Build.targets so these don't get overridden -->
|
||||
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true'">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Pack" />
|
||||
<Message Text="> gradlew $(GradleOptions) createPackage" Importance="high" />
|
||||
<Exec Command="../gradlew $(GradleOptions) createPackage" />
|
||||
<Message Importance="high" Text="java:signalr -> $(PackageOutputPath)%(JavaBuildFiles.Identity)" />
|
||||
<Copy SourceFiles="$(MSBuildThisFileDirectory)build\libs\%(JavaBuildFiles.Identity)" DestinationFolder="$(PackageOutputPath)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Build">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
|
||||
<Exec Command="../gradlew $(GradleOptions) compileJava" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Test" />
|
||||
|
||||
<Target Name="Publish" />
|
||||
|
||||
</Project>
|
||||
1
src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/.gitignore
vendored
Normal file
1
src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
Version.java
|
||||
|
|
@ -5,7 +5,7 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
final class CancelInvocationMessage extends HubMessage {
|
||||
public final class CancelInvocationMessage extends HubMessage {
|
||||
private final int type = HubMessageType.CANCEL_INVOCATION.value;
|
||||
private Map<String, String> headers;
|
||||
private final String invocationId;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
final class CloseMessage extends HubMessage {
|
||||
public final class CloseMessage extends HubMessage {
|
||||
private final String error;
|
||||
private final boolean allowReconnect;
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
final class CompletionMessage extends HubMessage {
|
||||
public final class CompletionMessage extends HubMessage {
|
||||
private final int type = HubMessageType.COMPLETION.value;
|
||||
private Map<String, String> headers;
|
||||
private final String invocationId;
|
||||
|
|
@ -57,12 +57,13 @@ public class HttpHubConnectionBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets MessagePack as the {@link HubProtocol} to be used by the {@link HubConnection}.
|
||||
* Sets the {@link HubProtocol} to be used by the {@link HubConnection}.
|
||||
*
|
||||
* @param protocol The {@link HubProtocol} to be used by the {@link HubConnection}.
|
||||
* @return This instance of the HttpHubConnectionBuilder.
|
||||
*/
|
||||
public HttpHubConnectionBuilder withMessagePackHubProtocol() {
|
||||
this.protocol = new MessagePackHubProtocol();
|
||||
public HttpHubConnectionBuilder withHubProtocol(HubProtocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -6,6 +6,6 @@ package com.microsoft.signalr;
|
|||
/**
|
||||
* A base class for hub messages.
|
||||
*/
|
||||
abstract class HubMessage {
|
||||
public abstract class HubMessage {
|
||||
public abstract HubMessageType getMessageType();
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
enum HubMessageType {
|
||||
public enum HubMessageType {
|
||||
INVOCATION(1),
|
||||
STREAM_ITEM(2),
|
||||
COMPLETION(3),
|
||||
|
|
@ -9,14 +9,14 @@ import java.util.List;
|
|||
/**
|
||||
* A protocol abstraction for communicating with SignalR hubs.
|
||||
*/
|
||||
interface HubProtocol {
|
||||
public interface HubProtocol {
|
||||
String getName();
|
||||
int getVersion();
|
||||
TransferFormat getTransferFormat();
|
||||
|
||||
/**
|
||||
* Creates a new list of {@link HubMessage}s.
|
||||
* @param message A ByteBuffer representation of one or more {@link HubMessage}s.
|
||||
* @param binder The {@link InvocationBinder} to use for this Protocol instance.
|
||||
* @return A list of {@link HubMessage}s.
|
||||
*/
|
||||
List<HubMessage> parseMessages(ByteBuffer message, InvocationBinder binder);
|
||||
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* An abstraction for passing around information about method signatures.
|
||||
*/
|
||||
interface InvocationBinder {
|
||||
public interface InvocationBinder {
|
||||
Type getReturnType(String invocationId);
|
||||
List<Type> getParameterTypes(String methodName);
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class InvocationBindingFailureMessage extends HubMessage {
|
||||
public class InvocationBindingFailureMessage extends HubMessage {
|
||||
private final String invocationId;
|
||||
private final String target;
|
||||
private final Exception exception;
|
||||
|
|
@ -6,7 +6,7 @@ package com.microsoft.signalr;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
class InvocationMessage extends HubMessage {
|
||||
public class InvocationMessage extends HubMessage {
|
||||
int type = HubMessageType.INVOCATION.value;
|
||||
private Map<String, String> headers;
|
||||
private final String invocationId;
|
||||
|
|
@ -34,11 +34,6 @@ class JsonHubProtocol implements HubProtocol {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransferFormat getTransferFormat() {
|
||||
return TransferFormat.TEXT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) {
|
||||
String payloadStr;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class PingMessage extends HubMessage
|
||||
public class PingMessage extends HubMessage
|
||||
{
|
||||
private final int type = HubMessageType.PING.value;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class StreamBindingFailureMessage extends HubMessage {
|
||||
public class StreamBindingFailureMessage extends HubMessage {
|
||||
private final String invocationId;
|
||||
private final Exception exception;
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ package com.microsoft.signalr;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
final class StreamInvocationMessage extends InvocationMessage {
|
||||
public final class StreamInvocationMessage extends InvocationMessage {
|
||||
|
||||
public StreamInvocationMessage(Map<String, String> headers, String invocationId, String target, Object[] args, Collection<String> streamIds) {
|
||||
super(headers, invocationId, target, args, streamIds);
|
||||
|
|
@ -5,7 +5,7 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
final class StreamItem extends HubMessage {
|
||||
public final class StreamItem extends HubMessage {
|
||||
private final int type = HubMessageType.STREAM_ITEM.value;
|
||||
private Map<String, String> headers;
|
||||
private final String invocationId;
|
||||
|
|
@ -31,6 +31,7 @@ public class TypeReference<T> {
|
|||
|
||||
/**
|
||||
* Gets the referenced type.
|
||||
* @return The Type encapsulated by this TypeReference
|
||||
*/
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class Utils {
|
||||
public static String appendQueryString(String original, String queryStringValue) {
|
||||
if (original.contains("?")) {
|
||||
return original + "&" + queryStringValue;
|
||||
} else {
|
||||
return original + "?" + queryStringValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> typeToClass(Type type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
if (type instanceof Class) {
|
||||
return (Class<?>) type;
|
||||
} else if (type instanceof GenericArrayType) {
|
||||
// Instantiate an array of the same type as this type, then return its class
|
||||
return Array.newInstance(typeToClass(((GenericArrayType)type).getGenericComponentType()), 0).getClass();
|
||||
} else if (type instanceof ParameterizedType) {
|
||||
return typeToClass(((ParameterizedType) type).getRawType());
|
||||
} else if (type instanceof TypeVariable) {
|
||||
Type[] bounds = ((TypeVariable<?>) type).getBounds();
|
||||
return bounds.length == 0 ? Object.class : typeToClass(bounds[0]);
|
||||
} else if (type instanceof WildcardType) {
|
||||
Type[] bounds = ((WildcardType) type).getUpperBounds();
|
||||
return bounds.length == 0 ? Object.class : typeToClass(bounds[0]);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Cannot handle type class: " + type.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
group 'com.microsoft.signalr.messagepack'
|
||||
|
||||
dependencies {
|
||||
implementation project(':core')
|
||||
compile 'org.msgpack:msgpack-core:0.8.20'
|
||||
compile 'org.msgpack:jackson-dataformat-msgpack:0.8.20'
|
||||
}
|
||||
|
||||
archivesBaseName = 'signalr-messagepack'
|
||||
|
||||
task sourceJar(type: Jar) {
|
||||
classifier "sources"
|
||||
from sourceSets.main.allJava
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier "javadoc"
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task generatePOM {
|
||||
pom {
|
||||
project {
|
||||
inceptionYear '2020'
|
||||
description 'MessagePack protocol implementation for ASP.NET Core SignalR Client for Java applications'
|
||||
url 'https://github.com/dotnet/aspnetcore'
|
||||
name groupId + ':' + artifactId
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
developerConnection 'scm:git:git://github.com/dotnet/aspnetcore.git'
|
||||
url 'http://github.com/dotnet/aspnetcore/tree/master'
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'microsoft'
|
||||
name 'Microsoft'
|
||||
}
|
||||
}
|
||||
}
|
||||
}.writeTo("${buildDir}/libs/signalr-messagepack-${project.version}.pom")
|
||||
}
|
||||
|
||||
task createPackage(dependsOn: [jar,sourceJar,javadocJar,generatePOM])
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<Project>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- This package ID is only ever used along with eng/PatchConfig.props to determine when to patch the Java client. -->
|
||||
<PackageId>java:signalr-messagepack</PackageId>
|
||||
<!-- In servicing builds, this will be set to value if the Java client is not configured to be released in the currently building patch. -->
|
||||
<IsPackable>true</IsPackable>
|
||||
<IsTestProject>false</IsTestProject>
|
||||
<!-- Disable gradle daemon on CI since the CI seems to try to wait for the daemon to shut down, which it doesn't do :) -->
|
||||
<GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -Dorg.gradle.daemon=false</GradleOptions>
|
||||
<PublishDir>$(OutputPath)</PublishDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Jars Include="
|
||||
signalr-messagepack-$(PackageVersion).jar;
|
||||
signalr-messagepack-$(PackageVersion)-javadoc.jar;
|
||||
signalr-messagepack-$(PackageVersion)-sources.jar;" />
|
||||
<PomFile Include="signalr-messagepack-$(PackageVersion).pom" />
|
||||
<JavaBuildFiles Include="@(Jars);@(PomFile)"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Restore" />
|
||||
|
||||
<PropertyGroup>
|
||||
<PackDependsOn Condition=" '$(NoBuild)' != 'true' ">
|
||||
$(PackDependsOn);
|
||||
Build
|
||||
</PackDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GradleOptions>$(GradleOptions) -PpackageVersion="$(PackageVersion)"</GradleOptions>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Define Target overrides after importing Directory.Build.targets so these don't get overridden -->
|
||||
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true'">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Pack" />
|
||||
<Message Text="> gradlew $(GradleOptions) createPackage" Importance="high" />
|
||||
<Exec Command="../gradlew $(GradleOptions) createPackage" />
|
||||
<Message Importance="high" Text="java:signalr-messagepack -> $(PackageOutputPath)%(JavaBuildFiles.Identity)" />
|
||||
<Copy SourceFiles="$(MSBuildThisFileDirectory)build\libs\%(JavaBuildFiles.Identity)" DestinationFolder="$(PackageOutputPath)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Build">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
|
||||
<Exec Command="../gradlew $(GradleOptions) compileJava" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Test" />
|
||||
|
||||
<Target Name="Publish" />
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
package com.microsoft.signalr.messagepack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -25,7 +25,21 @@ import org.msgpack.value.ValueType;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
class MessagePackHubProtocol implements HubProtocol {
|
||||
import com.microsoft.signalr.CancelInvocationMessage;
|
||||
import com.microsoft.signalr.CloseMessage;
|
||||
import com.microsoft.signalr.CompletionMessage;
|
||||
import com.microsoft.signalr.HubMessage;
|
||||
import com.microsoft.signalr.HubMessageType;
|
||||
import com.microsoft.signalr.HubProtocol;
|
||||
import com.microsoft.signalr.InvocationBinder;
|
||||
import com.microsoft.signalr.InvocationBindingFailureMessage;
|
||||
import com.microsoft.signalr.InvocationMessage;
|
||||
import com.microsoft.signalr.PingMessage;
|
||||
import com.microsoft.signalr.StreamBindingFailureMessage;
|
||||
import com.microsoft.signalr.StreamInvocationMessage;
|
||||
import com.microsoft.signalr.StreamItem;
|
||||
|
||||
public class MessagePackHubProtocol implements HubProtocol {
|
||||
|
||||
private static final int ERROR_RESULT = 1;
|
||||
private static final int VOID_RESULT = 2;
|
||||
|
|
@ -44,11 +58,6 @@ class MessagePackHubProtocol implements HubProtocol {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransferFormat getTransferFormat() {
|
||||
return TransferFormat.BINARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) {
|
||||
if (payload.remaining() == 0) {
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
package com.microsoft.signalr.messagepack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
|
|
@ -14,14 +11,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.ArrayList;
|
||||
|
||||
class Utils {
|
||||
public static String appendQueryString(String original, String queryStringValue) {
|
||||
if (original.contains("?")) {
|
||||
return original + "&" + queryStringValue;
|
||||
} else {
|
||||
return original + "?" + queryStringValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static int readLengthHeader(ByteBuffer buffer) throws IOException {
|
||||
// The payload starts with a length prefix encoded as a VarInt. VarInts use the most significant bit
|
||||
// as a marker whether the byte is the last byte of the VarInt or if it spans to the next byte. Bytes
|
||||
|
|
@ -89,9 +78,9 @@ class Utils {
|
|||
}
|
||||
|
||||
public static Class<?> typeToClass(Type type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
if (type instanceof Class) {
|
||||
return (Class<?>) type;
|
||||
} else if (type instanceof GenericArrayType) {
|
||||
|
|
@ -108,5 +97,5 @@ class Utils {
|
|||
} else {
|
||||
throw new UnsupportedOperationException("Cannot handle type class: " + type.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
rootProject.name = 'signalr'
|
||||
include 'main'
|
||||
include 'core', 'messagepack', 'test'
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
package com.microsoft.signalr;
|
||||
|
||||
class Version {
|
||||
public static String getDetailedVersion() {
|
||||
return "5.0.0-dev";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
apply plugin: 'org.junit.platform.gradle.plugin'
|
||||
|
||||
dependencies {
|
||||
implementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
|
||||
compile 'org.junit.jupiter:junit-jupiter-params:5.3.1'
|
||||
runtime 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
|
||||
implementation project(':core')
|
||||
implementation project(':messagepack')
|
||||
compile project(':messagepack')
|
||||
}
|
||||
|
||||
junitPlatform {
|
||||
reportsDir file('test-results')
|
||||
}
|
||||
|
|
@ -2,75 +2,44 @@
|
|||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!-- This package ID is only ever used along with eng/PatchConfig.props to determine when to patch the Java client. -->
|
||||
<PackageId>java:signalr</PackageId>
|
||||
|
||||
<!-- In servicing builds, this will be set to value if the Java client is not configured to be released in the currently building patch. -->
|
||||
<IsPackable>true</IsPackable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
|
||||
<!-- Installing Java on ARM will take some work -->
|
||||
<SkipHelixArm>true</SkipHelixArm>
|
||||
|
||||
<!-- Skipping on Helix for now -->
|
||||
<BuildHelixPayload>false</BuildHelixPayload>
|
||||
<!-- Disable gradle daemon on CI since the CI seems to try to wait for the daemon to shut down, which it doesn't do :) -->
|
||||
<GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -Dorg.gradle.daemon=false</GradleOptions>
|
||||
<PublishDir>$(OutputPath)</PublishDir>
|
||||
<TestDependsOnJava>true</TestDependsOnJava>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Jars Include="
|
||||
signalr-$(PackageVersion).jar;
|
||||
signalr-$(PackageVersion)-javadoc.jar;
|
||||
signalr-$(PackageVersion)-sources.jar;" />
|
||||
<PomFile Include="signalr-$(PackageVersion).pom" />
|
||||
<JavaBuildFiles Include="@(Jars);@(PomFile)"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Restore" />
|
||||
|
||||
<PropertyGroup>
|
||||
<PackDependsOn Condition=" '$(NoBuild)' != 'true' ">
|
||||
$(PackDependsOn);
|
||||
Build
|
||||
</PackDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
|
||||
|
||||
<!-- Define Target overrides after importing Directory.Build.targets so these don't get overridden -->
|
||||
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true'">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Pack" />
|
||||
<Message Text="> gradlew $(GradleOptions) createPackage" Importance="high" />
|
||||
<Exec Command="./gradlew $(GradleOptions) createPackage" />
|
||||
<Message Importance="high" Text="java:signalr -> $(PackageOutputPath)%(JavaBuildFiles.Identity)" />
|
||||
<Copy SourceFiles="build\libs\%(JavaBuildFiles.Identity)" DestinationFolder="$(PackageOutputPath)" />
|
||||
</Target>
|
||||
<Target Name="Pack" />
|
||||
|
||||
<Target Name="Build">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
|
||||
<Exec Command="./gradlew $(GradleOptions) compileJava" />
|
||||
</Target>
|
||||
<Target Name="Build" />
|
||||
|
||||
<Target Name="Test" Condition="'$(SkipTests)' != 'true'">
|
||||
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
|
||||
<Message Text="Running Java client tests" Importance="high" />
|
||||
<Message Text="> gradlew $(GradleOptions) test" Importance="high" />
|
||||
<Exec Command="./gradlew $(GradleOptions) test" IgnoreStandardErrorWarningFormat="true" />
|
||||
<Exec Command="../gradlew $(GradleOptions) test" IgnoreStandardErrorWarningFormat="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Publish">
|
||||
<ItemGroup>
|
||||
<Files Include="**/*.java" />
|
||||
<Files Include="**/gradle-wrapper.jar" />
|
||||
<Files Include="**/gradle-wrapper.properties" />
|
||||
<Files Include="gradlew" />
|
||||
<Files Include="../**/*.java" />
|
||||
<Files Include="../**/gradle-wrapper.jar" />
|
||||
<Files Include="../**/gradle-wrapper.properties" />
|
||||
<Files Include="../gradlew" />
|
||||
<Files Include="build.gradle" />
|
||||
<Files Include="gradlew.bat" />
|
||||
<Files Include="settings.gradle" />
|
||||
<Files Include="../build.gradle" />
|
||||
<Files Include="../gradlew.bat" />
|
||||
<Files Include="../settings.gradle" />
|
||||
<Files Include="@(Content)" />
|
||||
</ItemGroup>
|
||||
<Copy DestinationFiles="@(Files->'$(PublishDir)\%(RecursiveDir)%(FileName)%(Extension)')" SourceFiles="@(Files)" />
|
||||
|
|
@ -26,11 +26,6 @@ class JsonHubProtocolTest {
|
|||
assertEquals(1, jsonHubProtocol.getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkTransferFormat() {
|
||||
assertEquals(TransferFormat.TEXT, jsonHubProtocol.getTransferFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyWriteMessage() {
|
||||
InvocationMessage invocationMessage = new InvocationMessage(null, null, "test", new Object[] {"42"}, null);
|
||||
|
|
@ -19,6 +19,8 @@ import java.util.TreeMap;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.microsoft.signalr.messagepack.MessagePackHubProtocol;
|
||||
|
||||
class MessagePackHubProtocolTest {
|
||||
private MessagePackHubProtocol messagePackHubProtocol = new MessagePackHubProtocol();
|
||||
|
||||
|
|
@ -31,11 +33,6 @@ class MessagePackHubProtocolTest {
|
|||
public void checkVersionNumber() {
|
||||
assertEquals(1, messagePackHubProtocol.getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkTransferFormat() {
|
||||
assertEquals(TransferFormat.BINARY, messagePackHubProtocol.getTransferFormat());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyWriteInvocationMessage() {
|
||||
|
|
@ -5,6 +5,7 @@ package com.microsoft.signalr;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import com.microsoft.signalr.messagepack.MessagePackHubProtocol;
|
||||
|
||||
class TestUtils {
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ class TestUtils {
|
|||
.shouldSkipNegotiate(skipNegotiate);
|
||||
|
||||
if (withMessagePack) {
|
||||
builder = builder.withMessagePackHubProtocol();
|
||||
builder = builder.withHubProtocol(new MessagePackHubProtocol());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
Loading…
Reference in New Issue