Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2011-10-21 21:13:59 -0400
committerRoberto E. Escobar2011-10-21 21:13:59 -0400
commitf45d8c0ce30df5da8c1fccf21fbe43d4d5638245 (patch)
treea73467876d8d2420c941996120b748190233c5e9 /plugins/org.eclipse.osee.executor.admin.test
parent4faaa5303f2e761ce00150174c8251e39c113fc3 (diff)
downloadorg.eclipse.osee-f45d8c0ce30df5da8c1fccf21fbe43d4d5638245.tar.gz
org.eclipse.osee-f45d8c0ce30df5da8c1fccf21fbe43d4d5638245.tar.xz
org.eclipse.osee-f45d8c0ce30df5da8c1fccf21fbe43d4d5638245.zip
feature[ats_Q9NLC]: Create executor admin
Diffstat (limited to 'plugins/org.eclipse.osee.executor.admin.test')
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/.project28
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/build.properties5
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/pom.xml30
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/ExecutorAdminTestSuite.java21
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminIternalTestSuite.java20
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java67
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockEventService.java62
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockLog.java105
10 files changed, 356 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.executor.admin.test/.classpath b/plugins/org.eclipse.osee.executor.admin.test/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.executor.admin.test/.project b/plugins/org.eclipse.osee.executor.admin.test/.project
new file mode 100644
index 0000000000..c6f815a299
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.executor.admin.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.executor.admin.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.executor.admin.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7abc66e61b
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Executor Admin Test (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.executor.admin.test
+Bundle-Version: 0.9.9.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Fragment-Host: org.eclipse.osee.executor.admin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.junit;version="4.8.2",
+ org.junit.runner;version="4.8.2",
+ org.junit.runners;version="4.8.2"
diff --git a/plugins/org.eclipse.osee.executor.admin.test/build.properties b/plugins/org.eclipse.osee.executor.admin.test/build.properties
new file mode 100644
index 0000000000..5b9d2918ff
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
+additional.bundles = org.junit
diff --git a/plugins/org.eclipse.osee.executor.admin.test/pom.xml b/plugins/org.eclipse.osee.executor.admin.test/pom.xml
new file mode 100644
index 0000000000..4eda239164
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/pom.xml
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.x.server.parent</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.server.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.executor.admin.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE Executor Admin Test - (Incubation)</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <testSuite>org.eclipse.osee.executor.admin.test</testSuite>
+ <testClass>org.eclipse.osee.executor.admin.ExecutorAdminTestSuite</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/ExecutorAdminTestSuite.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/ExecutorAdminTestSuite.java
new file mode 100644
index 0000000000..bf2c100d1b
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/ExecutorAdminTestSuite.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.executor.admin;
+
+import org.eclipse.osee.executor.admin.internal.ExecutorAdminIternalTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ExecutorAdminIternalTestSuite.class})
+public class ExecutorAdminTestSuite {
+ //
+}
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminIternalTestSuite.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminIternalTestSuite.java
new file mode 100644
index 0000000000..5569d96927
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminIternalTestSuite.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.executor.admin.internal;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ExecutorAdminTest.class})
+public class ExecutorAdminIternalTestSuite {
+ //
+}
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java
new file mode 100644
index 0000000000..65011395d5
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.executor.admin.internal;
+
+import java.util.HashMap;
+import java.util.concurrent.ExecutorService;
+import org.eclipse.osee.executor.admin.mock.MockEventService;
+import org.eclipse.osee.executor.admin.mock.MockLog;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ExecutorAdminTest {
+
+ @Test(expected = IllegalStateException.class)
+ public void testInitializationGuard() throws Exception {
+ ExecutorAdminImpl admin = new ExecutorAdminImpl();
+ admin.getDefaultExecutor();
+ }
+
+ @Test
+ public void testGetService() throws Exception {
+ ExecutorAdminImpl admin = new ExecutorAdminImpl();
+ admin.setLogger(new MockLog());
+ admin.setEventService(new MockEventService());
+ admin.start(new HashMap<String, Object>());
+
+ ExecutorService defaultService = admin.getDefaultExecutor();
+ Assert.assertNotNull(defaultService);
+
+ ExecutorService serviceByName = admin.getExecutor("default.executor");
+ Assert.assertNotNull(serviceByName);
+ Assert.assertEquals(serviceByName, defaultService);
+
+ ExecutorService anotherExecutor = admin.getExecutor("hello");
+ Assert.assertNotNull(anotherExecutor);
+ Assert.assertTrue(!anotherExecutor.equals(defaultService));
+ }
+
+ @Test
+ public void testTerminateExecutorService() throws Exception {
+ ExecutorAdminImpl admin = new ExecutorAdminImpl();
+ admin.setLogger(new MockLog());
+ admin.setEventService(new MockEventService());
+ admin.start(new HashMap<String, Object>());
+
+ ExecutorService anotherExecutor = admin.getExecutor("hello");
+ Assert.assertNotNull(anotherExecutor);
+
+ ExecutorService second = admin.getExecutor("hello");
+ Assert.assertEquals(anotherExecutor, second);
+
+ second.shutdown();
+ ExecutorService third = admin.getExecutor("hello");
+ Assert.assertFalse(third.equals(second));
+ }
+}
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockEventService.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockEventService.java
new file mode 100644
index 0000000000..edb8fa8b69
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockEventService.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.executor.admin.mock;
+
+import java.util.Map;
+import org.eclipse.osee.event.EventService;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockEventService implements EventService {
+
+ private String topic;
+ private Map<String, ?> data;
+ private int postEvent;
+ private int sendEvent;
+
+ @Override
+ public void postEvent(String topic, Map<String, ?> data) {
+ this.topic = topic;
+ this.data = data;
+ postEvent++;
+ }
+
+ @Override
+ public void sendEvent(String topic, Map<String, ?> data) {
+ this.topic = topic;
+ this.data = data;
+ sendEvent++;
+ }
+
+ public void reset() {
+ this.topic = null;
+ this.data = null;
+ postEvent = 0;
+ sendEvent = 0;
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public Map<String, ?> getData() {
+ return data;
+ }
+
+ public int getPostEventCount() {
+ return postEvent;
+ }
+
+ public int getSendEventCount() {
+ return sendEvent;
+ }
+}
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockLog.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockLog.java
new file mode 100644
index 0000000000..7588b181b5
--- /dev/null
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockLog.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.executor.admin.mock;
+
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class MockLog implements Log {
+
+ @Override
+ public boolean isTraceEnabled() {
+ return true;
+ }
+
+ @Override
+ public void trace(String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public void trace(Throwable th, String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return true;
+ }
+
+ @Override
+ public void debug(String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public void debug(Throwable th, String format, Object... args) {
+ commonOut(th, format, args);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return true;
+ }
+
+ @Override
+ public void info(String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public void info(Throwable th, String format, Object... args) {
+ commonOut(th, format, args);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public void warn(String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public void warn(Throwable th, String format, Object... args) {
+ commonOut(th, format, args);
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public void error(String format, Object... args) {
+ commonOut(format, args);
+ }
+
+ @Override
+ public void error(Throwable th, String format, Object... args) {
+ commonOut(th, format, args);
+ }
+
+ private void commonOut(String format, Object... args) {
+ System.out.printf(format, args);
+ System.out.println();
+ }
+
+ private void commonOut(Throwable th, String format, Object... args) {
+ commonOut(format, args);
+ th.printStackTrace();
+ }
+
+}

Back to the top