Code Monkey home page Code Monkey logo

verano-http's People

Contributors

dependabot[bot] avatar vatavuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

verano-http's Issues

Kvp lazy loading

Let's make Kvp.Template take Scalar<Kvp> in ctor, instead of Kvp, to achieve lazy loading.

ExpectedStatus

Let's create ExpectedStatus that will assert whether received status code matches the expected one.

java.lang.VerifyError: class org.cactoos.list.Mapped overrides final method toString.

The code is:

public class AppTest {

    @Test
    public void httpPost() {
        final Response response = new Response(
            new ApiUrl().asString(),
            new Post(
                "/api/auth/login",
                new JsonBody(
                    Json.createObjectBuilder().add(
                        "username",
                        "***"
                    ).add(
                        "password",
                        "***"
                    ).build()
                )
            )
        );
        System.out.println(new Body.Of(response).asString());
    }

}

The result is:

java.lang.VerifyError: class org.cactoos.list.Mapped overrides final method toString.()Ljava/lang/String;

	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at hr.com.vgv.verano.http.HashDict.<init>(HashDict.java:59)
	at hr.com.vgv.verano.http.HashDict.<init>(HashDict.java:51)
	at hr.com.vgv.verano.http.DictInput$Envelope.<init>(DictInput.java:67)
	at hr.com.vgv.verano.http.parts.RequestUri.<init>(RequestUri.java:47)
	at hr.com.vgv.verano.http.wire.apache.ApacheWire.<init>(ApacheWire.java:109)
	at hr.com.vgv.verano.http.wire.apache.ApacheWire.<init>(ApacheWire.java:80)
	at hr.com.vgv.verano.http.response.Response.<init>(Response.java:81)
	at ru.fusionsoft.AppTest.httpPost(AppTest.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Note: I have in my pom.xml

      <dependency>
          <groupId>org.cactoos</groupId>
          <artifactId>cactoos</artifactId>
          <version>0.50</version>
      </dependency>

You have in your pom.xml

        <dependency>
            <groupId>org.cactoos</groupId>
            <artifactId>cactoos</artifactId>
            <version>0.39</version>
        </dependency>

UniqueHeader

Create a header that will guarantee its uniqueness in header map.

Get/Post/Put/Delete methods

Let's create inner classes in Method.class that contains information for Get/Post/Put/Delete method names

AsyncResponse

Lets add support for handling of async http calls via new AsyncResponse class

ApacheHeaders

Create ApacheHeaders that will transform apache Header array to Iterable<Kvp>

Request/Response toString

Let's override Request/Response toString methods to have more comprehensive view when
an error occur.

ApacheWire null body

ApacheWire does not check if the response contains a body before fetching it.

HeadersOf

Create HeadersOf as iterable if headers

MockWire

Let's create mock wire for testing client. Mock wire shouldn't run on http, it should operate on java memory structures.

FailWith

Instead of

new ExpectedStatus("Cannot fetch from Google", 301)

use

new ExpectedStatus(301, new FailWith("CannotFetch from Google))

Note: Status code should always go before fail message

HeadersOf

Create HeadersOf that will extract headers from dict

Header asList

Lets add asList method to Header class that will return a list of header values.

Form params

FormParams (plural) override all the other params being sent in the same request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.