Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
02da812
bumped up version to 1.2.0 SNAP
mrazjava Sep 15, 2017
f6940f7
javadoc
mrazjava Sep 15, 2017
747dcbb
javadoc typo
mrazjava Sep 15, 2017
2192520
initial travis build script
mrazjava Sep 16, 2017
448ad3f
readme: added build status
mrazjava Sep 16, 2017
d3f9e9c
code coverage w/ coveralls
mrazjava Sep 16, 2017
709840c
jacoco integration
mrazjava Sep 16, 2017
2512af4
branch status in readme
mrazjava Sep 16, 2017
4403042
missing table header
mrazjava Sep 16, 2017
72fc99e
optimized travis build, more readme badges
mrazjava Sep 16, 2017
7da1310
version badge
mrazjava Sep 16, 2017
a547fab
version badge wrong id
mrazjava Sep 16, 2017
19abc51
version badge - final fix
mrazjava Sep 16, 2017
8bbeb12
license + badge
mrazjava Sep 16, 2017
60fbd54
formatted readme
mrazjava Sep 16, 2017
ce5faed
readme formatting
mrazjava Sep 16, 2017
d4884b9
readme fmt (1)
mrazjava Sep 16, 2017
5719632
readme fmt (2)
mrazjava Sep 16, 2017
b435fcc
readme fmt (3)
mrazjava Sep 16, 2017
a897248
removed web (angular) client
mrazjava Sep 17, 2017
245a6d5
refactoring: renamed client/server to reflect socket implementation
mrazjava Sep 17, 2017
c817bd0
empty cmd ui project + basic API client contracts
mrazjava Sep 17, 2017
4059e0a
jacoco fixes (1)
mrazjava Sep 18, 2017
215611d
jacoco fixes (2)
mrazjava Sep 18, 2017
41fd897
travis (1)
mrazjava Sep 19, 2017
61896da
shell ui project structure
mrazjava Sep 19, 2017
f10ec00
refactoring: ui reader drives input/output
mrazjava Sep 21, 2017
cc7deaf
partitioned shell UI client to reader/writer
mrazjava Sep 22, 2017
28fa8ff
pre-release tweaks
mrazjava Sep 23, 2017
e331caf
improved logging during shell writer shutdown
mrazjava Sep 23, 2017
0059ede
prep release
mrazjava Sep 24, 2017
9fb3284
readme fix (1)
mrazjava Sep 24, 2017
7cbe3d7
readme fix (2)
mrazjava Sep 24, 2017
d2bf389
readme fix (3)
mrazjava Sep 24, 2017
d2b503e
readme fix (4)
mrazjava Sep 24, 2017
84e5b89
renamed license file
mrazjava Sep 24, 2017
6087105
externalized shell commons + readme tweaks
mrazjava Sep 24, 2017
a35bb02
pom cleanup
mrazjava Sep 25, 2017
397c184
readme (1)
mrazjava Sep 25, 2017
34cf881
readme (2)
mrazjava Sep 25, 2017
4d10a80
readme (3)
mrazjava Sep 25, 2017
f50dc8c
readme (4)
mrazjava Sep 25, 2017
e0cc9ec
shell writer EventHandler unit test
mrazjava Sep 25, 2017
33da14a
coveralls (1)
mrazjava Sep 26, 2017
5dbd94b
coveralls (2)
mrazjava Sep 26, 2017
cf59308
unit tests + cleanup
mrazjava Sep 27, 2017
dfcf96b
more unit tests
mrazjava Sep 27, 2017
c573382
readme logo
mrazjava Sep 27, 2017
566ec90
readme logo (1)
mrazjava Sep 27, 2017
c3a6b75
readme update
mrazjava Sep 27, 2017
a82cdd0
readme formatting
mrazjava Sep 27, 2017
514b029
readme typo
mrazjava Sep 27, 2017
41d7a06
readme logo resize (1)
mrazjava Sep 28, 2017
2a94371
readme logo resize (2)
mrazjava Sep 28, 2017
8e341de
readme logo resize (3)
mrazjava Sep 28, 2017
ae1602b
readme logo resize (4)
mrazjava Sep 28, 2017
e71dcfa
readme logo resize (5)
mrazjava Sep 28, 2017
7c9d9b7
readme logo resize (6)
mrazjava Sep 28, 2017
753ec77
readme logo resize (7)
mrazjava Sep 28, 2017
5ef0d2e
readme logo resize (8)
mrazjava Sep 28, 2017
da80b06
readme logo resize (9)
mrazjava Sep 28, 2017
38b255c
readme logo resize (10)
mrazjava Sep 28, 2017
99bd7f9
readme logo resize (11)
mrazjava Sep 28, 2017
3b546b1
readme logo resize (12)
mrazjava Sep 28, 2017
e6169e2
readme logo resize (13)
mrazjava Sep 28, 2017
ca0916a
readme logo resize (14)
mrazjava Sep 28, 2017
d039202
readme content (1)
mrazjava Sep 28, 2017
6c2ecfb
readme content (2)
mrazjava Sep 28, 2017
15adf69
logback root level set to WARN by default
mrazjava Sep 28, 2017
34199b5
readme content (3) - jmx screenshot
mrazjava Sep 28, 2017
9f07904
readme content (4)
mrazjava Sep 28, 2017
6590060
more unit tests
mrazjava Sep 28, 2017
2819816
readme + logging tweaks
mrazjava Sep 28, 2017
5f0f1b2
more unit tests
mrazjava Sep 29, 2017
3d2f904
deleted wrong log commit
mrazjava Sep 29, 2017
9da0ae2
more unit tests
mrazjava Sep 29, 2017
01e6ad5
more unit tests
mrazjava Sep 29, 2017
34b68bf
unit tests for moo-test-utils
mrazjava Sep 30, 2017
64dab5d
more unit tests for moo-api
mrazjava Sep 30, 2017
97a6233
unit tests; code coverage up to 94%
mrazjava Oct 3, 2017
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 .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language:
- java
dist:
- trusty
jdk:
- oraclejdk8
install:
- mvn test-compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script:
- mvn verify jacoco:report
after_success:
- mvn coveralls:report
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2017 Adam Zimowski (mrazjava)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Binary file added docs/images/moo-jmx-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/moo-ui-shell-tmux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Miscellaneous docs for improved documentation. For example, contains images
which can be linked from the master readme.
14 changes: 4 additions & 10 deletions moo-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<parent>
<groupId>pl.zimowski</groupId>
<artifactId>moo</artifactId>
<version>1.1.0-FINAL</version>
<version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>moo-api</artifactId>
<name>Moo (api)</name>
<name>Moo API</name>
<description>Common data structures, contracts and utilities used for communication by server and client.</description>

<dependencies>
Expand All @@ -15,14 +15,8 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-integration</artifactId>
<scope>test</scope>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
</dependency>
</dependencies>

Expand Down
11 changes: 9 additions & 2 deletions moo-api/readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Moo - common API shared by client and server
=====================
# Moo - Chat API
---------------------
Common API shared by UI, client and server. Because UI is bound to an
API, and client powers UI at runtime, it is easy to build any new UI
client by simply implementing this API.

A UI application essentially must inject implementation of `ClientHandling`
(which is provided by client runtime), and register `ClientListener` which
will process chat events.
5 changes: 5 additions & 0 deletions moo-api/src/main/java/pl/zimowski/moo/api/ClientAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public enum ClientAction {
* After this operation user is ready to chat.
*/
Signin,

/**
* Client would like server to randomly generate user nick name.
*/
GenerateNick,

/**
* Client emitted a chat message to a server on behalf of end user.
Expand Down
16 changes: 16 additions & 0 deletions moo-api/src/main/java/pl/zimowski/moo/api/ClientHandling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pl.zimowski.moo.api;

/**
* @since 1.2.0
* @author Adam Zimowski (<a href="mailto:mrazjava@yandex.com">mrazjava</a>)
*/
public interface ClientHandling {

boolean connect(ClientListener listener);

boolean isConnected();

void disconnect();

void send(ClientEvent event);
}
10 changes: 10 additions & 0 deletions moo-api/src/main/java/pl/zimowski/moo/api/ClientListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package pl.zimowski.moo.api;

public interface ClientListener {

void onEvent(ServerEvent event);

void onBeforeServerConnect(String host, int port);

void onConnectToServerError(String error);
}
27 changes: 26 additions & 1 deletion moo-api/src/main/java/pl/zimowski/moo/api/ServerAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@
*/
public enum ServerAction {

/**
* Upon client request to establish connection with the server, server confirmed
* successful connection. Broadcast only to the thread that established
* connection.
*/
ConnectionEstablished,

/**
* Upon client request to generate a random nick name, server generated
* the nick name. Broadcast only to thread that generated {@link ClientAction#GenerateNick}.
*/
NickGenerated,

/**
* Confirmation of a successful user sign in. Broadcast only to thread that
* generated {@link ClientAction#Signin}.
*/
SigninConfirmed,

/**
* report count of online users due to change to client collection (login,
Expand All @@ -22,9 +37,19 @@ public enum ServerAction {
* server aborted client connection due to inactivity
*/
ConnectionTimeOut,

/**
* Client voluntarily chose to disconnect.
*/
ClientDisconnected,

/**
* chat message from another user
*/
Message
Message,

/**
* Server process terminated and all client connections were aborted
*/
ServerExit
}
37 changes: 34 additions & 3 deletions moo-api/src/main/java/pl/zimowski/moo/api/ServerEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
public class ServerEvent implements Serializable {

/**
* Name reported for messages authored by the server.
*/
public static final String AUTHOR = "server";

private static final long serialVersionUID = -6175363790070655216L;

private long timestamp;
Expand All @@ -21,7 +26,14 @@ public class ServerEvent implements Serializable {

private String message;

private String author = ApiUtils.APP_NAME;
/**
* Author which caused this event. Not every server event is caused by
* the server. In fact, most events are caused by clients and server
* simply echoes them back by broadcasting equivalent server event.
*/
private String author = ServerEvent.AUTHOR;

private String note;

private int participantCount;

Expand All @@ -46,6 +58,17 @@ public ServerEvent withAuthor(String author) {
return this;
}

/**
* Additional data associated with this an event. Often empty.
*
* @param note free text that could mean different things depending on the context
* @return metadata (note) associated with an event
*/
public ServerEvent withNote(String note) {
this.note = note;
return this;
}

public ServerEvent withParticipantCount(int count) {
participantCount = count;
return this;
Expand Down Expand Up @@ -84,7 +107,15 @@ public String getAuthor() {
return author;
}

/**
public String getNote() {
return note;
}

public void setNote(String note) {
this.note = note;
}

/**
* @return id of a client which triggered this server event; may be
* {@code null} if server itself triggered the event
*/
Expand All @@ -95,6 +126,6 @@ public String getClientId() {
@Override
public String toString() {
return "ServerEvent [timestamp=" + timestamp + ", action=" + action + ", clientId=" + clientId + ", author=" + author
+ ", message=" + message + ", participantCount=" + participantCount + "]";
+ ", message=" + message + ", note=" + note + ", participantCount=" + participantCount + "]";
}
}
36 changes: 35 additions & 1 deletion moo-api/src/test/java/pl/zimowski/moo/api/ApiUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

import static org.junit.Assert.assertEquals;

import java.nio.charset.Charset;

import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.runners.model.Statement;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

/**
* Ensures that {@link ApiUtils} operates as expected.
Expand All @@ -12,6 +20,13 @@
*/
public class ApiUtilsTest {

@Rule
public MockitoRule mockito = MockitoJUnit.rule();

@Mock
private Charset charset;


@Test
public void shouldFetchResource() {

Expand All @@ -20,4 +35,23 @@ public void shouldFetchResource() {

assertEquals(expectedContent, fetchedContent);
}
}

@Test
public void shouldNotFetchResource() {

ApiUtils.fetchResource("/blah-blah");
}

@Test
public void shouldPrintPrompt() {

SystemOutRule systemOutMock = new SystemOutRule().mute().enableLog();
systemOutMock.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
ApiUtils.printPrompt();
assertEquals("> ", systemOutMock.getLog());
}
}, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public void shouldProduceEventVia1ArgConstructor() {

assertTrue(event.getTimestamp() > 0);
assertEquals(ClientAction.Signin, event.getAction());
assertEquals(ClientAction.Signin, ClientAction.valueOf("Signin"));
assertNull(event.getAuthor());
assertNull(event.getMessage());
assertNull(event.getId());

event.withAuthor("foo").withMessage("bar");

Expand Down
Loading