aboutsummaryrefslogtreecommitdiffstats
path: root/testing-client/src
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-01-23 19:45:07 -0800
committerAndy Clement <aclement@pivotal.io>2019-01-23 19:45:07 -0800
commita303931ebcf72494bdb75395b350ff640a0ff1f3 (patch)
tree2e0346be1fda535f80f603aa4214784e704952e9 /testing-client/src
parent44f6584f48c77f58ad80115bff0dd637831df939 (diff)
downloadaspectj-a303931ebcf72494bdb75395b350ff640a0ff1f3.tar.gz
aspectj-a303931ebcf72494bdb75395b350ff640a0ff1f3.zip
mavenizing testing-client module - wip
Diffstat (limited to 'testing-client/src')
-rw-r--r--testing-client/src/main/java/org/aspectj/testing/Tester.java (renamed from testing-client/src/org/aspectj/testing/Tester.java)0
-rw-r--r--testing-client/src/main/java/org/aspectj/testing/server/TestServer.java (renamed from testing-client/src/org/aspectj/testing/server/TestServer.java)0
-rw-r--r--testing-client/src/test/java/org/aspectj/testing/TesterTest.java239
-rw-r--r--testing-client/src/test/java/org/aspectj/testing/TestingClientModuleTests.java30
-rw-r--r--testing-client/src/test/java/org/aspectj/testing/TestingTests.java35
-rw-r--r--testing-client/src/test/java/org/aspectj/testing/server/TestServerTest.java40
6 files changed, 344 insertions, 0 deletions
diff --git a/testing-client/src/org/aspectj/testing/Tester.java b/testing-client/src/main/java/org/aspectj/testing/Tester.java
index 500c4c363..500c4c363 100644
--- a/testing-client/src/org/aspectj/testing/Tester.java
+++ b/testing-client/src/main/java/org/aspectj/testing/Tester.java
diff --git a/testing-client/src/org/aspectj/testing/server/TestServer.java b/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java
index 80cbc357b..80cbc357b 100644
--- a/testing-client/src/org/aspectj/testing/server/TestServer.java
+++ b/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java
diff --git a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java
new file mode 100644
index 000000000..d538a63f7
--- /dev/null
+++ b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java
@@ -0,0 +1,239 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.testing;
+
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+/**
+ * Test the Tester client API's.
+ * See also tests/harness/*.java and tests/ajcHarnessTests.xml for harness-
+ * driven Tester tests.
+ * @author isberg
+ */
+public class TesterTest extends TestCase {
+
+
+ private static final String ME
+ = "org.aspectj.testing.TesterTest";
+
+ /** @param args ignored */
+ public static void main(String[] args) {
+ TestRunner.main(new String[] {ME});
+ }
+
+ /**
+ * Constructor for TesterTest.
+ * @param arg0
+ */
+ public TesterTest(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test the usage pattern
+ * <pre>Tester.event("foo");
+ * Tester.checkEvents(new String[] { "foo" }); </pre>
+ */
+ public void testEventArrayPattern() {
+ MyTestReporter reporter = new MyTestReporter();
+ Tester.setMessageHandler(reporter);
+
+ //--------- positive test - got expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.event("one");
+ Tester.event("two");
+ Tester.checkEvents(new String[] { "one", "two"});
+ reporter.assertSize(0);
+
+ //--------- failed to get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.checkEvents(new String[] { "one"});
+ assertTrue(reporter.gotFail("one"));
+ reporter.assertSize(1);
+
+ //--------- got and didn't get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.event("one");
+ Tester.event("two");
+ Tester.checkEvents(new String[] { "one", "two", "three"});
+ reporter.assertSize(1);
+ assertTrue(reporter.gotFail("three"));
+ }
+
+ /**
+ * Test the usage pattern
+ * <pre>Tester.event("foo");
+ * Tester.expectEvent("foo");
+ * Tester.checkAllEvents();</pre>
+ */
+ public void testEventStringPattern() {
+ MyTestReporter reporter = new MyTestReporter();
+ Tester.setMessageHandler(reporter);
+
+ //--------- positive test - got expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.event("one");
+ Tester.event("two");
+ Tester.expectEvent("one");
+ Tester.expectEvent("two");
+ Tester.checkAllEvents();
+ reporter.assertSize(0);
+
+ //--------- failed to get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.expectEvent("one");
+ Tester.checkAllEvents();
+ assertTrue(reporter.gotFail("one"));
+ reporter.assertSize(1);
+
+ //--------- got and didn't get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.expectEvent("one");
+ Tester.expectEvent("two");
+ Tester.expectEvent("three");
+ Tester.event("one");
+ Tester.event("two");
+ Tester.checkAllEvents();
+ assertTrue(reporter.gotFail("three"));
+ reporter.assertSize(1);
+ }
+
+ /**
+ * Test the usage pattern
+ * <pre>Tester.note("foo");
+ * Tester.check("foo");</pre>
+ */
+ public void testNotePattern() {
+ MyTestReporter reporter = new MyTestReporter();
+ Tester.setMessageHandler(reporter);
+
+ //--------- positive test - got expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.note("one");
+ Tester.note("two");
+ Tester.check("one");
+ Tester.check("two");
+ reporter.assertSize(0);
+
+ //--------- failed to get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.check("one");
+ Tester.checkAllEvents();
+ assertTrue(reporter.gotFail("one"));
+ reporter.assertSize(1);
+
+ //--------- got and didn't get expected events
+ reporter.clear();
+ Tester.clear();
+ Tester.note("one");
+ Tester.check("one");
+ Tester.note("two");
+ Tester.check("two");
+ Tester.check("three");
+ assertTrue(reporter.gotFail("three"));
+ reporter.assertSize(1);
+ }
+
+ /**
+ * Stub to record failures emitted by Tester.
+ * @author isberg
+ */
+ public static class MyTestReporter implements IMessageHandler {
+ public ArrayList<IMessage> failures = new ArrayList<>();
+ public ArrayList<IMessage> passes = new ArrayList<>();
+
+ public void clear() {
+ failures.clear();
+ passes.clear();
+ }
+
+ void assertSize(int size) {
+ assertTrue(-1 < size);
+ assertTrue("failures: " + failures, size == failures.size());
+ }
+
+ boolean gotPass(String substring) {
+ return gotItem(passes, substring);
+ }
+
+ boolean gotFail(String substring) {
+ return gotItem(failures, substring);
+ }
+
+ boolean gotItem(List<IMessage> list, String substring) {
+ for (IMessage element: list) {
+ String s = element.getMessage();
+ if ((null != s) && (-1 != s.indexOf(substring))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnoring(IMessage.Kind kind) {
+ return false;
+ }
+
+ public void dontIgnore(IMessage.Kind kind) {
+ ;
+ }
+
+ public void ignore(IMessage.Kind kind) {
+ }
+
+ public boolean handleMessage(IMessage message) {
+ (message.isFailed() ? failures : passes).add(message);
+ return true;
+ }
+ }
+}
+// /**
+// * @see ReporterI#abortWithFailure(String, Throwable)
+// */
+// public void abortWithFailure(String message, Throwable exception) {
+// if (null == exception) {
+// check(message, true);
+// } else {
+// String s = message + Util.unqualifiedClassName(exception)
+// + ": " + exception.getMessage();
+// check(s, false);
+// }
+// }
+//
+// /**
+// * @see ReporterI#check(String, boolean)
+// */
+// public boolean check(String message, boolean passed) {
+// (!passed ? failures : passes).add(message);
+// return passed;
+// }
+//
+
diff --git a/testing-client/src/test/java/org/aspectj/testing/TestingClientModuleTests.java b/testing-client/src/test/java/org/aspectj/testing/TestingClientModuleTests.java
new file mode 100644
index 000000000..b5dfd039c
--- /dev/null
+++ b/testing-client/src/test/java/org/aspectj/testing/TestingClientModuleTests.java
@@ -0,0 +1,30 @@
+package org.aspectj.testing;
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+// default package
+
+import junit.framework.*;
+
+public class TestingClientModuleTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TestingClientModuleTests.class.getName());
+ suite.addTest(TestingTests.suite());
+ return suite;
+ }
+
+ public TestingClientModuleTests(String name) { super(name); }
+
+}
diff --git a/testing-client/src/test/java/org/aspectj/testing/TestingTests.java b/testing-client/src/test/java/org/aspectj/testing/TestingTests.java
new file mode 100644
index 000000000..ea5e7ee14
--- /dev/null
+++ b/testing-client/src/test/java/org/aspectj/testing/TestingTests.java
@@ -0,0 +1,35 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.testing;
+
+import org.aspectj.testing.server.TestServerTest;
+
+import junit.framework.*;
+
+public class TestingTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TestingTests.class.getName());
+ // for now, do not include SuiteTest because it would take 15 minutes
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TesterTest.class);
+ suite.addTestSuite(TestServerTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+ public TestingTests(String name) { super(name); }
+
+}
diff --git a/testing-client/src/test/java/org/aspectj/testing/server/TestServerTest.java b/testing-client/src/test/java/org/aspectj/testing/server/TestServerTest.java
new file mode 100644
index 000000000..0c278588e
--- /dev/null
+++ b/testing-client/src/test/java/org/aspectj/testing/server/TestServerTest.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.testing.server;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+public class TestServerTest extends TestCase {
+
+ private TestServer server;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ server = new TestServer();
+ server.setExitOntError(false);
+ }
+
+ public void testInitialize() {
+ try {
+ server.setWorkingDirectory("../testing-client/testdata");
+ server.initialize();
+ }
+ catch (IOException ex) {
+ fail(ex.toString());
+ }
+ }
+
+ public void testSetWorkingDirectory() {
+ server.setWorkingDirectory("../testing-client/testdata");
+ }
+}