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:
Artak 2020-09-04 09:01:50 -07:00 committed by GitHub
commit fe1a881b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 373 additions and 208 deletions

View File

@ -2,7 +2,7 @@
.gradletasknamecache .gradletasknamecache
.gradle/ .gradle/
build/ build/
/test-results test/test-results
.settings/ .settings/
out/ out/
*.class *.class

View File

@ -15,32 +15,18 @@ plugins {
id 'maven' id 'maven'
} }
apply plugin: "java-library" allprojects {
apply plugin: "com.diffplug.gradle.spotless" apply plugin: "java-library"
apply plugin: 'org.junit.platform.gradle.plugin' 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. sourceCompatibility = 1.8
version project.findProperty('packageVersion') ?: "99.99.99-dev"
sourceCompatibility = 1.8 repositories {
mavenCentral()
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'
} }
spotless { spotless {
@ -48,7 +34,7 @@ spotless {
licenseHeader '// Copyright (c) .NET Foundation. All rights reserved.\n' + 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 '// 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 if', 'if(', 'if ('
replace 'Not enough space after else', 'else{', 'else {' replace 'Not enough space after else', 'else{', 'else {'
@ -66,73 +52,4 @@ spotless {
indentWithSpaces(4) indentWithSpaces(4)
removeUnusedImports() // removes any unused imports 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

View File

@ -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

View File

@ -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>

View File

@ -0,0 +1 @@
Version.java

View File

@ -5,7 +5,7 @@ package com.microsoft.signalr;
import java.util.Map; import java.util.Map;
final class CancelInvocationMessage extends HubMessage { public final class CancelInvocationMessage extends HubMessage {
private final int type = HubMessageType.CANCEL_INVOCATION.value; private final int type = HubMessageType.CANCEL_INVOCATION.value;
private Map<String, String> headers; private Map<String, String> headers;
private final String invocationId; private final String invocationId;

View File

@ -3,7 +3,7 @@
package com.microsoft.signalr; package com.microsoft.signalr;
final class CloseMessage extends HubMessage { public final class CloseMessage extends HubMessage {
private final String error; private final String error;
private final boolean allowReconnect; private final boolean allowReconnect;

View File

@ -5,7 +5,7 @@ package com.microsoft.signalr;
import java.util.Map; import java.util.Map;
final class CompletionMessage extends HubMessage { public final class CompletionMessage extends HubMessage {
private final int type = HubMessageType.COMPLETION.value; private final int type = HubMessageType.COMPLETION.value;
private Map<String, String> headers; private Map<String, String> headers;
private final String invocationId; private final String invocationId;

View File

@ -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. * @return This instance of the HttpHubConnectionBuilder.
*/ */
public HttpHubConnectionBuilder withMessagePackHubProtocol() { public HttpHubConnectionBuilder withHubProtocol(HubProtocol protocol) {
this.protocol = new MessagePackHubProtocol(); this.protocol = protocol;
return this; return this;
} }

View File

@ -6,6 +6,6 @@ package com.microsoft.signalr;
/** /**
* A base class for hub messages. * A base class for hub messages.
*/ */
abstract class HubMessage { public abstract class HubMessage {
public abstract HubMessageType getMessageType(); public abstract HubMessageType getMessageType();
} }

View File

@ -3,7 +3,7 @@
package com.microsoft.signalr; package com.microsoft.signalr;
enum HubMessageType { public enum HubMessageType {
INVOCATION(1), INVOCATION(1),
STREAM_ITEM(2), STREAM_ITEM(2),
COMPLETION(3), COMPLETION(3),

View File

@ -9,14 +9,14 @@ import java.util.List;
/** /**
* A protocol abstraction for communicating with SignalR hubs. * A protocol abstraction for communicating with SignalR hubs.
*/ */
interface HubProtocol { public interface HubProtocol {
String getName(); String getName();
int getVersion(); int getVersion();
TransferFormat getTransferFormat();
/** /**
* Creates a new list of {@link HubMessage}s. * Creates a new list of {@link HubMessage}s.
* @param message A ByteBuffer representation of one or more {@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. * @return A list of {@link HubMessage}s.
*/ */
List<HubMessage> parseMessages(ByteBuffer message, InvocationBinder binder); List<HubMessage> parseMessages(ByteBuffer message, InvocationBinder binder);

View File

@ -9,7 +9,7 @@ import java.util.List;
/** /**
* An abstraction for passing around information about method signatures. * An abstraction for passing around information about method signatures.
*/ */
interface InvocationBinder { public interface InvocationBinder {
Type getReturnType(String invocationId); Type getReturnType(String invocationId);
List<Type> getParameterTypes(String methodName); List<Type> getParameterTypes(String methodName);
} }

View File

@ -3,7 +3,7 @@
package com.microsoft.signalr; package com.microsoft.signalr;
class InvocationBindingFailureMessage extends HubMessage { public class InvocationBindingFailureMessage extends HubMessage {
private final String invocationId; private final String invocationId;
private final String target; private final String target;
private final Exception exception; private final Exception exception;

View File

@ -6,7 +6,7 @@ package com.microsoft.signalr;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
class InvocationMessage extends HubMessage { public class InvocationMessage extends HubMessage {
int type = HubMessageType.INVOCATION.value; int type = HubMessageType.INVOCATION.value;
private Map<String, String> headers; private Map<String, String> headers;
private final String invocationId; private final String invocationId;

View File

@ -34,11 +34,6 @@ class JsonHubProtocol implements HubProtocol {
return 1; return 1;
} }
@Override
public TransferFormat getTransferFormat() {
return TransferFormat.TEXT;
}
@Override @Override
public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) { public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) {
String payloadStr; String payloadStr;

View File

@ -3,7 +3,7 @@
package com.microsoft.signalr; package com.microsoft.signalr;
class PingMessage extends HubMessage public class PingMessage extends HubMessage
{ {
private final int type = HubMessageType.PING.value; private final int type = HubMessageType.PING.value;

View File

@ -3,7 +3,7 @@
package com.microsoft.signalr; package com.microsoft.signalr;
class StreamBindingFailureMessage extends HubMessage { public class StreamBindingFailureMessage extends HubMessage {
private final String invocationId; private final String invocationId;
private final Exception exception; private final Exception exception;

View File

@ -6,7 +6,7 @@ package com.microsoft.signalr;
import java.util.Collection; import java.util.Collection;
import java.util.Map; 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) { public StreamInvocationMessage(Map<String, String> headers, String invocationId, String target, Object[] args, Collection<String> streamIds) {
super(headers, invocationId, target, args, streamIds); super(headers, invocationId, target, args, streamIds);

View File

@ -5,7 +5,7 @@ package com.microsoft.signalr;
import java.util.Map; import java.util.Map;
final class StreamItem extends HubMessage { public final class StreamItem extends HubMessage {
private final int type = HubMessageType.STREAM_ITEM.value; private final int type = HubMessageType.STREAM_ITEM.value;
private Map<String, String> headers; private Map<String, String> headers;
private final String invocationId; private final String invocationId;

View File

@ -31,6 +31,7 @@ public class TypeReference<T> {
/** /**
* Gets the referenced type. * Gets the referenced type.
* @return The Type encapsulated by this TypeReference
*/ */
public Type getType() { public Type getType() {
return this.type; return this.type;

View File

@ -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());
}
}
}

View File

@ -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])

View File

@ -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>

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // 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. // 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.io.IOException;
import java.lang.reflect.Type; 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.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory; 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 ERROR_RESULT = 1;
private static final int VOID_RESULT = 2; private static final int VOID_RESULT = 2;
@ -44,11 +58,6 @@ class MessagePackHubProtocol implements HubProtocol {
return 1; return 1;
} }
@Override
public TransferFormat getTransferFormat() {
return TransferFormat.BINARY;
}
@Override @Override
public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) { public List<HubMessage> parseMessages(ByteBuffer payload, InvocationBinder binder) {
if (payload.remaining() == 0) { if (payload.remaining() == 0) {

View File

@ -1,7 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. package com.microsoft.signalr.messagepack;
// 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.io.IOException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
@ -14,14 +11,6 @@ import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
class Utils { 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 { 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 // 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 // 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) { public static Class<?> typeToClass(Type type) {
if (type == null) { if (type == null) {
return null; return null;
} }
if (type instanceof Class) { if (type instanceof Class) {
return (Class<?>) type; return (Class<?>) type;
} else if (type instanceof GenericArrayType) { } else if (type instanceof GenericArrayType) {
@ -108,5 +97,5 @@ class Utils {
} else { } else {
throw new UnsupportedOperationException("Cannot handle type class: " + type.getClass()); throw new UnsupportedOperationException("Cannot handle type class: " + type.getClass());
} }
} }
} }

View File

@ -1,2 +1,2 @@
rootProject.name = 'signalr' rootProject.name = 'signalr'
include 'main' include 'core', 'messagepack', 'test'

View File

@ -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";
}
}

View File

@ -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')
}

View File

@ -2,75 +2,44 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable>
<!-- 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>true</IsTestProject> <IsTestProject>true</IsTestProject>
<!-- Installing Java on ARM will take some work --> <!-- Installing Java on ARM will take some work -->
<SkipHelixArm>true</SkipHelixArm> <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 :) --> <!-- 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> <GradleOptions Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(GradleOptions) -Dorg.gradle.daemon=false</GradleOptions>
<PublishDir>$(OutputPath)</PublishDir> <PublishDir>$(OutputPath)</PublishDir>
<TestDependsOnJava>true</TestDependsOnJava> <TestDependsOnJava>true</TestDependsOnJava>
</PropertyGroup> </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" /> <Target Name="Restore" />
<PropertyGroup>
<PackDependsOn Condition=" '$(NoBuild)' != 'true' ">
$(PackDependsOn);
Build
</PackDependsOn>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" /> <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 --> <!-- Define Target overrides after importing Directory.Build.targets so these don't get overridden -->
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true'"> <Target Name="Pack" />
<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="Build"> <Target Name="Build" />
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
<Exec Command="./gradlew $(GradleOptions) compileJava" />
</Target>
<Target Name="Test" Condition="'$(SkipTests)' != 'true'"> <Target Name="Test" Condition="'$(SkipTests)' != 'true'">
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" /> <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" />
<Message Text="Running Java client tests" Importance="high" /> <Message Text="Running Java client tests" Importance="high" />
<Message Text="> gradlew $(GradleOptions) test" 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>
<Target Name="Publish"> <Target Name="Publish">
<ItemGroup> <ItemGroup>
<Files Include="**/*.java" /> <Files Include="../**/*.java" />
<Files Include="**/gradle-wrapper.jar" /> <Files Include="../**/gradle-wrapper.jar" />
<Files Include="**/gradle-wrapper.properties" /> <Files Include="../**/gradle-wrapper.properties" />
<Files Include="gradlew" /> <Files Include="../gradlew" />
<Files Include="build.gradle" /> <Files Include="build.gradle" />
<Files Include="gradlew.bat" /> <Files Include="../build.gradle" />
<Files Include="settings.gradle" /> <Files Include="../gradlew.bat" />
<Files Include="../settings.gradle" />
<Files Include="@(Content)" /> <Files Include="@(Content)" />
</ItemGroup> </ItemGroup>
<Copy DestinationFiles="@(Files->'$(PublishDir)\%(RecursiveDir)%(FileName)%(Extension)')" SourceFiles="@(Files)" /> <Copy DestinationFiles="@(Files->'$(PublishDir)\%(RecursiveDir)%(FileName)%(Extension)')" SourceFiles="@(Files)" />

View File

@ -26,11 +26,6 @@ class JsonHubProtocolTest {
assertEquals(1, jsonHubProtocol.getVersion()); assertEquals(1, jsonHubProtocol.getVersion());
} }
@Test
public void checkTransferFormat() {
assertEquals(TransferFormat.TEXT, jsonHubProtocol.getTransferFormat());
}
@Test @Test
public void verifyWriteMessage() { public void verifyWriteMessage() {
InvocationMessage invocationMessage = new InvocationMessage(null, null, "test", new Object[] {"42"}, null); InvocationMessage invocationMessage = new InvocationMessage(null, null, "test", new Object[] {"42"}, null);

View File

@ -19,6 +19,8 @@ import java.util.TreeMap;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import com.microsoft.signalr.messagepack.MessagePackHubProtocol;
class MessagePackHubProtocolTest { class MessagePackHubProtocolTest {
private MessagePackHubProtocol messagePackHubProtocol = new MessagePackHubProtocol(); private MessagePackHubProtocol messagePackHubProtocol = new MessagePackHubProtocol();
@ -31,11 +33,6 @@ class MessagePackHubProtocolTest {
public void checkVersionNumber() { public void checkVersionNumber() {
assertEquals(1, messagePackHubProtocol.getVersion()); assertEquals(1, messagePackHubProtocol.getVersion());
} }
@Test
public void checkTransferFormat() {
assertEquals(TransferFormat.BINARY, messagePackHubProtocol.getTransferFormat());
}
@Test @Test
public void verifyWriteInvocationMessage() { public void verifyWriteInvocationMessage() {

View File

@ -5,6 +5,7 @@ package com.microsoft.signalr;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import com.microsoft.signalr.messagepack.MessagePackHubProtocol;
class TestUtils { class TestUtils {
@ -33,7 +34,7 @@ class TestUtils {
.shouldSkipNegotiate(skipNegotiate); .shouldSkipNegotiate(skipNegotiate);
if (withMessagePack) { if (withMessagePack) {
builder = builder.withMessagePackHubProtocol(); builder = builder.withHubProtocol(new MessagePackHubProtocol());
} }
return builder.build(); return builder.build();