You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2018/05/18 11:03:24 UTC
svn commit: r1831849 - in
/uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper:
./ JUnitServiceWrapperTestSuite.java
Author: cwiklik
Date: Fri May 18 11:03:24 2018
New Revision: 1831849
URL: http://svn.apache.org/viewvc?rev=1831849&view=rev
Log:
UIMA-5756 added test suite to test service state changes
Added:
uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/
uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/JUnitServiceWrapperTestSuite.java
Added: uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/JUnitServiceWrapperTestSuite.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/JUnitServiceWrapperTestSuite.java?rev=1831849&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/JUnitServiceWrapperTestSuite.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-pullservice/src/test/java/org/apache/uima/ducc/ps/service/wrapper/JUnitServiceWrapperTestSuite.java Fri May 18 11:03:24 2018
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.uima.ducc.ps.service.wrapper;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.uima.ducc.ph.Client;
+import org.apache.uima.ducc.ph.StateMonitor;
+import org.apache.uima.ducc.ps.service.errors.ServiceInitializationException;
+import org.apache.uima.ducc.ps.service.main.ServiceWrapper;
+import org.junit.Test;
+
+public class JUnitServiceWrapperTestSuite extends Client {
+
+ @Test
+ public void testPullServiceWrapper() throws Exception {
+ //int scaleout = 2;
+ StateMonitor monitor = new StateMonitor();
+ monitor.start();
+ System.out.println("........... Monitor Port:"+System.getProperty("DUCC_STATE_UPDATE_PORT"));
+ super.startJetty(false); // don't block
+ String analysisEngineDescriptor = "TestAAE";
+
+ String tasURL = "http://localhost:8080/test";
+ try {
+ System.setProperty("ducc.deploy.JdURL", tasURL);
+ System.setProperty("ducc.deploy.JpThreadCount","4");
+ System.setProperty("ducc.deploy.service.type", "NotesService");
+ System.getProperty("ducc.deploy.JpType", "uima");
+
+ ServiceWrapper service = new ServiceWrapper();
+
+ Timer fTimer = new Timer("testPullService Timer");
+ // after 5secs stop the pull service
+ fTimer.schedule(new MyTimerTask(service, fTimer), 5000);
+
+ service.initialize(new String[] {analysisEngineDescriptor});
+
+ service.start();
+
+
+ } catch (ServiceInitializationException e) {
+ throw e;
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ monitor.stop();
+
+ }
+ }
+ class MyTimerTask extends TimerTask {
+ final ServiceWrapper service;
+ final Timer fTimer;
+ MyTimerTask(ServiceWrapper service, Timer fTimer) {
+ this.service = service;
+ this.fTimer = fTimer;
+ }
+
+ @Override
+
+ public void run() {
+ this.cancel();
+ fTimer.purge();
+ fTimer.cancel();
+ System.out.println("Timmer popped - stopping service");
+ service.stop();
+
+ }
+
+
+
+ }
+
+}