From cb7d1617e55097b4fa5e46c3f6075d2d4bb95ff6 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 00:43:05 -0700 Subject: [PATCH 01/37] Start refactoring for 2.0.0 Refactored EventManagers to EventBus, start making tests dry. --- .../{EventManager.java => EventBus.java} | 8 +- ...ssistUtil.java => JavaAssistEventBus.java} | 68 ++-- ...ntManager.java => ReflectionEventBus.java} | 8 +- .../reflection/ReflectionMethodExecutor.java | 2 +- ...ventManagerTest.java => EventBusTest.java} | 37 +- .../trident/EventDoublyLinkedListTest.java | 322 ------------------ src/test/java/trident/IgnoreCanceledTest.java | 9 +- .../java/trident/JavaAssistEventBusTest.java} | 20 +- .../java/trident/JavaAssistMiscEventTest.java | 86 ----- src/test/java/trident/MultiThreadingTest.java | 77 ----- .../java/trident/ReflectionEventBusTest.java | 28 ++ .../trident/ReflectionEventManagerTest.java | 101 ------ 12 files changed, 103 insertions(+), 663 deletions(-) rename src/main/java/com/clubobsidian/trident/{EventManager.java => EventBus.java} (96%) rename src/main/java/com/clubobsidian/trident/impl/javaassist/{JavaAssistUtil.java => JavaAssistEventBus.java} (72%) rename src/main/java/com/clubobsidian/trident/impl/reflection/{ReflectionEventManager.java => ReflectionEventBus.java} (90%) rename src/test/java/trident/{JavaAssistEventManagerTest.java => EventBusTest.java} (62%) delete mode 100644 src/test/java/trident/EventDoublyLinkedListTest.java rename src/{main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventManager.java => test/java/trident/JavaAssistEventBusTest.java} (56%) delete mode 100644 src/test/java/trident/JavaAssistMiscEventTest.java delete mode 100644 src/test/java/trident/MultiThreadingTest.java create mode 100644 src/test/java/trident/ReflectionEventBusTest.java delete mode 100644 src/test/java/trident/ReflectionEventManagerTest.java diff --git a/src/main/java/com/clubobsidian/trident/EventManager.java b/src/main/java/com/clubobsidian/trident/EventBus.java similarity index 96% rename from src/main/java/com/clubobsidian/trident/EventManager.java rename to src/main/java/com/clubobsidian/trident/EventBus.java index 6958b74..7f6af9e 100644 --- a/src/main/java/com/clubobsidian/trident/EventManager.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -27,16 +27,16 @@ import com.clubobsidian.trident.util.EventNode; /** - * Abstract class for implementing EventManager - * classes. For an example see @see com.clubobsidian.trident.impl.javaassist.JavaAssistEventManager + * Abstract class for implementing EventBus + * classes. For an example see @see com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus * * @author virustotalop */ -public abstract class EventManager { +public abstract class EventBus { private Map> registeredEventListeners; private Map, EventDoublyLinkedList> registeredExecutors; - public EventManager() + public EventBus() { this.registeredEventListeners = new ConcurrentHashMap<>(); this.registeredExecutors = new ConcurrentHashMap<>(); diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistUtil.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java similarity index 72% rename from src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistUtil.java rename to src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index d1bcd10..48013e9 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistUtil.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -21,6 +21,8 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; +import com.clubobsidian.trident.Event; +import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; @@ -33,35 +35,36 @@ import javassist.LoaderClassPath; import javassist.NotFoundException; -public final class JavaAssistUtil { +/** + * {@inheritDoc} + */ +public class JavaAssistEventBus extends EventBus { - private static ClassPool pool; private static ConcurrentMap map; static { - try - { - map = new ConcurrentHashMap<>(); - pool = new ClassPool(true); - pool.insertClassPath("com.clubobsidian.trident.impl.javaassist.MethodCallback"); - pool.insertClassPath("com.clubobsidian.trident.Event"); - pool.insertClassPath("com.clubobsidian.trident.Listener"); - } - catch (NotFoundException e) - { - e.printStackTrace(); - } + JavaAssistEventBus.map = new ConcurrentHashMap<>(); } - private JavaAssistUtil() {} + private ClassPool pool; + public JavaAssistEventBus() + { + this.pool = new ClassPool(true); + } - public static ClassPool getClassPool() + public ClassPool getClassPool() { - return JavaAssistUtil.pool; + return this.pool; } - - public static MethodExecutor generateMethodExecutor(final Listener listener, final Method method, final boolean ignoreCanceled) + + @Override + protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + { + return this.generateMethodExecutor(listener, method, ignoreCanceled); + } + + private MethodExecutor generateMethodExecutor(final Listener listener, final Method method, final boolean ignoreCanceled) { if(listener == null || method == null) return null; @@ -71,9 +74,16 @@ public static MethodExecutor generateMethodExecutor(final Listener listener, fin ClassLoader classLoader = listener.getClass().getClassLoader(); Class listenerClass = Class.forName(listener.getClass().getName(), true, classLoader); - pool.insertClassPath(new LoaderClassPath(classLoader)); - pool.insertClassPath(new ClassClassPath(listenerClass)); - + + this.addClassToPool(Event.class); + this.addClassToPool(Listener.class); + + if(this.pool.getOrNull(listenerClass.getName()) == null) + { + this.pool.insertClassPath(new LoaderClassPath(classLoader)); + this.addClassToPool(listenerClass); + } + String callbackClassName = listener.getClass().getName() + method.getName(); AtomicInteger collision = map.get(callbackClassName); @@ -107,7 +117,7 @@ public static MethodExecutor generateMethodExecutor(final Listener listener, fin CtMethod call = CtNewMethod.make(sb.toString(), methodExecutorClass); methodExecutorClass.addMethod(call); - Class cl = methodExecutorClass.toClass(classLoader, JavaAssistEventManager.class.getProtectionDomain()); + Class cl = methodExecutorClass.toClass(classLoader, JavaAssistEventBus.class.getProtectionDomain()); return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCanceled); } catch (NotFoundException | CannotCompileException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException e) @@ -116,4 +126,14 @@ public static MethodExecutor generateMethodExecutor(final Listener listener, fin } return null; } -} + + private boolean addClassToPool(Class clazz) + { + if(this.pool.getOrNull(clazz.getName()) == null) + { + this.pool.insertClassPath(new ClassClassPath(clazz)); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventManager.java b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java similarity index 90% rename from src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventManager.java rename to src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java index 244bf62..78c925a 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventManager.java +++ b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java @@ -17,20 +17,18 @@ import java.lang.reflect.Method; -import com.clubobsidian.trident.EventManager; +import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; /** * {@inheritDoc} */ -public class ReflectionEventManager extends EventManager { +public class ReflectionEventBus extends EventBus { @Override protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) { return new ReflectionMethodExecutor(listener, method, ignoreCanceled); } - - -} +} \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java index d1c5991..a349942 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java @@ -44,4 +44,4 @@ public void execute(final Event event) e.printStackTrace(); } } -} +} \ No newline at end of file diff --git a/src/test/java/trident/JavaAssistEventManagerTest.java b/src/test/java/trident/EventBusTest.java similarity index 62% rename from src/test/java/trident/JavaAssistEventManagerTest.java rename to src/test/java/trident/EventBusTest.java index 245173a..78adb3f 100644 --- a/src/test/java/trident/JavaAssistEventManagerTest.java +++ b/src/test/java/trident/EventBusTest.java @@ -1,36 +1,20 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ package trident; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.junit.Test; import com.clubobsidian.trident.Event; -import com.clubobsidian.trident.EventManager; -import com.clubobsidian.trident.impl.javaassist.JavaAssistEventManager; +import com.clubobsidian.trident.EventBus; -public class JavaAssistEventManagerTest { +public abstract class EventBusTest { @Test public void testEventFiring() { TestListener test = new TestListener("test"); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); boolean registered = manager.registerEvents(test); assertTrue("Event is not registered", registered); @@ -49,7 +33,7 @@ public void testEventFiring() public void testEventCancellable() { TestListener test = new TestListener("test"); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); manager.registerEvents(test); manager.callEvent(new TestCancelableEvent()); @@ -61,7 +45,7 @@ public void testEventCancellable() public void testOrder() { TestListener test = new TestListener(""); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); manager.registerEvents(test); manager.callEvent(new TestOrderEvent()); @@ -73,7 +57,7 @@ public void testOrder() public void testDoubleRegister() { TestListener test = new TestListener("test"); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); manager.registerEvents(test); assertFalse("Event was double registered", manager.registerEvents(test)); @@ -83,7 +67,7 @@ public void testDoubleRegister() public void testCalledEvent() { Event event = new TestEvent(); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); assertFalse("Event call ran when event did not exist", manager.callEvent(event)); } @@ -92,10 +76,13 @@ public void testCalledEvent() public void testUnregister() { TestListener test = new TestListener("test"); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = this.createNewEventBus(); manager.registerEvents(test); assertTrue("Listener was not registered", manager.unregisterEvents(test)); assertFalse("Listener was still registered", manager.unregisterEvents(test)); } + + protected abstract EventBus createNewEventBus(); + } \ No newline at end of file diff --git a/src/test/java/trident/EventDoublyLinkedListTest.java b/src/test/java/trident/EventDoublyLinkedListTest.java deleted file mode 100644 index 8db6b16..0000000 --- a/src/test/java/trident/EventDoublyLinkedListTest.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package trident; - -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Random; - -import org.junit.Test; - -import com.clubobsidian.trident.EventPriority; -import com.clubobsidian.trident.MethodExecutor; -import com.clubobsidian.trident.impl.javaassist.JavaAssistUtil; -import com.clubobsidian.trident.util.EventDoublyLinkedList; -import com.clubobsidian.trident.util.EventNode; - -public class EventDoublyLinkedListTest { - - @Test - public void testOrder() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - - TestListener test = new TestListener("test"); - MethodExecutor executor = JavaAssistUtil.generateMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode low = list.insert(executor, EventPriority.LOW); - assertTrue("Low could not be inserted at head", low != null); - - assertTrue("Low is not head", list.getHead().getData().equals(executor)); - - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = JavaAssistUtil.generateMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode lowest = list.insert(executor2, EventPriority.LOWEST); - assertTrue("Lowest could not be inserted", lowest != null); - - assertTrue("Lowest is not head", list.getHead().getData().equals(executor2)); - - - TestListener test3 = new TestListener("test3"); - MethodExecutor executor3 = JavaAssistUtil.generateMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode nextLowest = list.insert(executor3, EventPriority.LOWEST); - assertTrue("NextLowest could not be inserted", nextLowest != null); - - assertTrue("NextLowest is not next to head", list.getHead().getNext().getData().equals(executor3)); - - - TestListener test4 = new TestListener("test4"); - MethodExecutor executor4 = JavaAssistUtil.generateMethodExecutor(test4, test4.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode monitor = list.insert(executor4, EventPriority.MONITOR); - assertTrue("Monitor could not be inserted", monitor != null); - - assertTrue("Monitor is not tail", list.find(executor4).getData().equals(executor4)); - - - TestListener test5 = new TestListener("test5"); - MethodExecutor executor5 = JavaAssistUtil.generateMethodExecutor(test5, test5.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode high = list.insert(executor5, EventPriority.HIGH); - assertTrue("High could not be inserted", high != null); - - assertTrue("High next node is not priority monitor", list.find(executor5).getNext().getData().equals(executor4)); - - TestListener test6 = new TestListener("test6"); - MethodExecutor executor6 = JavaAssistUtil.generateMethodExecutor(test6, test6.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode normal = list.insert(executor6, EventPriority.NORMAL); - assertTrue("Normal could not be inserted", normal != null); - - assertTrue("Normal next node is not priority high", list.find(executor6).getNext().getData().equals(executor5)); - - - TestListener test7 = new TestListener("test7"); - MethodExecutor executor7 = JavaAssistUtil.generateMethodExecutor(test7, test7.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode highest = list.insert(executor7, EventPriority.HIGHEST); - assertTrue("Highest could not be inserted", highest != null); - - assertTrue("Highest next node is not priority monitor", list.find(executor7).getNext().getData().equals(executor4)); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void testRemoval() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test = new TestListener("test1"); - MethodExecutor executor = JavaAssistUtil.generateMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - list.insert(executor, EventPriority.MONITOR); - - assertTrue("Monitor is not head", list.getHead().getData().equals(executor)); - list.remove(executor); - assertTrue("Head is not null after monitor removal", list.getHead() == null); - - for(int i = EventPriority.values()[0].getValue(); i < (EventPriority.values()[EventPriority.values().length - 1]).getValue() + 1; i++) - { - list.insert(JavaAssistUtil.generateMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class) , false), EventPriority.getByValue(i)); - } - - EventNode node = list.getHead(); - int removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all node", list.getHead() == null); - assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); - - for(int i = (EventPriority.values()[EventPriority.values().length - 1]).getValue(); i > -1 ; i--) - { - list.insert(JavaAssistUtil.generateMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(i)); - } - - node = list.getHead(); - removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all nodes reverse", list.getHead() == null); - assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); - - Random rand = new Random(); - - int iterate = 10000; - for(int i = 0; i < iterate; i++) - { - - rand.setSeed(System.nanoTime()); - int next = rand.nextInt(6); - EventNode inserted = list.insert(JavaAssistUtil.generateMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(next)); - - assertTrue("Insert failed for random insert for removal", inserted != null); - } - - node = list.getHead(); - removalCount = 0; - while(node != null) - { - list.remove(node.getData()); - removalCount += 1; - node = node.getNext(); - } - - assertTrue("Head is not null after traversing after removing all nodes after random insert", list.getHead() == null); - assertTrue("Removed nodes are not equal to iterating length after random insert", iterate == removalCount); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void emptyLinkedListTest() - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test = new TestListener("test1"); - try - { - MethodExecutor executor = JavaAssistUtil.generateMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); - assertTrue("Executor was removed", list.remove(executor) == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void nextIsNullAndNotHeadRemove() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = JavaAssistUtil.generateMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = JavaAssistUtil.generateMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor2, EventPriority.LOW); - - EventNode removed = list.remove(executor2); - - assertTrue("EventNode data was not equal", removed.getData().equals(executor2)); - - assertTrue("EventNode previous node's next node was not null", removed.getPrev().getNext() == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void foundIsMiddleNodeRemoveTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = JavaAssistUtil.generateMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = JavaAssistUtil.generateMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor2, EventPriority.LOW); - - TestListener test3 = new TestListener("test3"); - MethodExecutor executor3 = JavaAssistUtil.generateMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor3, EventPriority.NORMAL); - - EventNode removed = list.remove(executor2); - - assertTrue("Previous node's next node was not set to removed next node", removed.getPrev().getNext().equals(removed.getNext())); - - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void findMethodExecutorThatDoesNotExistTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = JavaAssistUtil.generateMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - assertTrue("Executor was found while not inserted", list.find(executor1) == null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test //This should never happen under normal circumstances but is being used for code coverage - public void findInsertNull() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - - Method findInsertion = list.getClass().getDeclaredMethod("findInsertionNode", int.class); - findInsertion.setAccessible(true); - assertTrue("Null node was not found", findInsertion.invoke(list, 6) == null); - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - e.printStackTrace(); - } - } - - @Test - public void findIfFoundNodePriorityIsTheSameTest() - { - try - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - TestListener test1 = new TestListener("test1"); - MethodExecutor executor1 = JavaAssistUtil.generateMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); - - list.insert(executor1, EventPriority.LOWEST); - - TestListener test2 = new TestListener("test2"); - MethodExecutor executor2 = JavaAssistUtil.generateMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); - - - EventPriority priority = EventPriority.LOWEST; - EventNode inserted = list.insert(executor2, priority); - - assertTrue("Previous node's priority is not the same", inserted.getPriority() == priority.getValue()); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void nullCaseTest() - { - EventDoublyLinkedList list = new EventDoublyLinkedList(); - EventNode inserted = list.insert(null, null); - assertTrue("Inserted was not null", inserted == null); - } -} \ No newline at end of file diff --git a/src/test/java/trident/IgnoreCanceledTest.java b/src/test/java/trident/IgnoreCanceledTest.java index b50089e..a344384 100644 --- a/src/test/java/trident/IgnoreCanceledTest.java +++ b/src/test/java/trident/IgnoreCanceledTest.java @@ -20,8 +20,8 @@ import org.junit.Test; -import com.clubobsidian.trident.EventManager; -import com.clubobsidian.trident.impl.javaassist.JavaAssistEventManager; +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; public class IgnoreCanceledTest { @@ -29,12 +29,11 @@ public class IgnoreCanceledTest { public void ignoredCanceled() { TestListenerIgnore listener = new TestListenerIgnore(); - EventManager manager = new JavaAssistEventManager(); + EventBus manager = new JavaAssistEventBus(); manager.registerEvents(listener); manager.callEvent(new TestCancelableEvent()); assertTrue("Event was not canceled", listener.isCanceled()); assertTrue("Event was not ignored", listener.getIgnored()); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventManager.java b/src/test/java/trident/JavaAssistEventBusTest.java similarity index 56% rename from src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventManager.java rename to src/test/java/trident/JavaAssistEventBusTest.java index e9bb2db..cdfa96a 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventManager.java +++ b/src/test/java/trident/JavaAssistEventBusTest.java @@ -13,22 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.clubobsidian.trident.impl.javaassist; +package trident; -import java.lang.reflect.Method; +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; -import com.clubobsidian.trident.EventManager; -import com.clubobsidian.trident.Listener; -import com.clubobsidian.trident.MethodExecutor; - -/** - * {@inheritDoc} - */ -public class JavaAssistEventManager extends EventManager { +public class JavaAssistEventBusTest extends EventBusTest { @Override - protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + protected EventBus createNewEventBus() { - return JavaAssistUtil.generateMethodExecutor(listener, method, ignoreCanceled); + return new JavaAssistEventBus(); } -} +} \ No newline at end of file diff --git a/src/test/java/trident/JavaAssistMiscEventTest.java b/src/test/java/trident/JavaAssistMiscEventTest.java deleted file mode 100644 index 7bd8d1f..0000000 --- a/src/test/java/trident/JavaAssistMiscEventTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package trident; - -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.Method; - -import org.junit.Test; - -import com.clubobsidian.trident.Event; -import com.clubobsidian.trident.EventPriority; -import com.clubobsidian.trident.Listener; -import com.clubobsidian.trident.MethodExecutor; -import com.clubobsidian.trident.impl.javaassist.JavaAssistUtil; - -public class JavaAssistMiscEventTest { - - @Test - public void eventNameTest() - { - Event event = new TestEvent(); - assertTrue(event.getName().equals("TestEvent")); - } - - @Test - public void methodExecutorTest() - { - try - { - Listener listener = new TestListener("test"); - Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); - MethodExecutor executor = JavaAssistUtil.generateMethodExecutor(listener, testEventMethod, false); - - assertTrue("Listeners are not equal for method executor", listener.equals(executor.getListener())); - assertTrue("Methods are not equal for method executor", testEventMethod.equals(executor.getMethod())); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void methodExecutorNullTest() - { - try - { - Listener listener = null; - Method testEventMethod = null; - MethodExecutor executor = JavaAssistUtil.generateMethodExecutor(listener, testEventMethod, false); - - assertTrue("Method executor was not null", executor == null); - } - catch (SecurityException e) - { - e.printStackTrace(); - } - } - - @Test - public void eventPriorityTest() - { - assertTrue("-1 event priority is not null", EventPriority.getByValue(-1) == null); - assertTrue("Length event priority is not null", EventPriority.getByValue(EventPriority.values().length) == null); - } - - @Test - public void classPoolTest() - { - assertTrue("Class pool is null", JavaAssistUtil.getClassPool() != null); - } -} \ No newline at end of file diff --git a/src/test/java/trident/MultiThreadingTest.java b/src/test/java/trident/MultiThreadingTest.java deleted file mode 100644 index 5e3eaf9..0000000 --- a/src/test/java/trident/MultiThreadingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package trident; - -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.Test; - -import com.clubobsidian.trident.EventPriority; -import com.clubobsidian.trident.MethodExecutor; -import com.clubobsidian.trident.impl.javaassist.JavaAssistUtil; -import com.clubobsidian.trident.util.EventDoublyLinkedList; -import com.clubobsidian.trident.util.EventNode; - -public class MultiThreadingTest { - - @Test - public void multiThreadingTestEventDoublyLinkedList() - { - AtomicInteger count = new AtomicInteger(0); - final EventDoublyLinkedList list = new EventDoublyLinkedList(); - Runnable testRunnable = new Runnable() - { - @Override - public void run() - { - for(int i = 0; i < 1000; i++) - { - try - { - int inc = count.incrementAndGet(); - TestListener testListener = new TestListener("test" + inc); - MethodExecutor testExecutor = JavaAssistUtil.generateMethodExecutor(testListener, testListener.getClass().getDeclaredMethod("test", TestEvent.class), false); - EventNode node = list.insert(testExecutor, EventPriority.LOWEST); - assertTrue("Node was null when inserted", node != null); - } - catch (NoSuchMethodException | SecurityException e) - { - e.printStackTrace(); - } - } - Thread.currentThread().interrupt(); - } - }; - Thread th1 = new Thread(testRunnable); - Thread th2 = new Thread(testRunnable); - - th1.start(); - th2.start(); - - while(th1.isAlive() || th2.isAlive()); - - int nodeCount = 0; - EventNode node = list.getHead(); - while(node != null) - { - nodeCount+= 1; - node = node.getNext(); - } - assertTrue("Node count not equal when running from multiple thread", nodeCount == count.get()); - } -} diff --git a/src/test/java/trident/ReflectionEventBusTest.java b/src/test/java/trident/ReflectionEventBusTest.java new file mode 100644 index 0000000..7c61d99 --- /dev/null +++ b/src/test/java/trident/ReflectionEventBusTest.java @@ -0,0 +1,28 @@ +/* + Copyright 2018 Club Obsidian and contributors. + + 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. +*/ +package trident; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.impl.reflection.ReflectionEventBus; + +public class ReflectionEventBusTest extends EventBusTest { + + @Override + protected EventBus createNewEventBus() + { + return new ReflectionEventBus(); + } +} \ No newline at end of file diff --git a/src/test/java/trident/ReflectionEventManagerTest.java b/src/test/java/trident/ReflectionEventManagerTest.java deleted file mode 100644 index 21921c5..0000000 --- a/src/test/java/trident/ReflectionEventManagerTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package trident; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.clubobsidian.trident.Event; -import com.clubobsidian.trident.EventManager; -import com.clubobsidian.trident.impl.reflection.ReflectionEventManager; - -public class ReflectionEventManagerTest { - - @Test - public void testEventFiring() - { - TestListener test = new TestListener("test"); - EventManager manager = new ReflectionEventManager(); - boolean registered = manager.registerEvents(test); - - assertTrue("Event is not registered", registered); - assertFalse("Test is not false", test.getTest()); - - manager.callEvent(new TestEvent()); - - assertTrue("Test is not true", test.getTest()); - - manager.callEvent(new TestEvent()); - - assertFalse("Test is not false", test.getTest()); - } - - @Test - public void testEventCancellable() - { - TestListener test = new TestListener("test"); - EventManager manager = new ReflectionEventManager(); - manager.registerEvents(test); - - manager.callEvent(new TestCancelableEvent()); - - assertTrue("Test is not true, event was not cancelled", test.getTest()); - } - - @Test - public void testOrder() - { - TestListener test = new TestListener(""); - EventManager manager = new ReflectionEventManager(); - manager.registerEvents(test); - - manager.callEvent(new TestOrderEvent()); - - assertTrue("Events were not listened in the correct order", test.getData().equals("012345")); - } - - @Test - public void testDoubleRegister() - { - TestListener test = new TestListener("test"); - EventManager manager = new ReflectionEventManager(); - manager.registerEvents(test); - - assertFalse("Event was double registered", manager.registerEvents(test)); - } - - @Test - public void testCalledEvent() - { - Event event = new TestEvent(); - EventManager manager = new ReflectionEventManager(); - - assertFalse("Event call ran when event did not exist", manager.callEvent(event)); - } - - @Test - public void testUnregister() - { - TestListener test = new TestListener("test"); - EventManager manager = new ReflectionEventManager(); - manager.registerEvents(test); - - assertTrue("Listener was not registered", manager.unregisterEvents(test)); - assertFalse("Listener was still registered", manager.unregisterEvents(test)); - } -} \ No newline at end of file From 5ab9224e36884fcf8176994ecd51b8a33a5a24ff Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 00:46:53 -0700 Subject: [PATCH 02/37] Update travis yml for different jdks --- .travis.yml | 68 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5051d49..bbf0a9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,63 @@ language: java -jdk: - - oraclejdk8 - - openjdk8 - - oraclejdk9 - - openjdk10 + before_install: - chmod +x gradlew -script: -- ./gradlew test -- ./gradlew jacocoTestReport +before_script: +- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh + +jobs: + include: + - stage: jdk.java.net - OpenJDK - GPL + env: JDK=8 + script: + - jdk_switcher use openjdk8 + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=9 + script: + - source install-jdk.sh -C -F 9 + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=10 + script: + - source install-jdk.sh -C -F 10 + - ./gradlew test + - ./gradlew jacocoTestReport + + - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 + env: JDK=10 + Hotspot + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=10 + OpenJ9 + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + + - stage: Graal & Zulu + env: JDK=graalvm-ce-1.0.0-rc6 + script: + - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=zulu10.3+5-jdk10.0.2 + script: + - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport + + after_success: -- bash <(curl -s https://codecov.io/bash) \ No newline at end of file +- bash <(curl -s https://codecov.io/bash) + +after_script: +- echo JAVA_HOME = ${JAVA_HOME} +- echo PATH = ${PATH} +- ls ${JAVA_HOME} +- java -version \ No newline at end of file From fc55e7145ee6092f9d38095226ab1a011ea37ca2 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 00:48:56 -0700 Subject: [PATCH 03/37] Revert "Update travis yml for different jdks" This reverts commit 5ab9224e36884fcf8176994ecd51b8a33a5a24ff. --- .travis.yml | 68 +++++++---------------------------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/.travis.yml b/.travis.yml index bbf0a9e..5051d49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,63 +1,13 @@ language: java - +jdk: + - oraclejdk8 + - openjdk8 + - oraclejdk9 + - openjdk10 before_install: - chmod +x gradlew -before_script: -- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh - -jobs: - include: - - stage: jdk.java.net - OpenJDK - GPL - env: JDK=8 - script: - - jdk_switcher use openjdk8 - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=9 - script: - - source install-jdk.sh -C -F 9 - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=10 - script: - - source install-jdk.sh -C -F 10 - - ./gradlew test - - ./gradlew jacocoTestReport - - - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 - env: JDK=10 + Hotspot - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=10 + OpenJ9 - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - - stage: Graal & Zulu - env: JDK=graalvm-ce-1.0.0-rc6 - script: - - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=zulu10.3+5-jdk10.0.2 - script: - - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport - - +script: +- ./gradlew test +- ./gradlew jacocoTestReport after_success: -- bash <(curl -s https://codecov.io/bash) - -after_script: -- echo JAVA_HOME = ${JAVA_HOME} -- echo PATH = ${PATH} -- ls ${JAVA_HOME} -- java -version \ No newline at end of file +- bash <(curl -s https://codecov.io/bash) \ No newline at end of file From af065e05d8fff3505ba93e4048b22d4a8ac658a2 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 00:54:41 -0700 Subject: [PATCH 04/37] Revert "Revert "Update travis yml for different jdks"" This reverts commit fc55e7145ee6092f9d38095226ab1a011ea37ca2. --- .travis.yml | 68 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5051d49..bbf0a9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,63 @@ language: java -jdk: - - oraclejdk8 - - openjdk8 - - oraclejdk9 - - openjdk10 + before_install: - chmod +x gradlew -script: -- ./gradlew test -- ./gradlew jacocoTestReport +before_script: +- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh + +jobs: + include: + - stage: jdk.java.net - OpenJDK - GPL + env: JDK=8 + script: + - jdk_switcher use openjdk8 + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=9 + script: + - source install-jdk.sh -C -F 9 + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=10 + script: + - source install-jdk.sh -C -F 10 + - ./gradlew test + - ./gradlew jacocoTestReport + + - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 + env: JDK=10 + Hotspot + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=10 + OpenJ9 + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + + - stage: Graal & Zulu + env: JDK=graalvm-ce-1.0.0-rc6 + script: + - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=zulu10.3+5-jdk10.0.2 + script: + - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport + + after_success: -- bash <(curl -s https://codecov.io/bash) \ No newline at end of file +- bash <(curl -s https://codecov.io/bash) + +after_script: +- echo JAVA_HOME = ${JAVA_HOME} +- echo PATH = ${PATH} +- ls ${JAVA_HOME} +- java -version \ No newline at end of file From ccc93096fbcf975ab870403a14a629085f269138 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 00:54:58 -0700 Subject: [PATCH 05/37] Run on travis "trusty" dist --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bbf0a9e..61d4467 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: java +dist: trusty before_install: - chmod +x gradlew From 79a1b23e36216816871deb7c1c487056ecd385f8 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:06:15 -0700 Subject: [PATCH 06/37] Only test on openjdk --- .travis.yml | 26 ------------------- .../impl/javaassist/JavaAssistEventBus.java | 6 ++--- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61d4467..9a05a85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,32 +26,6 @@ jobs: - source install-jdk.sh -C -F 10 - ./gradlew test - ./gradlew jacocoTestReport - - - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 - env: JDK=10 + Hotspot - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=10 + OpenJ9 - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - - stage: Graal & Zulu - env: JDK=graalvm-ce-1.0.0-rc6 - script: - - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=zulu10.3+5-jdk10.0.2 - script: - - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport after_success: diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index 48013e9..af6cee7 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -92,7 +92,7 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met { collision = new AtomicInteger(0); classNum = 0; - map.put(callbackClassName, collision); + JavaAssistEventBus.map.put(callbackClassName, collision); } else { @@ -101,8 +101,8 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met callbackClassName += classNum; - CtClass methodExecutorClass = pool.makeClass(callbackClassName); - methodExecutorClass.setSuperclass(pool.get("com.clubobsidian.trident.MethodExecutor")); + CtClass methodExecutorClass = this.pool.makeClass(callbackClassName); + methodExecutorClass.setSuperclass(this.pool.get("com.clubobsidian.trident.MethodExecutor")); String eventType = method.getParameterTypes()[0].getName(); String listenerType = listener.getClass().getName(); From 764148a8bf5372d30338bbe6b24cbedd709857d4 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:21:28 -0700 Subject: [PATCH 07/37] Re-add EventDoublyLinkedList test --- .../trident/EventDoublyLinkedListTest.java | 321 ++++++++++++++++++ src/test/java/trident/TestMethodExecutor.java | 21 ++ 2 files changed, 342 insertions(+) create mode 100644 src/test/java/trident/EventDoublyLinkedListTest.java create mode 100644 src/test/java/trident/TestMethodExecutor.java diff --git a/src/test/java/trident/EventDoublyLinkedListTest.java b/src/test/java/trident/EventDoublyLinkedListTest.java new file mode 100644 index 0000000..02f58b6 --- /dev/null +++ b/src/test/java/trident/EventDoublyLinkedListTest.java @@ -0,0 +1,321 @@ +/* + Copyright 2018 Club Obsidian and contributors. + + 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. +*/ +package trident; + +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Random; + +import org.junit.Test; + +import com.clubobsidian.trident.EventPriority; +import com.clubobsidian.trident.MethodExecutor; +import com.clubobsidian.trident.util.EventDoublyLinkedList; +import com.clubobsidian.trident.util.EventNode; + +public class EventDoublyLinkedListTest { + + @Test + public void testOrder() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + + TestListener test = new TestListener("test"); + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode low = list.insert(executor, EventPriority.LOW); + assertTrue("Low could not be inserted at head", low != null); + + assertTrue("Low is not head", list.getHead().getData().equals(executor)); + + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode lowest = list.insert(executor2, EventPriority.LOWEST); + assertTrue("Lowest could not be inserted", lowest != null); + + assertTrue("Lowest is not head", list.getHead().getData().equals(executor2)); + + + TestListener test3 = new TestListener("test3"); + MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode nextLowest = list.insert(executor3, EventPriority.LOWEST); + assertTrue("NextLowest could not be inserted", nextLowest != null); + + assertTrue("NextLowest is not next to head", list.getHead().getNext().getData().equals(executor3)); + + + TestListener test4 = new TestListener("test4"); + MethodExecutor executor4 = new TestMethodExecutor(test4, test4.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode monitor = list.insert(executor4, EventPriority.MONITOR); + assertTrue("Monitor could not be inserted", monitor != null); + + assertTrue("Monitor is not tail", list.find(executor4).getData().equals(executor4)); + + + TestListener test5 = new TestListener("test5"); + MethodExecutor executor5 = new TestMethodExecutor(test5, test5.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode high = list.insert(executor5, EventPriority.HIGH); + assertTrue("High could not be inserted", high != null); + + assertTrue("High next node is not priority monitor", list.find(executor5).getNext().getData().equals(executor4)); + + TestListener test6 = new TestListener("test6"); + MethodExecutor executor6 = new TestMethodExecutor(test6, test6.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode normal = list.insert(executor6, EventPriority.NORMAL); + assertTrue("Normal could not be inserted", normal != null); + + assertTrue("Normal next node is not priority high", list.find(executor6).getNext().getData().equals(executor5)); + + + TestListener test7 = new TestListener("test7"); + MethodExecutor executor7 = new TestMethodExecutor(test7, test7.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode highest = list.insert(executor7, EventPriority.HIGHEST); + assertTrue("Highest could not be inserted", highest != null); + + assertTrue("Highest next node is not priority monitor", list.find(executor7).getNext().getData().equals(executor4)); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void testRemoval() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test = new TestListener("test1"); + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + list.insert(executor, EventPriority.MONITOR); + + assertTrue("Monitor is not head", list.getHead().getData().equals(executor)); + list.remove(executor); + assertTrue("Head is not null after monitor removal", list.getHead() == null); + + for(int i = EventPriority.values()[0].getValue(); i < (EventPriority.values()[EventPriority.values().length - 1]).getValue() + 1; i++) + { + list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class) , false), EventPriority.getByValue(i)); + } + + EventNode node = list.getHead(); + int removalCount = 0; + while(node != null) + { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all node", list.getHead() == null); + assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); + + for(int i = (EventPriority.values()[EventPriority.values().length - 1]).getValue(); i > -1 ; i--) + { + list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(i)); + } + + node = list.getHead(); + removalCount = 0; + while(node != null) + { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all nodes reverse", list.getHead() == null); + assertTrue("Removed nodes are not equal to EventPriority length", EventPriority.values().length == removalCount); + + Random rand = new Random(); + + int iterate = 10000; + for(int i = 0; i < iterate; i++) + { + + rand.setSeed(System.nanoTime()); + int next = rand.nextInt(6); + EventNode inserted = list.insert(new TestMethodExecutor(new TestListener("test" + i), test.getClass().getDeclaredMethod("test", TestEvent.class), false), EventPriority.getByValue(next)); + + assertTrue("Insert failed for random insert for removal", inserted != null); + } + + node = list.getHead(); + removalCount = 0; + while(node != null) + { + list.remove(node.getData()); + removalCount += 1; + node = node.getNext(); + } + + assertTrue("Head is not null after traversing after removing all nodes after random insert", list.getHead() == null); + assertTrue("Removed nodes are not equal to iterating length after random insert", iterate == removalCount); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void emptyLinkedListTest() + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test = new TestListener("test1"); + try + { + MethodExecutor executor = new TestMethodExecutor(test, test.getClass().getDeclaredMethod("test", TestEvent.class), false); + assertTrue("Executor was removed", list.remove(executor) == null); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void nextIsNullAndNotHeadRemove() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor2, EventPriority.LOW); + + EventNode removed = list.remove(executor2); + + assertTrue("EventNode data was not equal", removed.getData().equals(executor2)); + + assertTrue("EventNode previous node's next node was not null", removed.getPrev().getNext() == null); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void foundIsMiddleNodeRemoveTest() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor2, EventPriority.LOW); + + TestListener test3 = new TestListener("test3"); + MethodExecutor executor3 = new TestMethodExecutor(test3, test3.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor3, EventPriority.NORMAL); + + EventNode removed = list.remove(executor2); + + assertTrue("Previous node's next node was not set to removed next node", removed.getPrev().getNext().equals(removed.getNext())); + + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void findMethodExecutorThatDoesNotExistTest() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + assertTrue("Executor was found while not inserted", list.find(executor1) == null); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test //This should never happen under normal circumstances but is being used for code coverage + public void findInsertNull() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + + Method findInsertion = list.getClass().getDeclaredMethod("findInsertionNode", int.class); + findInsertion.setAccessible(true); + assertTrue("Null node was not found", findInsertion.invoke(list, 6) == null); + } + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) + { + e.printStackTrace(); + } + } + + @Test + public void findIfFoundNodePriorityIsTheSameTest() + { + try + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + TestListener test1 = new TestListener("test1"); + MethodExecutor executor1 = new TestMethodExecutor(test1, test1.getClass().getDeclaredMethod("test", TestEvent.class), false); + + list.insert(executor1, EventPriority.LOWEST); + + TestListener test2 = new TestListener("test2"); + MethodExecutor executor2 = new TestMethodExecutor(test2, test2.getClass().getDeclaredMethod("test", TestEvent.class), false); + + + EventPriority priority = EventPriority.LOWEST; + EventNode inserted = list.insert(executor2, priority); + + assertTrue("Previous node's priority is not the same", inserted.getPriority() == priority.getValue()); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + @Test + public void nullCaseTest() + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + EventNode inserted = list.insert(null, null); + assertTrue("Inserted was not null", inserted == null); + } +} \ No newline at end of file diff --git a/src/test/java/trident/TestMethodExecutor.java b/src/test/java/trident/TestMethodExecutor.java new file mode 100644 index 0000000..7ac75ef --- /dev/null +++ b/src/test/java/trident/TestMethodExecutor.java @@ -0,0 +1,21 @@ +package trident; + +import java.lang.reflect.Method; + +import com.clubobsidian.trident.Event; +import com.clubobsidian.trident.Listener; +import com.clubobsidian.trident.MethodExecutor; + +public class TestMethodExecutor extends MethodExecutor { + + public TestMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + { + super(listener, method, ignoreCanceled); + } + + @Override + public void execute(Event event) + { + + } +} \ No newline at end of file From e56f421bb2f841fd910302338d8b4c7efc9952ee Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:25:14 -0700 Subject: [PATCH 08/37] Repackage tests to "com.clubobsidian.trident.test" --- .../clubobsidian/trident/test}/EventBusTest.java | 6 +++++- .../trident/test}/EventDoublyLinkedListTest.java | 5 ++++- .../clubobsidian/trident/test}/IgnoreCanceledTest.java | 4 +++- .../clubobsidian/trident/test}/JavaAssistEventBusTest.java | 2 +- .../clubobsidian/trident/test}/ReflectionEventBusTest.java | 2 +- .../clubobsidian/trident/test}/ReflectionMiscEventTest.java | 4 +++- .../clubobsidian/trident/test}/UtilTest.java | 4 ++-- .../trident/test/impl}/TestCancelableEvent.java | 2 +- .../clubobsidian/trident/test/impl}/TestEvent.java | 2 +- .../clubobsidian/trident/test/impl}/TestEventSuper.java | 2 +- .../clubobsidian/trident/test/impl}/TestListener.java | 2 +- .../clubobsidian/trident/test/impl}/TestListenerIgnore.java | 2 +- .../clubobsidian/trident/test/impl}/TestMethodExecutor.java | 2 +- .../clubobsidian/trident/test/impl}/TestOrderEvent.java | 2 +- 14 files changed, 26 insertions(+), 15 deletions(-) rename src/test/java/{trident => com/clubobsidian/trident/test}/EventBusTest.java (89%) rename src/test/java/{trident => com/clubobsidian/trident/test}/EventDoublyLinkedListTest.java (98%) rename src/test/java/{trident => com/clubobsidian/trident/test}/IgnoreCanceledTest.java (87%) rename src/test/java/{trident => com/clubobsidian/trident/test}/JavaAssistEventBusTest.java (95%) rename src/test/java/{trident => com/clubobsidian/trident/test}/ReflectionEventBusTest.java (95%) rename src/test/java/{trident => com/clubobsidian/trident/test}/ReflectionMiscEventTest.java (91%) rename src/test/java/{trident => com/clubobsidian/trident/test}/UtilTest.java (92%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestCancelableEvent.java (95%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestEvent.java (94%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestEventSuper.java (94%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestListener.java (97%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestListenerIgnore.java (96%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestMethodExecutor.java (90%) rename src/test/java/{trident => com/clubobsidian/trident/test/impl}/TestOrderEvent.java (94%) diff --git a/src/test/java/trident/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java similarity index 89% rename from src/test/java/trident/EventBusTest.java rename to src/test/java/com/clubobsidian/trident/test/EventBusTest.java index 78adb3f..a1c8bb0 100644 --- a/src/test/java/trident/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -1,4 +1,4 @@ -package trident; +package com.clubobsidian.trident.test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -7,6 +7,10 @@ import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.test.impl.TestCancelableEvent; +import com.clubobsidian.trident.test.impl.TestEvent; +import com.clubobsidian.trident.test.impl.TestListener; +import com.clubobsidian.trident.test.impl.TestOrderEvent; public abstract class EventBusTest { diff --git a/src/test/java/trident/EventDoublyLinkedListTest.java b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java similarity index 98% rename from src/test/java/trident/EventDoublyLinkedListTest.java rename to src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java index 02f58b6..fd78582 100644 --- a/src/test/java/trident/EventDoublyLinkedListTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import static org.junit.Assert.assertTrue; @@ -25,6 +25,9 @@ import com.clubobsidian.trident.EventPriority; import com.clubobsidian.trident.MethodExecutor; +import com.clubobsidian.trident.test.impl.TestEvent; +import com.clubobsidian.trident.test.impl.TestListener; +import com.clubobsidian.trident.test.impl.TestMethodExecutor; import com.clubobsidian.trident.util.EventDoublyLinkedList; import com.clubobsidian.trident.util.EventNode; diff --git a/src/test/java/trident/IgnoreCanceledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java similarity index 87% rename from src/test/java/trident/IgnoreCanceledTest.java rename to src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java index a344384..ee70c8f 100644 --- a/src/test/java/trident/IgnoreCanceledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import static org.junit.Assert.assertTrue; @@ -22,6 +22,8 @@ import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; +import com.clubobsidian.trident.test.impl.TestCancelableEvent; +import com.clubobsidian.trident.test.impl.TestListenerIgnore; public class IgnoreCanceledTest { diff --git a/src/test/java/trident/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java similarity index 95% rename from src/test/java/trident/JavaAssistEventBusTest.java rename to src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index cdfa96a..d41ff91 100644 --- a/src/test/java/trident/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; diff --git a/src/test/java/trident/ReflectionEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java similarity index 95% rename from src/test/java/trident/ReflectionEventBusTest.java rename to src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java index 7c61d99..c3eac14 100644 --- a/src/test/java/trident/ReflectionEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.impl.reflection.ReflectionEventBus; diff --git a/src/test/java/trident/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java similarity index 91% rename from src/test/java/trident/ReflectionMiscEventTest.java rename to src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index 96b71dd..ef76743 100644 --- a/src/test/java/trident/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import static org.junit.Assert.assertTrue; @@ -25,6 +25,8 @@ import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.impl.reflection.ReflectionMethodExecutor; +import com.clubobsidian.trident.test.impl.TestEvent; +import com.clubobsidian.trident.test.impl.TestListener; public class ReflectionMiscEventTest { diff --git a/src/test/java/trident/UtilTest.java b/src/test/java/com/clubobsidian/trident/test/UtilTest.java similarity index 92% rename from src/test/java/trident/UtilTest.java rename to src/test/java/com/clubobsidian/trident/test/UtilTest.java index 9adf8d7..fad6d1f 100644 --- a/src/test/java/trident/UtilTest.java +++ b/src/test/java/com/clubobsidian/trident/test/UtilTest.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; @@ -21,7 +21,7 @@ import org.junit.Test; import com.clubobsidian.trident.Event; - +import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.util.ClassUtil; public class UtilTest { diff --git a/src/test/java/trident/TestCancelableEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java similarity index 95% rename from src/test/java/trident/TestCancelableEvent.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java index 0e4775b..90cf0b1 100644 --- a/src/test/java/trident/TestCancelableEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Cancelable; diff --git a/src/test/java/trident/TestEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java similarity index 94% rename from src/test/java/trident/TestEvent.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java index a6badc3..0d09d2d 100644 --- a/src/test/java/trident/TestEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; /** * diff --git a/src/test/java/trident/TestEventSuper.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java similarity index 94% rename from src/test/java/trident/TestEventSuper.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java index 80af965..e5ff0a5 100644 --- a/src/test/java/trident/TestEventSuper.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Event; diff --git a/src/test/java/trident/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java similarity index 97% rename from src/test/java/trident/TestListener.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index 4c8f156..aa08f68 100644 --- a/src/test/java/trident/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventHandler; import com.clubobsidian.trident.EventPriority; diff --git a/src/test/java/trident/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java similarity index 96% rename from src/test/java/trident/TestListenerIgnore.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index 5dda96b..13a2970 100644 --- a/src/test/java/trident/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.EventHandler; import com.clubobsidian.trident.EventPriority; diff --git a/src/test/java/trident/TestMethodExecutor.java b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java similarity index 90% rename from src/test/java/trident/TestMethodExecutor.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java index 7ac75ef..bb3d6a7 100644 --- a/src/test/java/trident/TestMethodExecutor.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java @@ -1,4 +1,4 @@ -package trident; +package com.clubobsidian.trident.test.impl; import java.lang.reflect.Method; diff --git a/src/test/java/trident/TestOrderEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java similarity index 94% rename from src/test/java/trident/TestOrderEvent.java rename to src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java index 6f969f1..9140847 100644 --- a/src/test/java/trident/TestOrderEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package trident; +package com.clubobsidian.trident.test.impl; import com.clubobsidian.trident.Event; From f154ae501457dc1e9236053a244f42e9f669b934 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:32:21 -0700 Subject: [PATCH 09/37] Test event priority getByValue --- .../trident/test/EventPriorityTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java diff --git a/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java new file mode 100644 index 0000000..04bf09b --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/EventPriorityTest.java @@ -0,0 +1,24 @@ +package com.clubobsidian.trident.test; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.clubobsidian.trident.EventPriority; + +public class EventPriorityTest { + + @Test + public void testOutOfLowerBounds() + { + EventPriority priority = EventPriority.getByValue(-1); + assertTrue("Priority was not null when going below bounds", priority == null); + } + + @Test + public void testOutOfUpperBounds() + { + EventPriority priority = EventPriority.getByValue(EventPriority.values().length); + assertTrue("Priority was not null when going above bounds", priority == null); + } +} \ No newline at end of file From 68b7938dc8ee788c092411b8a83fa49e4d7c776d Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:32:28 -0700 Subject: [PATCH 10/37] Test event name --- .../clubobsidian/trident/test/EventTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/java/com/clubobsidian/trident/test/EventTest.java diff --git a/src/test/java/com/clubobsidian/trident/test/EventTest.java b/src/test/java/com/clubobsidian/trident/test/EventTest.java new file mode 100644 index 0000000..81873a1 --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/EventTest.java @@ -0,0 +1,18 @@ +package com.clubobsidian.trident.test; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.clubobsidian.trident.Event; +import com.clubobsidian.trident.test.impl.TestEvent; + +public class EventTest { + + @Test + public void testName() + { + Event event = new TestEvent(); + assertTrue("Event name is not \"TestEvent\"", event.getName().equals("TestEvent")); + } +} \ No newline at end of file From 19a6bea864ba55d053c13c9031c09ea81f2e3617 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:38:16 -0700 Subject: [PATCH 11/37] Add back multithreading test --- .../trident/test/MultiThreadingTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java diff --git a/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java new file mode 100644 index 0000000..04023bb --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/MultiThreadingTest.java @@ -0,0 +1,64 @@ +package com.clubobsidian.trident.test; + +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.Test; + +import com.clubobsidian.trident.EventPriority; +import com.clubobsidian.trident.MethodExecutor; +import com.clubobsidian.trident.test.impl.TestEvent; +import com.clubobsidian.trident.test.impl.TestListener; +import com.clubobsidian.trident.test.impl.TestMethodExecutor; +import com.clubobsidian.trident.util.EventDoublyLinkedList; +import com.clubobsidian.trident.util.EventNode; + +public class MultiThreadingTest { + + @Test + public void multiThreadingTestEventDoublyLinkedList() + { + AtomicInteger count = new AtomicInteger(0); + final EventDoublyLinkedList list = new EventDoublyLinkedList(); + Runnable testRunnable = new Runnable() + { + @Override + public void run() + { + for(int i = 0; i < 1000; i++) + { + try + { + int inc = count.incrementAndGet(); + TestListener testListener = new TestListener("test" + inc); + MethodExecutor testExecutor = new TestMethodExecutor(testListener, testListener.getClass().getDeclaredMethod("test", TestEvent.class), false); + EventNode node = list.insert(testExecutor, EventPriority.LOWEST); + assertTrue("Node was null when inserted", node != null); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + Thread.currentThread().interrupt(); + } + }; + Thread th1 = new Thread(testRunnable); + Thread th2 = new Thread(testRunnable); + + th1.start(); + th2.start(); + + while(th1.isAlive() || th2.isAlive()); + + int nodeCount = 0; + EventNode node = list.getHead(); + while(node != null) + { + nodeCount+= 1; + node = node.getNext(); + } + assertTrue("Node count not equal when running from multiple thread", nodeCount == count.get()); + } +} \ No newline at end of file From a9c6c6c0f1986b79b7bcdc1552a9386355987478 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:54:03 -0700 Subject: [PATCH 12/37] Test ReflectionMethodExecutor wrong argument when invoking --- .../trident/test/ReflectionMiscEventTest.java | 20 +++++++++ .../test/impl/TestWrongArgumentEvent.java | 5 +++ .../test/impl/TestWrongArgumentListener.java | 44 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java create mode 100644 src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index ef76743..beb5493 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -25,8 +25,10 @@ import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.impl.reflection.ReflectionMethodExecutor; +import com.clubobsidian.trident.test.impl.TestWrongArgumentListener; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; +import com.clubobsidian.trident.test.impl.TestWrongArgumentEvent; public class ReflectionMiscEventTest { @@ -47,4 +49,22 @@ public void methodExecutorTest() e.printStackTrace(); } } + + @Test + public void methodExecutorPrivateTest() + { + try + { + TestWrongArgumentListener listener = new TestWrongArgumentListener("test"); + Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); + MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); + executor.execute(new TestWrongArgumentEvent()); + + assertTrue("Executor was able to execute method on a listener with a different event class", listener.getTest() == false); + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java new file mode 100644 index 0000000..fa15ccf --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentEvent.java @@ -0,0 +1,5 @@ +package com.clubobsidian.trident.test.impl; + +public class TestWrongArgumentEvent extends TestEventSuper { + +} diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java new file mode 100644 index 0000000..b11a44a --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java @@ -0,0 +1,44 @@ +/* + Copyright 2018 Club Obsidian and contributors. + + 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. +*/ +package com.clubobsidian.trident.test.impl; + +import com.clubobsidian.trident.Listener; + +public class TestWrongArgumentListener implements Listener { + + private String data; + private boolean test; + public TestWrongArgumentListener(String data) + { + this.data = data; + this.test = false; + } + + public String getData() + { + return this.data; + } + + public boolean getTest() + { + return this.test; + } + + public void test(TestEvent event) + { + this.test = !test; + } +} \ No newline at end of file From 6983b0e7f8a443a9607b8fee1ceb467486d6e819 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 01:54:15 -0700 Subject: [PATCH 13/37] Test if JavaAssistEventBus class pool exists --- .../trident/test/JavaAssistEventBusTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index d41ff91..880a7cc 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -15,11 +15,22 @@ */ package com.clubobsidian.trident.test; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; public class JavaAssistEventBusTest extends EventBusTest { + @Test + public void testClassPoolExists() + { + JavaAssistEventBus eventBus = new JavaAssistEventBus(); + assertTrue("No class pool for JavaAssist event bus", eventBus.getClassPool() != null); + } + @Override protected EventBus createNewEventBus() { From 5afa317149c06bab7ba9189387317ae45d6a1a7f Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 02:21:05 -0700 Subject: [PATCH 14/37] Test doubly linked list event priority null --- .../trident/test/EventDoublyLinkedListTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java index fd78582..923cf8e 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java @@ -315,10 +315,18 @@ public void findIfFoundNodePriorityIsTheSameTest() } @Test - public void nullCaseTest() + public void methodExecutorNullTest() { EventDoublyLinkedList list = new EventDoublyLinkedList(); EventNode inserted = list.insert(null, null); - assertTrue("Inserted was not null", inserted == null); + assertTrue("Inserted event node was not null for a null method executor", inserted == null); + } + + @Test + public void eventPriorityNullTest() + { + EventDoublyLinkedList list = new EventDoublyLinkedList(); + EventNode inserted = list.insert(new TestMethodExecutor(null, null, false), null); + assertTrue("Inserted event node was not null for a null event priority", inserted == null); } } \ No newline at end of file From 084866022ea3d14d386e5f17e6fdf356a6f2d6e7 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 02:21:18 -0700 Subject: [PATCH 15/37] Test EventBus for a null listener --- .../com/clubobsidian/trident/EventBus.java | 10 +++++++++- .../trident/test/EventBusTest.java | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 7f6af9e..bb6e3c1 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -83,7 +83,11 @@ public boolean callEvent(final Event event) */ public boolean registerEvents(final Listener listener) { - if(this.registeredEventListeners.keySet().contains(listener)) + if(listener == null) + { + return false; + } + else if(this.registeredEventListeners.keySet().contains(listener)) { return false; } @@ -109,6 +113,10 @@ public boolean registerEvents(final Listener listener) boolean ignoreCanceled = handler.ignoreCanceled(); MethodExecutor executor = this.createMethodExecutor(listener, method, ignoreCanceled); + + if(executor == null) + return false; + this.registeredExecutors.get(eventClass).insert(executor, handler.priority()); this.registeredEventListeners.get(listener).add(executor); } diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index a1c8bb0..e41cccd 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -87,6 +87,24 @@ public void testUnregister() assertFalse("Listener was still registered", manager.unregisterEvents(test)); } + @Test + public void testEmptyCallEvent() + { + EventBus manager = this.createNewEventBus(); + boolean called = manager.callEvent(new TestEvent()); + + assertFalse("Event was called when a listener is not registered", called); + } + + @Test + public void testNullRegister() + { + EventBus manager = this.createNewEventBus(); + boolean registered = manager.registerEvents(null); + + assertFalse("Listener was still registered event though the listener was null", registered); + } + protected abstract EventBus createNewEventBus(); } \ No newline at end of file From 491504dc62e7d09146e2769b8ad8960e12082dd0 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 02:44:24 -0700 Subject: [PATCH 16/37] Unit test null Method on javaassist method executor creation --- .../impl/javaassist/JavaAssistEventBus.java | 12 ++++++----- .../trident/test/EventBusTest.java | 12 +++++++++++ .../trident/test/JavaAssistEventBusTest.java | 21 +++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index af6cee7..bfcb4f4 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -78,11 +78,13 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met this.addClassToPool(Event.class); this.addClassToPool(Listener.class); - if(this.pool.getOrNull(listenerClass.getName()) == null) - { - this.pool.insertClassPath(new LoaderClassPath(classLoader)); - this.addClassToPool(listenerClass); - } + LoaderClassPath loaderClassPath = new LoaderClassPath(classLoader); + + //If class path exists, remove it first and then add + this.pool.removeClassPath(loaderClassPath); + this.pool.insertClassPath(loaderClassPath); + + this.addClassToPool(listenerClass); String callbackClassName = listener.getClass().getName() + method.getName(); diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index e41cccd..0baa003 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -7,6 +7,7 @@ import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.test.impl.TestCancelableEvent; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; @@ -105,6 +106,17 @@ public void testNullRegister() assertFalse("Listener was still registered event though the listener was null", registered); } + @Test + public void testPrivateListener() + { + EventBus manager = this.createNewEventBus(); + boolean registered = manager.registerEvents(new PrivateListener()); + + assertTrue("Listener was still registered event though the listener was private", registered); + } + protected abstract EventBus createNewEventBus(); + + private class PrivateListener implements Listener {} } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index 880a7cc..c2bdcd5 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -17,9 +17,13 @@ import static org.junit.Assert.assertTrue; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import org.junit.Test; import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; public class JavaAssistEventBusTest extends EventBusTest { @@ -31,6 +35,23 @@ public void testClassPoolExists() assertTrue("No class pool for JavaAssist event bus", eventBus.getClassPool() != null); } + @Test + public void testNullMethodOnMethodExecutor() + { + JavaAssistEventBus eventBus = new JavaAssistEventBus(); + try + { + Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Listener.class, Method.class, boolean.class); + generate.setAccessible(true); + Object methodExecutor = generate.invoke(eventBus, null, null, false); + assertTrue("Method executor is not null even though a null listener was passed", methodExecutor == null); + } + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) + { + e.printStackTrace(); + } + } + @Override protected EventBus createNewEventBus() { From cac2695602fe587c2d39eeeea58a698da6d36b73 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 03:43:11 -0700 Subject: [PATCH 17/37] Test event bus for null method executor --- .../trident/test/OtherEventBusTest.java | 20 +++++++++++++++++++ .../trident/test/impl/TestEventBus.java | 16 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java create mode 100644 src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java diff --git a/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java new file mode 100644 index 0000000..5d61a83 --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/OtherEventBusTest.java @@ -0,0 +1,20 @@ +package com.clubobsidian.trident.test; + +import static org.junit.Assert.assertFalse; + +import org.junit.Test; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.test.impl.TestEventBus; +import com.clubobsidian.trident.test.impl.TestListener; + +public class OtherEventBusTest { + + @Test + public void testNullExecutor() + { + EventBus bus = new TestEventBus(); + boolean registered = bus.registerEvents(new TestListener("data")); + assertFalse("Listener was registered even though MethodExecutor is null", registered); + } +} \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java new file mode 100644 index 0000000..ec33315 --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java @@ -0,0 +1,16 @@ +package com.clubobsidian.trident.test.impl; + +import java.lang.reflect.Method; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.Listener; +import com.clubobsidian.trident.MethodExecutor; + +public class TestEventBus extends EventBus { + + @Override + protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + { + return null; + } +} \ No newline at end of file From 1f9df46d940897f5a590fbe9f5192b53b004855c Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 03:43:41 -0700 Subject: [PATCH 18/37] Check if method executor class is frozen before creating --- .../impl/javaassist/JavaAssistEventBus.java | 23 ++++++---- .../trident/test/JavaAssistEventBusTest.java | 42 ++++++++++++++++++- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index bfcb4f4..5b967c1 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -103,7 +103,19 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met callbackClassName += classNum; + CtClass checkMethodExecutorClass = this.pool.getOrNull(callbackClassName); + if(checkMethodExecutorClass != null) + { + if(checkMethodExecutorClass.isFrozen()) + { + System.out.println("Method executor class is frozen"); + return null; + } + } + CtClass methodExecutorClass = this.pool.makeClass(callbackClassName); + + methodExecutorClass.setSuperclass(this.pool.get("com.clubobsidian.trident.MethodExecutor")); String eventType = method.getParameterTypes()[0].getName(); @@ -129,13 +141,10 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met return null; } - private boolean addClassToPool(Class clazz) + private void addClassToPool(Class clazz) { - if(this.pool.getOrNull(clazz.getName()) == null) - { - this.pool.insertClassPath(new ClassClassPath(clazz)); - return true; - } - return false; + ClassClassPath classClassPath = new ClassClassPath(clazz); + this.pool.removeClassPath(classClassPath); + this.pool.insertClassPath(classClassPath); } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index c2bdcd5..ecb9593 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -15,19 +15,32 @@ */ package com.clubobsidian.trident.test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; +import org.junit.FixMethodOrder; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runners.MethodSorters; import com.clubobsidian.trident.EventBus; import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; +import com.clubobsidian.trident.test.impl.TestListener; -public class JavaAssistEventBusTest extends EventBusTest { +import javassist.CannotCompileException; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class JavaAssistEventBusTest extends EventBusTest { + @Test public void testClassPoolExists() { @@ -52,6 +65,33 @@ public void testNullMethodOnMethodExecutor() } } + @Test + public void testFrozenMethodExecutor() + { + try + { + JavaAssistEventBus eventBus = new JavaAssistEventBus(); + eventBus.registerEvents(new TestListener("data")); + Field mapField = JavaAssistEventBus.class.getDeclaredField("map"); + mapField.setAccessible(true); + ConcurrentMap savedMap = (ConcurrentMap) mapField.get(null); + + mapField.set(null, new ConcurrentHashMap()); + boolean registered = false; + + registered = eventBus.registerEvents(new TestListener("data")); + + mapField.set(null, savedMap); + System.out.println("Set map back to prior state"); + + assertFalse("Was able to register event with invalid map", registered); + } + catch (IllegalArgumentException | SecurityException | IllegalAccessException | NoSuchFieldException e) + { + e.printStackTrace(); + } + } + @Override protected EventBus createNewEventBus() { From 2f80c60522c01d4ac6d90a7439bf2b68b76b8faa Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 03:46:13 -0700 Subject: [PATCH 19/37] Remove println if a class is frozen --- .../clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index 5b967c1..eb67f22 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -108,7 +108,6 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met { if(checkMethodExecutorClass.isFrozen()) { - System.out.println("Method executor class is frozen"); return null; } } From 64ca625138926700e5f5570e1aaceb3d55562c23 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 18 Jun 2019 04:35:43 -0700 Subject: [PATCH 20/37] Cleanup JavaAssistEventBusTest class --- .../clubobsidian/trident/test/JavaAssistEventBusTest.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index ecb9593..9121b7d 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -26,9 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.FixMethodOrder; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runners.MethodSorters; import com.clubobsidian.trident.EventBus; @@ -36,8 +34,6 @@ import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; import com.clubobsidian.trident.test.impl.TestListener; -import javassist.CannotCompileException; - @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class JavaAssistEventBusTest extends EventBusTest { @@ -77,9 +73,7 @@ public void testFrozenMethodExecutor() ConcurrentMap savedMap = (ConcurrentMap) mapField.get(null); mapField.set(null, new ConcurrentHashMap()); - boolean registered = false; - - registered = eventBus.registerEvents(new TestListener("data")); + boolean registered = eventBus.registerEvents(new TestListener("data")); mapField.set(null, savedMap); System.out.println("Set map back to prior state"); From 6c5bb9dbdbb3fdd6928359aad81a812f4ade24d5 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:16:58 -0700 Subject: [PATCH 21/37] Update gradle and dependencies to the newest versions Updated gradle, shadow and jacoco. --- build.gradle | 38 ++++++++++++------------ gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index c0b7df7..eb2af46 100644 --- a/build.gradle +++ b/build.gradle @@ -1,33 +1,32 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - } +plugins { + id 'java' + id 'com.github.johnrengelman.shadow' version '5.0.0' + id 'jacoco' + id 'eclipse' + id 'idea' } -apply plugin: 'java' -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'jacoco' -apply plugin: 'eclipse' -apply plugin: 'idea' - - sourceCompatibility = 1.8 targetCompatibility = 1.8 +group = 'com.clubobsidian' +version = '2.0.0' + repositories { mavenCentral() jcenter() } +configurations { + shade + compile.extendsFrom shade +} + shadowJar { baseName = 'trident' classifier = null - version = null relocate 'javassist', 'com.clubobsidian.trident.javassist' } @@ -38,10 +37,11 @@ dependencies { } jacocoTestReport { - reports { - xml.enabled true - html.enabled false - } + reports { + xml.enabled true + html.enabled false + html.destination file("${buildDir}/jacocoHtml") + } } task javadocJar(type: Jar, dependsOn: javadoc) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 16d2805..f4d7b2b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 84f99521e34b9c467a0610fc1308ba96b974b53d Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:24:19 -0700 Subject: [PATCH 22/37] Try building alternative jvms again Update travis yml to try building on more jvms again, should work now due to updating jacoco. --- .travis.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9a05a85..61d4467 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,32 @@ jobs: - source install-jdk.sh -C -F 10 - ./gradlew test - ./gradlew jacocoTestReport + + - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 + env: JDK=10 + Hotspot + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=10 + OpenJ9 + script: + - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) + - ./gradlew test + - ./gradlew jacocoTestReport + + - stage: Graal & Zulu + env: JDK=graalvm-ce-1.0.0-rc6 + script: + - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport + - # stage: ... + env: JDK=zulu10.3+5-jdk10.0.2 + script: + - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz + - ./gradlew test + - ./gradlew jacocoTestReport after_success: From 3589fdcc231d5842e0f847d69aae95080d6ac045 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:30:31 -0700 Subject: [PATCH 23/37] Revert "Try building alternative jvms again" This reverts commit 84f99521e34b9c467a0610fc1308ba96b974b53d. --- .travis.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61d4467..9a05a85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,32 +26,6 @@ jobs: - source install-jdk.sh -C -F 10 - ./gradlew test - ./gradlew jacocoTestReport - - - stage: adoptopenjdk.net - HotSpot - Eclipse OpenJ9 - env: JDK=10 + Hotspot - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=10 + OpenJ9 - script: - - source install-jdk.sh -C --url $(curl --silent https://api.adoptopenjdk.net/openjdk10-openj9/nightly/x64_linux/ | grep 'binary_link' | grep -Eo '(http|https)://[^"]+' | head -1) - - ./gradlew test - - ./gradlew jacocoTestReport - - - stage: Graal & Zulu - env: JDK=graalvm-ce-1.0.0-rc6 - script: - - source install-jdk.sh --url https://github.com/oracle/graal/releases/download/vm-1.0.0-rc6/graalvm-ce-1.0.0-rc6-linux-amd64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport - - # stage: ... - env: JDK=zulu10.3+5-jdk10.0.2 - script: - - source install-jdk.sh --url https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz - - ./gradlew test - - ./gradlew jacocoTestReport after_success: From 5e954fa7b9b801b2eb267b62ba63a361a1313d71 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:40:12 -0700 Subject: [PATCH 24/37] Added snyk badge to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1d8e006..cb0bf26 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status](https://api.travis-ci.org/ClubObsidian/trident.svg?branch=master)](https://travis-ci.org/ClubObsidian/trident) [![build artifacts](https://jitpack.io/v/clubobsidian/trident.svg)](https://jitpack.io/#clubobsidian/trident) [![codecov](https://codecov.io/gh/ClubObsidian/trident/branch/master/graph/badge.svg)](https://codecov.io/gh/ClubObsidian/trident) +[![Known Vulnerabilities](https://snyk.io//test/github/ClubObsidian/trident/badge.svg?targetFile=build.gradle)](https://snyk.io//test/github/ClubObsidian/trident?targetFile=build.gradle) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![discord](https://discordapp.com/api/guilds/482823104905609248/widget.png)](https://discord.gg/EY5Tq6r) [Javadocs](https://jitpack.io/com/github/clubobsidian/trident/1.0.8/javadoc/) From 73c2e74fe6d5db9e4b96925da4b36727239aa388 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:55:07 -0700 Subject: [PATCH 25/37] Get readme ready for 2.0.0 release --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cb0bf26..aab6244 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Known Vulnerabilities](https://snyk.io//test/github/ClubObsidian/trident/badge.svg?targetFile=build.gradle)](https://snyk.io//test/github/ClubObsidian/trident?targetFile=build.gradle) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![discord](https://discordapp.com/api/guilds/482823104905609248/widget.png)](https://discord.gg/EY5Tq6r) -[Javadocs](https://jitpack.io/com/github/clubobsidian/trident/1.0.8/javadoc/) +[![javadocs](https://img.shields.io/badge/Javadocs-2.0.0-success.svg)]](https://jitpack.io/com/github/clubobsidian/trident/2.0.0/javadoc/) A dead simpile annotation event system that allows different event executor implementations. @@ -25,7 +25,7 @@ repositories { maven { url 'https://jitpack.io' } } -compile 'com.github.clubobsidian:trident:1.1.0' +compile 'com.github.clubobsidian:trident:2.0.0' ``` ### Maven @@ -41,7 +41,7 @@ compile 'com.github.clubobsidian:trident:1.1.0' com.github.clubobsidian trident - 1.1.0 + 2.0.0 ``` From 20c76571b5fbadb1063b1dcde4c180426ecc4698 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 03:56:19 -0700 Subject: [PATCH 26/37] Fix bracket for javadoc badge in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aab6244..d7108f7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Known Vulnerabilities](https://snyk.io//test/github/ClubObsidian/trident/badge.svg?targetFile=build.gradle)](https://snyk.io//test/github/ClubObsidian/trident?targetFile=build.gradle) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![discord](https://discordapp.com/api/guilds/482823104905609248/widget.png)](https://discord.gg/EY5Tq6r) -[![javadocs](https://img.shields.io/badge/Javadocs-2.0.0-success.svg)]](https://jitpack.io/com/github/clubobsidian/trident/2.0.0/javadoc/) +[![javadocs](https://img.shields.io/badge/Javadocs-2.0.0-success.svg)](https://jitpack.io/com/github/clubobsidian/trident/2.0.0/javadoc/) A dead simpile annotation event system that allows different event executor implementations. From 29870e43ce533b3480fe6c3d85917760b260f662 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 04:00:09 -0700 Subject: [PATCH 27/37] Change discord badge to shields.io badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7108f7..ecd58b6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![codecov](https://codecov.io/gh/ClubObsidian/trident/branch/master/graph/badge.svg)](https://codecov.io/gh/ClubObsidian/trident) [![Known Vulnerabilities](https://snyk.io//test/github/ClubObsidian/trident/badge.svg?targetFile=build.gradle)](https://snyk.io//test/github/ClubObsidian/trident?targetFile=build.gradle) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![discord](https://discordapp.com/api/guilds/482823104905609248/widget.png)](https://discord.gg/EY5Tq6r) +[![Discord](https://img.shields.io/discord/482823104905609248.svg?logo=discord)](https://discord.gg/EY5Tq6r) [![javadocs](https://img.shields.io/badge/Javadocs-2.0.0-success.svg)](https://jitpack.io/com/github/clubobsidian/trident/2.0.0/javadoc/) A dead simpile annotation event system that allows different event executor implementations. From e34359d6f01f814c5b78d4d0b902be3a9bf68408 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 24 Jun 2019 04:25:41 -0700 Subject: [PATCH 28/37] Goodbye listener interface It seems that listener interfaces are old-hat. Removed for the 2.0.0 release. Now generic objects are used for registering and unregistering instead. --- README.md | 2 +- .../com/clubobsidian/trident/EventBus.java | 8 +++---- .../com/clubobsidian/trident/Listener.java | 23 ------------------- .../clubobsidian/trident/MethodExecutor.java | 6 ++--- .../impl/javaassist/JavaAssistEventBus.java | 6 ++--- .../impl/reflection/ReflectionEventBus.java | 3 +-- .../reflection/ReflectionMethodExecutor.java | 3 +-- .../trident/test/EventBusTest.java | 3 +-- .../trident/test/JavaAssistEventBusTest.java | 3 +-- .../trident/test/ReflectionMiscEventTest.java | 3 +-- .../trident/test/impl/TestEventBus.java | 3 +-- .../trident/test/impl/TestListener.java | 3 +-- .../trident/test/impl/TestListenerIgnore.java | 3 +-- .../trident/test/impl/TestMethodExecutor.java | 3 +-- .../test/impl/TestWrongArgumentListener.java | 4 +--- 15 files changed, 20 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/clubobsidian/trident/Listener.java diff --git a/README.md b/README.md index ecd58b6..c8b82c9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Discord](https://img.shields.io/discord/482823104905609248.svg?logo=discord)](https://discord.gg/EY5Tq6r) [![javadocs](https://img.shields.io/badge/Javadocs-2.0.0-success.svg)](https://jitpack.io/com/github/clubobsidian/trident/2.0.0/javadoc/) -A dead simpile annotation event system that allows different event executor implementations. +A dead simpile annotation-based event bus that allows different event executor implementations. Trident implements reflection and generated Javassist method executors. diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index bb6e3c1..a0583d1 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -34,7 +34,7 @@ */ public abstract class EventBus { - private Map> registeredEventListeners; + private Map> registeredEventListeners; private Map, EventDoublyLinkedList> registeredExecutors; public EventBus() { @@ -81,7 +81,7 @@ public boolean callEvent(final Event event) * @param listener listener to be registered * @return if the listener was registered */ - public boolean registerEvents(final Listener listener) + public boolean registerEvents(final Object listener) { if(listener == null) { @@ -126,14 +126,14 @@ else if(this.registeredEventListeners.keySet().contains(listener)) return true; } - protected abstract MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled); + protected abstract MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled); /** * * @param listener listener to be unregistered * @return if the listener was unregistered */ - public boolean unregisterEvents(Listener listener) + public boolean unregisterEvents(Object listener) { Queue executors = this.registeredEventListeners.remove(listener); if(executors == null) diff --git a/src/main/java/com/clubobsidian/trident/Listener.java b/src/main/java/com/clubobsidian/trident/Listener.java deleted file mode 100644 index 23fc4b8..0000000 --- a/src/main/java/com/clubobsidian/trident/Listener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package com.clubobsidian.trident; - -/** - * Interface for listeners to implement. - * - * @author virustotalop - */ -public interface Listener {} diff --git a/src/main/java/com/clubobsidian/trident/MethodExecutor.java b/src/main/java/com/clubobsidian/trident/MethodExecutor.java index c8b4f2c..9fe72ac 100644 --- a/src/main/java/com/clubobsidian/trident/MethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/MethodExecutor.java @@ -26,10 +26,10 @@ */ public abstract class MethodExecutor { - private Listener listener; + private Object listener; private Method method; private boolean ignoreCanceled; - public MethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + public MethodExecutor(Object listener, Method method, boolean ignoreCanceled) { this.listener = listener; this.method = method; @@ -39,7 +39,7 @@ public MethodExecutor(Listener listener, Method method, boolean ignoreCanceled) /** * @return listener to execute events on */ - public Listener getListener() + public Object getListener() { return this.listener; } diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java index eb67f22..1d5832e 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java @@ -23,7 +23,6 @@ import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; import javassist.CannotCompileException; @@ -59,12 +58,12 @@ public ClassPool getClassPool() } @Override - protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { return this.generateMethodExecutor(listener, method, ignoreCanceled); } - private MethodExecutor generateMethodExecutor(final Listener listener, final Method method, final boolean ignoreCanceled) + private MethodExecutor generateMethodExecutor(Object listener, final Method method, final boolean ignoreCanceled) { if(listener == null || method == null) return null; @@ -76,7 +75,6 @@ private MethodExecutor generateMethodExecutor(final Listener listener, final Met Class listenerClass = Class.forName(listener.getClass().getName(), true, classLoader); this.addClassToPool(Event.class); - this.addClassToPool(Listener.class); LoaderClassPath loaderClassPath = new LoaderClassPath(classLoader); diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java index 78c925a..d1f786e 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java @@ -18,7 +18,6 @@ import java.lang.reflect.Method; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; /** @@ -27,7 +26,7 @@ public class ReflectionEventBus extends EventBus { @Override - protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { return new ReflectionMethodExecutor(listener, method, ignoreCanceled); } diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java index a349942..57ac484 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java @@ -19,7 +19,6 @@ import java.lang.reflect.Method; import com.clubobsidian.trident.Event; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; /** @@ -27,7 +26,7 @@ */ public class ReflectionMethodExecutor extends MethodExecutor { - public ReflectionMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + public ReflectionMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { super(listener, method, ignoreCanceled); } diff --git a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java index 0baa003..faaae2e 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventBusTest.java @@ -7,7 +7,6 @@ import com.clubobsidian.trident.Event; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.test.impl.TestCancelableEvent; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; @@ -118,5 +117,5 @@ public void testPrivateListener() protected abstract EventBus createNewEventBus(); - private class PrivateListener implements Listener {} + private class PrivateListener {} } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index 9121b7d..6efb150 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -30,7 +30,6 @@ import org.junit.runners.MethodSorters; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; import com.clubobsidian.trident.test.impl.TestListener; @@ -50,7 +49,7 @@ public void testNullMethodOnMethodExecutor() JavaAssistEventBus eventBus = new JavaAssistEventBus(); try { - Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Listener.class, Method.class, boolean.class); + Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Object.class, Method.class, boolean.class); generate.setAccessible(true); Object methodExecutor = generate.invoke(eventBus, null, null, false); assertTrue("Method executor is not null even though a null listener was passed", methodExecutor == null); diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index beb5493..c1e1bfb 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -22,7 +22,6 @@ import org.junit.Test; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; import com.clubobsidian.trident.impl.reflection.ReflectionMethodExecutor; import com.clubobsidian.trident.test.impl.TestWrongArgumentListener; @@ -37,7 +36,7 @@ public void methodExecutorTest() { try { - Listener listener = new TestListener("test"); + TestListener listener = new TestListener("test"); Method testEventMethod = listener.getClass().getDeclaredMethod("test", TestEvent.class); MethodExecutor executor = new ReflectionMethodExecutor(listener, testEventMethod, false); diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java index ec33315..667bc1c 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventBus.java @@ -3,13 +3,12 @@ import java.lang.reflect.Method; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; public class TestEventBus extends EventBus { @Override - protected MethodExecutor createMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + protected MethodExecutor createMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { return null; } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index aa08f68..49cef61 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -17,9 +17,8 @@ import com.clubobsidian.trident.EventHandler; import com.clubobsidian.trident.EventPriority; -import com.clubobsidian.trident.Listener; -public class TestListener implements Listener { +public class TestListener { private String data; private boolean test; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index 13a2970..947525c 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -17,9 +17,8 @@ import com.clubobsidian.trident.EventHandler; import com.clubobsidian.trident.EventPriority; -import com.clubobsidian.trident.Listener; -public class TestListenerIgnore implements Listener { +public class TestListenerIgnore { private boolean canceled = false; private boolean ignored = true; diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java index bb3d6a7..aa3e298 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestMethodExecutor.java @@ -3,12 +3,11 @@ import java.lang.reflect.Method; import com.clubobsidian.trident.Event; -import com.clubobsidian.trident.Listener; import com.clubobsidian.trident.MethodExecutor; public class TestMethodExecutor extends MethodExecutor { - public TestMethodExecutor(Listener listener, Method method, boolean ignoreCanceled) + public TestMethodExecutor(Object listener, Method method, boolean ignoreCanceled) { super(listener, method, ignoreCanceled); } diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java index b11a44a..5893d4f 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java @@ -15,9 +15,7 @@ */ package com.clubobsidian.trident.test.impl; -import com.clubobsidian.trident.Listener; - -public class TestWrongArgumentListener implements Listener { +public class TestWrongArgumentListener { private String data; private boolean test; From 49b3e5853aa2bb2a33414958888337a392359d36 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 25 Jun 2019 01:29:31 -0700 Subject: [PATCH 29/37] Refactor eventbusses to new package --- .../javassist/JavassistEventBus.java} | 12 ++++++------ .../trident/eventbus/package-info.java | 1 + .../reflection/ReflectionEventBus.java | 2 +- .../reflection/ReflectionMethodExecutor.java | 2 +- .../clubobsidian/trident/impl/package-info.java | 16 ---------------- .../trident/test/IgnoreCanceledTest.java | 4 ++-- .../trident/test/JavaAssistEventBusTest.java | 12 ++++++------ .../trident/test/ReflectionEventBusTest.java | 2 +- .../trident/test/ReflectionMiscEventTest.java | 2 +- 9 files changed, 19 insertions(+), 34 deletions(-) rename src/main/java/com/clubobsidian/trident/{impl/javaassist/JavaAssistEventBus.java => eventbus/javassist/JavassistEventBus.java} (92%) create mode 100644 src/main/java/com/clubobsidian/trident/eventbus/package-info.java rename src/main/java/com/clubobsidian/trident/{impl => eventbus}/reflection/ReflectionEventBus.java (94%) rename src/main/java/com/clubobsidian/trident/{impl => eventbus}/reflection/ReflectionMethodExecutor.java (95%) delete mode 100644 src/main/java/com/clubobsidian/trident/impl/package-info.java diff --git a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java similarity index 92% rename from src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java rename to src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java index 1d5832e..0e9753b 100644 --- a/src/main/java/com/clubobsidian/trident/impl/javaassist/JavaAssistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.clubobsidian.trident.impl.javaassist; +package com.clubobsidian.trident.eventbus.javassist; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -37,17 +37,17 @@ /** * {@inheritDoc} */ -public class JavaAssistEventBus extends EventBus { +public class JavassistEventBus extends EventBus { private static ConcurrentMap map; static { - JavaAssistEventBus.map = new ConcurrentHashMap<>(); + JavassistEventBus.map = new ConcurrentHashMap<>(); } private ClassPool pool; - public JavaAssistEventBus() + public JavassistEventBus() { this.pool = new ClassPool(true); } @@ -92,7 +92,7 @@ private MethodExecutor generateMethodExecutor(Object listener, final Method meth { collision = new AtomicInteger(0); classNum = 0; - JavaAssistEventBus.map.put(callbackClassName, collision); + JavassistEventBus.map.put(callbackClassName, collision); } else { @@ -128,7 +128,7 @@ private MethodExecutor generateMethodExecutor(Object listener, final Method meth CtMethod call = CtNewMethod.make(sb.toString(), methodExecutorClass); methodExecutorClass.addMethod(call); - Class cl = methodExecutorClass.toClass(classLoader, JavaAssistEventBus.class.getProtectionDomain()); + Class cl = methodExecutorClass.toClass(classLoader, JavassistEventBus.class.getProtectionDomain()); return (MethodExecutor) cl.getDeclaredConstructors()[0].newInstance(listener, method, ignoreCanceled); } catch (NotFoundException | CannotCompileException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException e) diff --git a/src/main/java/com/clubobsidian/trident/eventbus/package-info.java b/src/main/java/com/clubobsidian/trident/eventbus/package-info.java new file mode 100644 index 0000000..857b273 --- /dev/null +++ b/src/main/java/com/clubobsidian/trident/eventbus/package-info.java @@ -0,0 +1 @@ +package com.clubobsidian.trident.eventbus; \ No newline at end of file diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java similarity index 94% rename from src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java rename to src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java index d1f786e..edce3fb 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.clubobsidian.trident.impl.reflection; +package com.clubobsidian.trident.eventbus.reflection; import java.lang.reflect.Method; diff --git a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java similarity index 95% rename from src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java rename to src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java index 57ac484..6e4f2be 100644 --- a/src/main/java/com/clubobsidian/trident/impl/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package com.clubobsidian.trident.impl.reflection; +package com.clubobsidian.trident.eventbus.reflection; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/src/main/java/com/clubobsidian/trident/impl/package-info.java b/src/main/java/com/clubobsidian/trident/impl/package-info.java deleted file mode 100644 index 55a6ced..0000000 --- a/src/main/java/com/clubobsidian/trident/impl/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - Copyright 2018 Club Obsidian and contributors. - - 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. -*/ -package com.clubobsidian.trident.impl; diff --git a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java index ee70c8f..5f332be 100644 --- a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java @@ -21,7 +21,7 @@ import org.junit.Test; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; +import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; import com.clubobsidian.trident.test.impl.TestCancelableEvent; import com.clubobsidian.trident.test.impl.TestListenerIgnore; @@ -31,7 +31,7 @@ public class IgnoreCanceledTest { public void ignoredCanceled() { TestListenerIgnore listener = new TestListenerIgnore(); - EventBus manager = new JavaAssistEventBus(); + EventBus manager = new JavassistEventBus(); manager.registerEvents(listener); manager.callEvent(new TestCancelableEvent()); diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index 6efb150..470929c 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -30,7 +30,7 @@ import org.junit.runners.MethodSorters; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.impl.javaassist.JavaAssistEventBus; +import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; import com.clubobsidian.trident.test.impl.TestListener; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -39,14 +39,14 @@ public class JavaAssistEventBusTest extends EventBusTest { @Test public void testClassPoolExists() { - JavaAssistEventBus eventBus = new JavaAssistEventBus(); + JavassistEventBus eventBus = new JavassistEventBus(); assertTrue("No class pool for JavaAssist event bus", eventBus.getClassPool() != null); } @Test public void testNullMethodOnMethodExecutor() { - JavaAssistEventBus eventBus = new JavaAssistEventBus(); + JavassistEventBus eventBus = new JavassistEventBus(); try { Method generate = eventBus.getClass().getDeclaredMethod("generateMethodExecutor", Object.class, Method.class, boolean.class); @@ -65,9 +65,9 @@ public void testFrozenMethodExecutor() { try { - JavaAssistEventBus eventBus = new JavaAssistEventBus(); + JavassistEventBus eventBus = new JavassistEventBus(); eventBus.registerEvents(new TestListener("data")); - Field mapField = JavaAssistEventBus.class.getDeclaredField("map"); + Field mapField = JavassistEventBus.class.getDeclaredField("map"); mapField.setAccessible(true); ConcurrentMap savedMap = (ConcurrentMap) mapField.get(null); @@ -88,6 +88,6 @@ public void testFrozenMethodExecutor() @Override protected EventBus createNewEventBus() { - return new JavaAssistEventBus(); + return new JavassistEventBus(); } } \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java index c3eac14..2ca8576 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java @@ -16,7 +16,7 @@ package com.clubobsidian.trident.test; import com.clubobsidian.trident.EventBus; -import com.clubobsidian.trident.impl.reflection.ReflectionEventBus; +import com.clubobsidian.trident.eventbus.reflection.ReflectionEventBus; public class ReflectionEventBusTest extends EventBusTest { diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index c1e1bfb..111c776 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import com.clubobsidian.trident.MethodExecutor; -import com.clubobsidian.trident.impl.reflection.ReflectionMethodExecutor; +import com.clubobsidian.trident.eventbus.reflection.ReflectionMethodExecutor; import com.clubobsidian.trident.test.impl.TestWrongArgumentListener; import com.clubobsidian.trident.test.impl.TestEvent; import com.clubobsidian.trident.test.impl.TestListener; From c6ee0769d70b6637d4f0d40932a5a0b416ba995c Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 25 Jun 2019 01:33:11 -0700 Subject: [PATCH 30/37] Update copyright notice --- LICENSE_HEADER | 2 +- src/main/java/com/clubobsidian/trident/Cancelable.java | 2 +- src/main/java/com/clubobsidian/trident/Event.java | 2 +- src/main/java/com/clubobsidian/trident/EventBus.java | 2 +- src/main/java/com/clubobsidian/trident/EventHandler.java | 2 +- src/main/java/com/clubobsidian/trident/EventPriority.java | 2 +- src/main/java/com/clubobsidian/trident/MethodExecutor.java | 2 +- .../trident/eventbus/javassist/JavassistEventBus.java | 2 +- .../trident/eventbus/reflection/ReflectionEventBus.java | 2 +- .../trident/eventbus/reflection/ReflectionMethodExecutor.java | 2 +- src/main/java/com/clubobsidian/trident/util/ClassUtil.java | 2 +- .../com/clubobsidian/trident/util/EventDoublyLinkedList.java | 2 +- src/main/java/com/clubobsidian/trident/util/EventNode.java | 2 +- .../clubobsidian/trident/test/EventDoublyLinkedListTest.java | 2 +- .../java/com/clubobsidian/trident/test/IgnoreCanceledTest.java | 2 +- .../com/clubobsidian/trident/test/JavaAssistEventBusTest.java | 2 +- .../com/clubobsidian/trident/test/ReflectionEventBusTest.java | 2 +- .../com/clubobsidian/trident/test/ReflectionMiscEventTest.java | 2 +- src/test/java/com/clubobsidian/trident/test/UtilTest.java | 2 +- .../com/clubobsidian/trident/test/impl/TestCancelableEvent.java | 2 +- src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java | 2 +- .../java/com/clubobsidian/trident/test/impl/TestEventSuper.java | 2 +- .../java/com/clubobsidian/trident/test/impl/TestListener.java | 2 +- .../com/clubobsidian/trident/test/impl/TestListenerIgnore.java | 2 +- .../java/com/clubobsidian/trident/test/impl/TestOrderEvent.java | 2 +- .../trident/test/impl/TestWrongArgumentListener.java | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/LICENSE_HEADER b/LICENSE_HEADER index 6c8053b..ad0340b 100644 --- a/LICENSE_HEADER +++ b/LICENSE_HEADER @@ -1,4 +1,4 @@ - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/Cancelable.java b/src/main/java/com/clubobsidian/trident/Cancelable.java index f5eefc1..ac8bcde 100644 --- a/src/main/java/com/clubobsidian/trident/Cancelable.java +++ b/src/main/java/com/clubobsidian/trident/Cancelable.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/Event.java b/src/main/java/com/clubobsidian/trident/Event.java index 68d4771..b6c209f 100644 --- a/src/main/java/com/clubobsidian/trident/Event.java +++ b/src/main/java/com/clubobsidian/trident/Event.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index a0583d1..75f75df 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/EventHandler.java b/src/main/java/com/clubobsidian/trident/EventHandler.java index 19a2957..984c9c7 100644 --- a/src/main/java/com/clubobsidian/trident/EventHandler.java +++ b/src/main/java/com/clubobsidian/trident/EventHandler.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/EventPriority.java b/src/main/java/com/clubobsidian/trident/EventPriority.java index 936ef08..37384f1 100644 --- a/src/main/java/com/clubobsidian/trident/EventPriority.java +++ b/src/main/java/com/clubobsidian/trident/EventPriority.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/MethodExecutor.java b/src/main/java/com/clubobsidian/trident/MethodExecutor.java index 9fe72ac..8ab0be4 100644 --- a/src/main/java/com/clubobsidian/trident/MethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/MethodExecutor.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java index 0e9753b..24ff8d6 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/javassist/JavassistEventBus.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java index edce3fb..971cae2 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionEventBus.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java index 6e4f2be..dbba86a 100644 --- a/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java +++ b/src/main/java/com/clubobsidian/trident/eventbus/reflection/ReflectionMethodExecutor.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java index 10e028f..f0f423c 100644 --- a/src/main/java/com/clubobsidian/trident/util/ClassUtil.java +++ b/src/main/java/com/clubobsidian/trident/util/ClassUtil.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java index ebf8115..9040dd2 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java +++ b/src/main/java/com/clubobsidian/trident/util/EventDoublyLinkedList.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main/java/com/clubobsidian/trident/util/EventNode.java b/src/main/java/com/clubobsidian/trident/util/EventNode.java index 19004db..0b7fc55 100644 --- a/src/main/java/com/clubobsidian/trident/util/EventNode.java +++ b/src/main/java/com/clubobsidian/trident/util/EventNode.java @@ -1,4 +1,4 @@ -/* Copyright 2018 Club Obsidian and contributors. +/* Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java index 923cf8e..a10aa5e 100644 --- a/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java +++ b/src/test/java/com/clubobsidian/trident/test/EventDoublyLinkedListTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java index 5f332be..e96b68d 100644 --- a/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java +++ b/src/test/java/com/clubobsidian/trident/test/IgnoreCanceledTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java index 470929c..84bce65 100644 --- a/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/JavaAssistEventBusTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java index 2ca8576..58b317c 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionEventBusTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java index 111c776..1a00954 100644 --- a/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java +++ b/src/test/java/com/clubobsidian/trident/test/ReflectionMiscEventTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/UtilTest.java b/src/test/java/com/clubobsidian/trident/test/UtilTest.java index fad6d1f..1dd87a2 100644 --- a/src/test/java/com/clubobsidian/trident/test/UtilTest.java +++ b/src/test/java/com/clubobsidian/trident/test/UtilTest.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java index 90cf0b1..8725695 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestCancelableEvent.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java index 0d09d2d..abda403 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEvent.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java index e5ff0a5..7f1e7b3 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestEventSuper.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java index 49cef61..b8c97d9 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListener.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java index 947525c..c25d364 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestListenerIgnore.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java index 9140847..d66f26a 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestOrderEvent.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java index 5893d4f..f670036 100644 --- a/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestWrongArgumentListener.java @@ -1,5 +1,5 @@ /* - Copyright 2018 Club Obsidian and contributors. + Copyright 2019 Club Obsidian and contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From d5821827e8fb501dfc241d9d0dd4d63a9c34d278 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 25 Jun 2019 02:12:16 -0700 Subject: [PATCH 31/37] Added DeadEvent Added DeadEvent finishes #12 --- .../com/clubobsidian/trident/EventBus.java | 8 ++++ .../clubobsidian/trident/event/DeadEvent.java | 44 +++++++++++++++++++ .../trident/test/DeadEventTest.java | 38 ++++++++++++++++ .../test/impl/TestDeadEventListener.java | 26 +++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/main/java/com/clubobsidian/trident/event/DeadEvent.java create mode 100644 src/test/java/com/clubobsidian/trident/test/DeadEventTest.java create mode 100644 src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 75f75df..49623bd 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; +import com.clubobsidian.trident.event.DeadEvent; import com.clubobsidian.trident.util.ClassUtil; import com.clubobsidian.trident.util.EventDoublyLinkedList; import com.clubobsidian.trident.util.EventNode; @@ -51,7 +52,13 @@ public boolean callEvent(final Event event) EventDoublyLinkedList executors = this.registeredExecutors.get(event.getClass()); if(executors == null) + { + if(!(event instanceof DeadEvent)) + { + this.callEvent(new DeadEvent(event)); + } return false; + } boolean ran = false; EventNode node = executors.getHead(); @@ -74,6 +81,7 @@ public boolean callEvent(final Event event) executor.execute(event); node = node.getNext(); } + return ran; } diff --git a/src/main/java/com/clubobsidian/trident/event/DeadEvent.java b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java new file mode 100644 index 0000000..37ee383 --- /dev/null +++ b/src/main/java/com/clubobsidian/trident/event/DeadEvent.java @@ -0,0 +1,44 @@ +/* + Copyright 2019 Club Obsidian and contributors. + + 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. +*/ +package com.clubobsidian.trident.event; + +import com.clubobsidian.trident.Event; + +/** + * Event that is called if an event is not + * listened to by a listener. + * Extends {@link Event} + * + * @author virustotalop + */ +public class DeadEvent extends Event { + + private Event event; + public DeadEvent(Event event) + { + this.event = event; + } + + /** + * Returns an event that was + * not fired. + * @return event not fired + */ + public Event getDeadEvent() + { + return this.event; + } +} \ No newline at end of file diff --git a/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java new file mode 100644 index 0000000..6681cf8 --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/DeadEventTest.java @@ -0,0 +1,38 @@ +package com.clubobsidian.trident.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.clubobsidian.trident.EventBus; +import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus; +import com.clubobsidian.trident.test.impl.TestDeadEventListener; +import com.clubobsidian.trident.test.impl.TestEvent; + +public class DeadEventTest { + + @Test + public void testNoListener() + { + EventBus eventBus = new JavassistEventBus(); + boolean listenedTo = eventBus.callEvent(new TestEvent()); + + assertFalse("Event was listened to", listenedTo); + + } + + @Test + public void testDeadListener() + { + EventBus eventBus = new JavassistEventBus(); + TestDeadEventListener deadEventListener = new TestDeadEventListener(); + eventBus.registerEvents(deadEventListener); + + eventBus.callEvent(new TestEvent()); + + System.out.println(deadEventListener.getTimesRan()); + assertTrue("Dead event triggered twice", deadEventListener.getTimesRan() == 1); + } + +} diff --git a/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java new file mode 100644 index 0000000..76e551f --- /dev/null +++ b/src/test/java/com/clubobsidian/trident/test/impl/TestDeadEventListener.java @@ -0,0 +1,26 @@ +package com.clubobsidian.trident.test.impl; + +import com.clubobsidian.trident.EventHandler; +import com.clubobsidian.trident.event.DeadEvent; + +public class TestDeadEventListener { + + private int timesRan; + public TestDeadEventListener() + { + this.timesRan = 0; + } + + + @EventHandler + public void onDeadEvent(DeadEvent event) + { + System.out.println("Dead event: " + event.getDeadEvent().getName()); + this.timesRan += 1; + } + + public int getTimesRan() + { + return this.timesRan; + } +} \ No newline at end of file From 4059587d6dac676d324a768257f05ed8a308b57d Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 25 Jun 2019 02:22:31 -0700 Subject: [PATCH 32/37] Test emoji in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8b82c9..062a21d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ compile 'com.github.clubobsidian:trident:2.0.0' 2. Generate intellij files with `gradlew idea` 3. Import project -### Building +### :building_construction: Building `gradlew shadowJar` From 2583c1c6b63eeaaab148fc1134b81b7b26cac659 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Tue, 25 Jun 2019 02:28:15 -0700 Subject: [PATCH 33/37] Add emojis to readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 062a21d..6560afc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![trident](/img/trident_logo.png) +# Trident [![Build Status](https://api.travis-ci.org/ClubObsidian/trident.svg?branch=master)](https://travis-ci.org/ClubObsidian/trident) [![build artifacts](https://jitpack.io/v/clubobsidian/trident.svg)](https://jitpack.io/#clubobsidian/trident) @@ -12,11 +12,11 @@ A dead simpile annotation-based event bus that allows different event executor i Trident implements reflection and generated Javassist method executors. -## Build Artifacts +## :hammer: Build Artifacts Build artifacts are hosted via [Jitpack.](https://jitpack.io/#clubobsidian/Trident/) -## Setting up as a dependency +## :open_book: Setting up as a dependency ### Gradle @@ -45,11 +45,11 @@ compile 'com.github.clubobsidian:trident:2.0.0' ``` -## Dependencies +## :fire: Dependencies * Javassist -## Development +## :computer: Development ### Eclipse @@ -67,7 +67,7 @@ compile 'com.github.clubobsidian:trident:2.0.0' `gradlew shadowJar` -### Projects that use Trident +### :notes: Projects that use Trident * [DynamicGui](https://github.com/ClubObsidian/DynamicGui) * [Hydra](https://github.com/ClubObsidian/hydra) From 4188e8b2d24d1410bc6dae5a72e8b009dd927eb3 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Mon, 1 Jul 2019 17:16:34 -0700 Subject: [PATCH 34/37] Put emojis at the end of the titles in the readme --- README.md | 12 ++++++------ src/main/java/com/clubobsidian/trident/EventBus.java | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6560afc..a20e247 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ A dead simpile annotation-based event bus that allows different event executor i Trident implements reflection and generated Javassist method executors. -## :hammer: Build Artifacts +## Build Artifacts :hammer: Build artifacts are hosted via [Jitpack.](https://jitpack.io/#clubobsidian/Trident/) -## :open_book: Setting up as a dependency +## Setting up as a dependency :open_book: ### Gradle @@ -45,11 +45,11 @@ compile 'com.github.clubobsidian:trident:2.0.0' ``` -## :fire: Dependencies +## Dependencies :fire: * Javassist -## :computer: Development +## Development :computer: ### Eclipse @@ -63,11 +63,11 @@ compile 'com.github.clubobsidian:trident:2.0.0' 2. Generate intellij files with `gradlew idea` 3. Import project -### :building_construction: Building +### Building :building_construction: `gradlew shadowJar` -### :notes: Projects that use Trident +### Projects that use Trident :notes: * [DynamicGui](https://github.com/ClubObsidian/DynamicGui) * [Hydra](https://github.com/ClubObsidian/hydra) diff --git a/src/main/java/com/clubobsidian/trident/EventBus.java b/src/main/java/com/clubobsidian/trident/EventBus.java index 49623bd..09ef21d 100644 --- a/src/main/java/com/clubobsidian/trident/EventBus.java +++ b/src/main/java/com/clubobsidian/trident/EventBus.java @@ -158,5 +158,4 @@ public boolean unregisterEvents(Object listener) } return true; } - -} +} \ No newline at end of file From 360f58d70cf43636a081dea7848659b29b5daa16 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Sun, 7 Jul 2019 01:41:04 -0700 Subject: [PATCH 35/37] Add inspiration section to readme Added inspiration section to readme completing #13 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a20e247..e737d5c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,14 @@ A dead simpile annotation-based event bus that allows different event executor i Trident implements reflection and generated Javassist method executors. +## Inspiration :star: + +Inspiration for Trident. + +* [Event4j](https://github.com/Techcable/Event4J) +* [Guava](https://github.com/google/guava) +* [mbassador](https://github.com/bennidi/mbassador) + ## Build Artifacts :hammer: Build artifacts are hosted via [Jitpack.](https://jitpack.io/#clubobsidian/Trident/) From 0e723811a8e497f2d7d601deb7084406e8fe316c Mon Sep 17 00:00:00 2001 From: virustotalop Date: Sun, 7 Jul 2019 01:43:48 -0700 Subject: [PATCH 36/37] Add link to javassist in the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e737d5c..7025f64 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ compile 'com.github.clubobsidian:trident:2.0.0' ## Dependencies :fire: -* Javassist +* [Javassist](https://github.com/jboss-javassist/javassist) ## Development :computer: From a29fec2b7e14f5a733c793b4db49ae4414c0739d Mon Sep 17 00:00:00 2001 From: virustotalop Date: Sun, 7 Jul 2019 01:46:22 -0700 Subject: [PATCH 37/37] Remove emojis from readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7025f64..0769409 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A dead simpile annotation-based event bus that allows different event executor i Trident implements reflection and generated Javassist method executors. -## Inspiration :star: +## Inspiration Inspiration for Trident. @@ -20,11 +20,11 @@ Inspiration for Trident. * [Guava](https://github.com/google/guava) * [mbassador](https://github.com/bennidi/mbassador) -## Build Artifacts :hammer: +## Build Artifacts Build artifacts are hosted via [Jitpack.](https://jitpack.io/#clubobsidian/Trident/) -## Setting up as a dependency :open_book: +## Setting up as a dependency ### Gradle @@ -53,11 +53,11 @@ compile 'com.github.clubobsidian:trident:2.0.0' ``` -## Dependencies :fire: +## Dependencies * [Javassist](https://github.com/jboss-javassist/javassist) -## Development :computer: +## Development ### Eclipse @@ -71,11 +71,11 @@ compile 'com.github.clubobsidian:trident:2.0.0' 2. Generate intellij files with `gradlew idea` 3. Import project -### Building :building_construction: +### Building `gradlew shadowJar` -### Projects that use Trident :notes: +### Projects that use Trident * [DynamicGui](https://github.com/ClubObsidian/DynamicGui) * [Hydra](https://github.com/ClubObsidian/hydra)