Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions frameworks/Java/martian/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Martian Benchmarking Test

This is Martian's official website address[http://mars-framework.com/](http://mars-framework.com/)

## Versions

- Java OpenJDK 1.8
- Martian 3.2.13

##Test URLs
### JSON Encoding Test
http://localhost:8080/json
23 changes: 23 additions & 0 deletions frameworks/Java/martian/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"framework": "martian",
"tests": [{
"default": {
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"framework": "martian",
"language": "Java",
"flavor": "None",
"orm": "None",
"platform": "Martian",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "martian-mvc",
"notes": "martian webserver with mvc",
"versus": "martian"
}
}]
}
14 changes: 14 additions & 0 deletions frameworks/Java/martian/martian.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM maven:3.6.1-jdk-11-slim as maven
WORKDIR /martian
COPY pom.xml pom.xml
COPY src src
RUN mvn package -q

FROM openjdk:11.0.3-jdk-slim
WORKDIR /martian
COPY --from=maven /martian/target/martian.jar martian.jar
COPY --from=maven /martian/target/lib lib

EXPOSE 8080

CMD ["java", "-jar", "martian.jar"]
69 changes: 69 additions & 0 deletions frameworks/Java/martian/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>martian</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<!-- 这个包为框架的启动器 -->
<dependency>
<groupId>com.github.yuyenews</groupId>
<artifactId>mars-starter</artifactId>
<version>3.2.13</version>
</dependency>

<!-- 下面的jar包为日志框架,必须引入,否则控制台看不到任何信息,此处以jdk日志为例 -->

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.12</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<finalName>martian</finalName>
<archive>
<manifest>
<mainClass>com.text.Start</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>./lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions frameworks/Java/martian/src/main/java/com/text/Start.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.text;

import com.mars.start.StartMars;
import com.text.config.TestConfig;

public class Start {

public static void main(String[] args) {
StartMars.start(Start.class, new TestConfig());
}
}
11 changes: 11 additions & 0 deletions frameworks/Java/martian/src/main/java/com/text/api/TestApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.text.api;

import com.mars.common.annotation.api.MarsApi;
import com.mars.server.server.request.HttpMarsResponse;
import com.text.api.vo.MessageVO;

@MarsApi(refBean = "testService")
public interface TestApi {

MessageVO json(HttpMarsResponse response);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.text.api.vo;

public class MessageVO {

private String message;

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.text.config;

import com.mars.common.base.config.MarsConfig;

public class TestConfig extends MarsConfig {

@Override
public int port() {
return 8080;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.text.service;

import com.mars.common.annotation.bean.MarsBean;
import com.mars.iserver.server.impl.MarsHttpExchange;
import com.mars.iserver.server.model.HttpHeaders;
import com.mars.server.server.request.HttpMarsRequest;
import com.mars.server.server.request.HttpMarsResponse;
import com.text.api.vo.MessageVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

@MarsBean
public class TestService {

private Logger logger = LoggerFactory.getLogger(TestService.class);

public MessageVO json(HttpMarsResponse response){
MessageVO messageVO = new MessageVO();
messageVO.setMessage("Hello, World!");

response.setHeader("Server","Martian");
response.setHeader("Date", "Wed, "+new Date().toGMTString());

return messageVO;
}
}