cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1204500 - in /cxf/trunk/rt/ws/rm/src: main/java/org/apache/cxf/ws/rm/persistence/jdbc/ test/java/org/apache/cxf/ws/rm/persistence/jdbc/
Date Mon, 21 Nov 2011 13:59:23 GMT
Author: ay
Date: Mon Nov 21 13:59:23 2011
New Revision: 1204500

URL: http://svn.apache.org/viewvc?rev=1204500&view=rev
Log:
[CXF-3921] makingRMTxStore's tabel-exists error state configurable

Added:
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml
  (with props)
Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1204500&r1=1204499&r2=1204500&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Mon Nov 21 13:59:23 2011
@@ -147,6 +147,9 @@ public class RMTxStore implements RMStor
     private String userName;
     private String password;
     
+    private String tableExistsState = DERBY_TABLE_EXISTS_STATE;
+    private int tableExistsCode = ORACLE_TABLE_EXISTS_CODE;
+    
     // configuration
     
     public void setDriverClassName(String dcn) {
@@ -181,6 +184,22 @@ public class RMTxStore implements RMStor
         return userName;
     }
     
+    public String getTableExistsState() {
+        return tableExistsState;
+    }
+
+    public void setTableExistsState(String tableExistsState) {
+        this.tableExistsState = tableExistsState;
+    }
+
+    public int getTableExistsCode() {
+        return tableExistsCode;
+    }
+
+    public void setTableExistsCode(int tableExistsCode) {
+        this.tableExistsCode = tableExistsCode;
+    }
+
     public void setConnection(Connection c) {
         connection = c;
     }
@@ -744,7 +763,8 @@ public class RMTxStore implements RMStor
     }
     
     protected boolean isTableExistsError(SQLException ex) {
-        return DERBY_TABLE_EXISTS_STATE.equals(ex.getSQLState())
-                || ORACLE_TABLE_EXISTS_CODE == ex.getErrorCode();
+        // we could be deriving the state/code from the driver url to avoid explicit setting
of them
+        return (null != tableExistsState && tableExistsState.equals(ex.getSQLState()))
+                || tableExistsCode == ex.getErrorCode();
     }
 }
\ No newline at end of file

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java?rev=1204500&r1=1204499&r2=1204500&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
(original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreConfigurationTest.java
Mon Nov 21 13:59:23 2011
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.ws.rm.persistence.jdbc;
 
+import java.sql.SQLException;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.ws.rm.RMManager;
@@ -46,4 +48,16 @@ public class RMTxStoreConfigurationTest 
         assertEquals("jdbc:derby://localhost:1527/rmdb;create=true", store.getUrl());
     }
    
+    @Test
+    public void testSetCustomTableExistsState() {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml");
+        RMManager manager = bus.getExtension(RMManager.class);
+        assertNotNull(manager);
+        RMTxStore store = (RMTxStore)manager.getStore();
+                
+        assertTrue(store.isTableExistsError(new SQLException("Table exists", "I6000", 288,
null)));
+        
+        assertFalse(store.isTableExistsError(new SQLException("Unknown error", "00000", -1,
null)));
+    }
 }

Added: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml?rev=1204500&view=auto
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml
(added)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml
Mon Nov 21 13:59:23 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:cxf-beans="http://cxf.apache.org/configuration/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"       
+       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+       xsi:schemaLocation="
+http://cxf.apache.org/ws/rm/manager http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd
+http://schemas.xmlsoap.org/ws/2005/02/rm/policy http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
+
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+   
+    <import resource="classpath:/org/apache/cxf/ws/rm/rmmanager.xml"/>  
+   
+    <wsrm-mgr:rmManager>
+        <wsrm-mgr:store>
+            <ref bean="testStore"/>
+        </wsrm-mgr:store>
+    </wsrm-mgr:rmManager>
+
+	<bean id="testStore" class="org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore">
+		<property name="userName" value="scott"/>
+		<property name="password" value="abc123"/>
+		<property name="driverClassName" value="org.apache.derby.jdbc.NoDriver"/>
+		<property name="url" value="jdbc:custom://localhost:1527/rmdb;create=true"/>
+	    <property name="tableExistsState" value="I6000"/>
+	</bean>
+
+</beans>

Propchange: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/txstore-custom-error-bean.xml
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message