-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finagle-mux: Add API for Request Which Only Needs the Body
Problem / Solution When testing functionality via the Mux protocol, if only testing the internal mechanics of how clients and servers interact, specifying a `Path` for a mux `Request` to use is unnecessary and adds to extra code to write and maintain. This change provides the ability to create a mux `Request` in both Scala and Java without specifying a `Path` explicitly. In those cases `Path.empty` will be used. Differential Revision: https://phabricator.twitter.biz/D613686
- Loading branch information
1 parent
6b79926
commit 3ca4630
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
finagle-mux/src/test/java/com/twitter/finagle/mux/RequestsCompilationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.twitter.finagle.mux; | ||
|
||
import org.junit.Test; | ||
|
||
import com.twitter.io.Buf; | ||
import com.twitter.io.Bufs; | ||
|
||
public class RequestsCompilationTest { | ||
|
||
private Buf buf = Bufs.EMPTY; | ||
|
||
@Test | ||
public void makeWithPayload() { | ||
Request request = Requests.make(buf); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
finagle-mux/src/test/scala/com/twitter/finagle/mux/RequestTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.twitter.finagle.mux | ||
|
||
import com.twitter.finagle.Path | ||
import com.twitter.io.Buf | ||
import org.scalatest.FunSuite | ||
|
||
class RequestTest extends FunSuite { | ||
|
||
test("create request with payload") { | ||
val buf = Buf.Utf8("Hello") | ||
val request = Request(buf) | ||
assert(request.destination == Path.empty) | ||
assert(request.contexts == Nil) | ||
assert(request.body == buf) | ||
} | ||
|
||
} |