Skip to content

Commit

Permalink
Cleanup, added test directories, use new serialization methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Apr 27, 2017
1 parent 2266745 commit d9f4cb3
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 746 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ admin.log
bin
.classpath
.settings/org.scala-ide.sdt.core.prefs
.cache-tests
.cache-tests
/proteus/
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>

Expand Down Expand Up @@ -130,13 +131,23 @@
</plugins>
</build>
<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>8.1.11.v20170118</version>
<scope>runtime</scope>

<scope>runtime</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -337,4 +348,7 @@
<version>[3.2.0,)</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
10 changes: 9 additions & 1 deletion src/main/java/io/sinistral/proteus/controllers/Benchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ public class Benchmarks
@ApiOperation(value = "Json serialization endpoint", httpMethod = "GET" )
public void json(HttpServerExchange exchange)
{
response( JsonStream.serialize(ImmutableMap.of("message", "Hello, World!")) ).send(exchange);
response( JsonStream.serialize(ImmutableMap.of("message", "Hello, World!")) ).applicationJson().send(exchange);
}

@GET
@Path("/json2")
@ApiOperation(value = "Json serialization endpoint", httpMethod = "GET" )
public void json2(HttpServerExchange exchange)
{
response( JsonStream.serializeToBytes(ImmutableMap.of("message", "Hello, World!")) ).applicationJson().send(exchange);
}

@GET
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/io/sinistral/proteus/server/ServerResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,27 +378,6 @@ else if (hasEntity)
}
else
{
// if (exchange.isInIoThread() && handler != null)
// {
// exchange.dispatch(handler);
// return;
// }
//
// exchange.startBlocking();
//
// final int bufferSize = exchange.getConnection().getBufferSize();
//
// /**
// * @TODO Test that this is faster than a thread local JsonStream with the TypeLiteral relevant encoder
// **/
//
// try (final JsonStream stream = new JsonStream(exchange.getOutputStream(), bufferSize))
// {
// stream.writeViewVal(this.entity,this.jsonContext);
// }
//
// exchange.endExchange();

try
{
exchange.getResponseSender().send(JsonStream.serialize(this.entity, this.jsonContext));
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/io/sinistral/proteus/server/swagger/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.github.javaparser.utils.Log;

import io.sinistral.proteus.server.ServerRequest;
import io.sinistral.proteus.server.ServerResponse;
Expand Down Expand Up @@ -92,6 +91,7 @@
import io.undertow.server.HttpServerExchange;

/**
* Copied from swagger.io implementation with tweaks to ignore or re-map server specific classes
* @author jbauer
*
*/
Expand Down Expand Up @@ -196,7 +196,8 @@ protected Swagger read(Class<?> cls, String parentPath, String parentMethod, boo
return read(cls, parentPath, parentMethod, isSubresource, parentConsumes, parentProduces, parentTags, parentParameters, new HashSet<>());
}

private Swagger read(Class<?> cls, String parentPath, String parentMethod, boolean isSubresource, String[] parentConsumes, String[] parentProduces, Map<String, Tag> parentTags, List<Parameter> parentParameters, Set<Class<?>> scannedResources) {
@SuppressWarnings("deprecation")
private Swagger read(Class<?> cls, String parentPath, String parentMethod, boolean isSubresource, String[] parentConsumes, String[] parentProduces, Map<String, Tag> parentTags, List<Parameter> parentParameters, Set<Class<?>> scannedResources) {
Map<String, Tag> tags = new LinkedHashMap<String, Tag>();
List<SecurityRequirement> securities = new ArrayList<SecurityRequirement>();

Expand Down Expand Up @@ -474,7 +475,8 @@ protected Parameter readImplicitParam(ApiImplicitParam param) {
Arrays.<Annotation>asList(param));
}

protected void readSwaggerConfig(Class<?> cls, SwaggerDefinition config) {
@SuppressWarnings("deprecation")
protected void readSwaggerConfig(Class<?> cls, SwaggerDefinition config) {
if (!config.basePath().isEmpty()) {
swagger.setBasePath(config.basePath());
}
Expand Down Expand Up @@ -798,7 +800,8 @@ public Operation parseMethod(Method method) {
Collections.<Parameter> emptyList(), Collections.<ApiResponse> emptyList());
}

private Operation parseMethod(Class<?> cls, Method method, AnnotatedMethod annotatedMethod,
@SuppressWarnings("deprecation")
private Operation parseMethod(Class<?> cls, Method method, AnnotatedMethod annotatedMethod,
List<Parameter> globalParameters, List<ApiResponse> classApiResponses) {
Operation operation = new Operation();
if (annotatedMethod != null) {
Expand Down
Loading

0 comments on commit d9f4cb3

Please sign in to comment.