Author: veithen
Date: Sat Jun 11 08:35:24 2016
New Revision: 1747860

URL: http://svn.apache.org/viewvc?rev=1747860&view=rev
Log:
Call ConfigurationContext.terminate() after test execution. This should delete 
temporary files, but it doesn't, providing evidence for AXIS2-3919.

Added:
    
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java  
 (with props)
Modified:
    
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java

Added: 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java?rev=1747860&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java 
(added)
+++ 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java 
Sat Jun 11 08:35:24 2016
@@ -0,0 +1,56 @@
+/*
+ * 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.axis2;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.junit.rules.ExternalResource;
+
+public class Axis2Repo extends ExternalResource {
+    private final String location;
+    private ConfigurationContext configurationContext;
+
+    public Axis2Repo(String location) {
+        this.location = location;
+    }
+
+    public ConfigurationContext getConfigurationContext() {
+        return configurationContext;
+    }
+
+    public AxisConfiguration getAxisConfiguration() {
+        return configurationContext.getAxisConfiguration();
+    }
+
+    @Override
+    protected void before() throws Throwable {
+        configurationContext = ConfigurationContextFactory
+                .createConfigurationContextFromFileSystem(location, location + 
"/axis2.xml");
+    }
+
+    @Override
+    protected void after() {
+        try {
+            configurationContext.terminate();
+        } catch (AxisFault ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}

Propchange: 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/Axis2Repo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java?rev=1747860&r1=1747859&r2=1747860&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
 Sat Jun 11 08:35:24 2016
@@ -19,39 +19,46 @@
 
 package org.apache.axis2.deployment;
 
-import junit.framework.TestCase;
-import org.apache.axis2.AbstractTestCase;
+import org.apache.axis2.Axis2Repo;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.Phase;
 import org.apache.axis2.registry.Handler3;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
 
 import javax.xml.stream.XMLStreamException;
-import java.util.ArrayList;
-import java.util.List;
 
-public class DeploymentTotalTest extends TestCase {
-    AxisConfiguration axisConfig;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
 
-    protected void setUp() throws Exception {
-        String filename = AbstractTestCase.basedir + 
"/target/test-resources/deployment";
-        axisConfig = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(filename, filename + 
"/axis2.xml")
-                .getAxisConfiguration();
-        axisConfig.engageModule("module1");
+public class DeploymentTotalTest {
+    @Rule
+    public Axis2Repo repo = new Axis2Repo("target/test-resources/deployment");
+
+    @Before
+    public void setUp() throws Exception {
+        repo.getAxisConfiguration().engageModule("module1");
          // OK, no exceptions.  Now make sure we read the correct file...
     }
 
+    @Test
     public void testparseService1() throws AxisFault, XMLStreamException {
-        Parameter param = axisConfig.getParameter("FavoriteColor");
+        Parameter param = 
repo.getAxisConfiguration().getParameter("FavoriteColor");
         assertNotNull("No FavoriteColor parameter in axis2.xml!", param);
         assertEquals("purple", param.getValue());
     }
 
+    @Test
     public void testDynamicPhase() {
+        AxisConfiguration axisConfig = repo.getAxisConfiguration();
+
         List inFlow = axisConfig.getInFlowPhases();
         for (int i = 0; i < inFlow.size(); i++) {
             Phase phase = (Phase) inFlow.get(i);


Reply via email to