esoe 2 years ago
parent
commit
3c161d49b0
  1. 181
      pom.xml
  2. 5
      src/main/java/module-info.java
  3. 37
      src/main/java/ru/molokoin/App.java
  4. 32
      src/main/java/ru/molokoin/ExchangeServer.java
  5. 37
      src/main/java/ru/molokoin/MainFrameController.java
  6. 13
      src/main/java/ru/molokoin/SystemInfo.java
  7. 10
      src/main/resources/face/mainframe.fxml
  8. 0
      src/main/webapp/upload.http
  9. 18
      src/test/java/ru/molokoin/AppTest.java
  10. 10
      target/classes/face/mainframe.fxml
  11. BIN
      target/classes/module-info.class
  12. BIN
      target/classes/ru/molokoin/App.class
  13. BIN
      target/classes/ru/molokoin/ExchangeServer.class
  14. BIN
      target/classes/ru/molokoin/MainFrameController.class
  15. BIN
      target/classes/ru/molokoin/SystemInfo.class
  16. BIN
      target/classes/ru/molokoin/UploadServer.class
  17. 0
      target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  18. 5
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  19. BIN
      target/test-classes/ru/molokoin/AppTest.class

181
pom.xml

@ -4,170 +4,47 @@ @@ -4,170 +4,47 @@
<artifactId>exchange-server</artifactId>
<version>0.1</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.6.0</junit.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<checkstyle.version>8.39</checkstyle.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
<maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
<!-- JaCoCo thresholds. Increase gradually as you add tests. -->
<jacoco.unit-tests.limit.instruction-ratio>0%</jacoco.unit-tests.limit.instruction-ratio>
<jacoco.unit-tests.limit.branch-ratio>0%</jacoco.unit-tests.limit.branch-ratio>
<jacoco.unit-tests.limit.class-complexity>20</jacoco.unit-tests.limit.class-complexity>
<jacoco.unit-tests.limit.method-complexity>5</jacoco.unit-tests.limit.method-complexity>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.3</version>
</requireMavenVersion>
</rules>
<fail>true</fail>
<release>11</release>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
<dependency>
<groupId>com.github.ngeor</groupId>
<artifactId>checkstyle-rules</artifactId>
<version>4.8.0</version>
</dependency>
</dependencies>
<configuration>
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<skip>${skipTests}</skip>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check-unit-test</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.unit-tests.limit.instruction-ratio}</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.unit-tests.limit.branch-ratio}</minimum>
</limit>
</limits>
</rule>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>TOTALCOUNT</value>
<maximum>${jacoco.unit-tests.limit.class-complexity}</maximum>
</limit>
</limits>
</rule>
<rule>
<element>METHOD</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>TOTALCOUNT</value>
<maximum>${jacoco.unit-tests.limit.method-complexity}</maximum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>ru.molokoin.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>
</plugins>
</reporting>
</project>

5
src/main/java/module-info.java

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
module ru.molokoin {
requires javafx.controls;
requires javafx.fxml;
exports ru.molokoin;
}

37
src/main/java/ru/molokoin/App.java

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
package ru.molokoin;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
//import javafx.fxml.*;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* JavaFX App
*/
public class App extends Application {
@Override
public void start(Stage stage){
try {
String link = "/face/mainframe.fxml";
Parent root = FXMLLoader.load(getClass().getResource(link));
stage.setTitle("exchange-server-settings");
stage.setScene(new Scene(root));
stage.show();
} catch (Exception e) {
System.out.println("Не удалось запустить сцену. Ошибка: " + e);
}
}
public static void main(String[] args) {
launch();
}
}

32
src/main/java/ru/molokoin/ExchangeServer.java

@ -14,8 +14,26 @@ public class ExchangeServer{ @@ -14,8 +14,26 @@ public class ExchangeServer{
private static int port = 8081;
private static String link = "localhost";
private static int num = 0;
ServerSocket serverSocket;
Socket socket;
public static void main(String[] args) {
//подготовка компонентов
public void init(){
}
//остановка серера
public void stop(){
try {
serverSocket.close();
//socket.close();
} catch (Exception e) {
System.out.println("Остановить сервер не удалось. Ошибка: " + e);
}
}
//запуск сервера
public void start(){
try (ServerSocket serverSocket = new ServerSocket(port)) {
System.out.println("Server started at port: " + port + " ...");
@ -44,16 +62,19 @@ public class ExchangeServer{ @@ -44,16 +62,19 @@ public class ExchangeServer{
if(firstLine.startsWith("GET")){
querry = "GET";
}
if(firstLine.startsWith("POST")){
querry = "POST";
}
System.out.println("firstLine: " + firstLine);
System.out.println("querry: " + querry);
}
System.out.println(line);
//System.out.println(line);
}
// отправляем ответ
System.out.println("отправка ответа от сервера:");
String path = new File("").getAbsolutePath();
String fileName = "upload.html";
String fileName = "upload.http";
path = path + "/src/main/webapp/";
File file = new File(path + fileName);
//String text = "";
@ -81,4 +102,9 @@ public class ExchangeServer{ @@ -81,4 +102,9 @@ public class ExchangeServer{
ex.printStackTrace();
}
}
public static void main(String[] args) {
new ExchangeServer().start();
}
}

37
src/main/java/ru/molokoin/MainFrameController.java

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
package ru.molokoin;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
public class MainFrameController implements Initializable{
@FXML
public Button btn;
public ExchangeServer server;
@Override
public void initialize(URL location, ResourceBundle resources) {
// TODO Auto-generated method stub
System.out.println("Инициализация компонентов интерфейса ...");
server = new ExchangeServer();
}
@FXML
public void buttonClicked(Event e){
System.out.println("Button clicked");
if (btn.getText().equals("START")){
btn.setText("STOP");
server.start();
}else {
btn.setText("START");
server.stop();
}
}
}

13
src/main/java/ru/molokoin/SystemInfo.java

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
package ru.molokoin;
public class SystemInfo {
public static String javaVersion() {
return System.getProperty("java.version");
}
public static String javafxVersion() {
return System.getProperty("javafx.version");
}
}

10
src/main/resources/face/mainframe.fxml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox prefHeight="200.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.molokoin.MainFrameController">
<Label text="exchange-server"/>
<Button fx:id="btn" text="START" onAction="#buttonClicked"/>
</VBox>

0
src/main/webapp/upload.html → src/main/webapp/upload.http

18
src/test/java/ru/molokoin/AppTest.java

@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
package ru.molokoin;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit test for simple App.
*/
class AppTest {
/**
* Rigorous Test.
*/
@Test
void testApp() {
assertEquals(1, 1);
}
}

10
target/classes/face/mainframe.fxml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox prefHeight="200.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.molokoin.MainFrameController">
<Label text="exchange-server"/>
<Button fx:id="btn" text="START" onAction="#buttonClicked"/>
</VBox>

BIN
target/classes/module-info.class

Binary file not shown.

BIN
target/classes/ru/molokoin/App.class

Binary file not shown.

BIN
target/classes/ru/molokoin/ExchangeServer.class

Binary file not shown.

BIN
target/classes/ru/molokoin/MainFrameController.class

Binary file not shown.

BIN
target/classes/ru/molokoin/SystemInfo.class

Binary file not shown.

BIN
target/classes/ru/molokoin/UploadServer.class

Binary file not shown.

0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

5
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
c:\Users\Strannik\Documents\esoe\code\exchange-server\src\main\java\ru\molokoin\SystemInfo.java
c:\Users\Strannik\Documents\esoe\code\exchange-server\src\main\java\module-info.java
c:\Users\Strannik\Documents\esoe\code\exchange-server\src\main\java\ru\molokoin\ExchangeServer.java
c:\Users\Strannik\Documents\esoe\code\exchange-server\src\main\java\ru\molokoin\App.java
c:\Users\Strannik\Documents\esoe\code\exchange-server\src\main\java\ru\molokoin\UploadServer.java

BIN
target/test-classes/ru/molokoin/AppTest.class

Binary file not shown.
Loading…
Cancel
Save