/** * Creates a new <code>FailedProperties40</code> instance. Since * Derby doesn't support any properties, all the keys from the * <code>props</code> parameter are added to the * <code>failedProps_</code> member with value * REASON_UNKNOWN_PROPERTY. * * @param props a <code>Properties</code> value. Can be null or empty */ public FailedProperties40(Properties props) { if (props == null || props.isEmpty()) { firstKey_ = null; firstValue_ = null; return; } Enumeration e = props.keys(); firstKey_ = (String)e.nextElement(); firstValue_ = props.getProperty(firstKey_); failedProps_.put(firstKey_, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); while (e.hasMoreElements()) { failedProps_.put((String)e.nextElement(), ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } }
/** * <code>setClientInfo</code> will throw a <code>SQLClientInfoException</code> * uless the <code>properties</code> paramenter is empty, since GemFireXD does * not support any properties. */ @Override public void setClientInfo(Properties properties) throws SQLClientInfoException { if (properties != null && !properties.isEmpty()) { HashMap<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(properties.size()); String firstKey = null; for (String key : properties.stringPropertyNames()) { if (firstKey == null) { firstKey = key; } failedProperties.put(key, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } throw ThriftExceptionUtil.newSQLClientInfoException( SQLState.PROPERTY_UNSUPPORTED_CHANGE, failedProperties, null, firstKey, properties.getProperty(firstKey)); } }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(Map<String,ClientInfoStatus>) */ public void test_Constructor_LMap() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( failedProperties); assertNull("The SQLState of SQLClientInfoException should be null", sqlClientInfoException.getSQLState()); assertNull("The reason of SQLClientInfoException should be null", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(String,Map<String,ClientInfoStatus>) */ public void test_Constructor_LStringLMap() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", failedProperties); assertNull("The SQLState of SQLClientInfoException should be null", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException set and get should be equivalent", "Message", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(String,Map<String,ClientInfoStatus>,Throwable) */ public void test_Constructor_LStringLMapLThrowable() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", failedProperties, cause); assertNull("The SQLState of SQLClientInfoException should be null", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException set and get should be equivalent", "Message", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); assertEquals( "The cause of SQLClientInfoException set and get should be equivalent", cause, sqlClientInfoException.getCause()); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(String,String,Map<String,ClientInfoStatus>) */ public void test_Constructor_LStringLStringLMap() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", "State", failedProperties); assertEquals( "The SQLState of SQLClientInfoException set and get should be equivalent", "State", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException set and get should be equivalent", "Message", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(String,String,Map<String,ClientInfoStatus>,Throwable) */ public void test_Constructor_LStringLStringLMapLThrowable() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", "State", failedProperties, cause); assertEquals( "The SQLState of SQLClientInfoException set and get should be equivalent", "State", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException set and get should be equivalent", "Message", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); assertEquals( "The cause of SQLClientInfoException set and get should be equivalent", cause, sqlClientInfoException.getCause()); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(String,String,int,Map<String,ClientInfoStatus>,Throwable) */ public void test_Constructor_LStringLStringILMapLThrowable() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", "State", 1, failedProperties, cause); assertEquals( "The SQLState of SQLClientInfoException set and get should be equivalent", "State", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException set and get should be equivalent", "Message", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 1", sqlClientInfoException.getErrorCode(), 1); assertEquals( "The cause of SQLClientInfoException set and get should be equivalent", cause, sqlClientInfoException.getCause()); }
public void setClientInfo(String name, String value) throws SQLClientInfoException { try { validate(); } catch (SQLException e) { throw new SQLClientInfoException(e.getMessage(), e.getSQLState(), e.getErrorCode(), (Map<String, ClientInfoStatus>) null, e); } this.getConnection().setClientInfo(name, value); }
public void setClientInfo( Properties properties) throws SQLClientInfoException { try { validate(); } catch (SQLException e) { throw new SQLClientInfoException(e.getMessage(), e.getSQLState(), e.getErrorCode(), (Map<String, ClientInfoStatus>) null, e); } this.getConnection().setClientInfo(properties); }
public static SQLClientInfoException newSQLClientInfoException( String sqlState, Map<String, ClientInfoStatus> failedProperties, Throwable t, Object... args) { return new SQLClientInfoException(getMessageUtil().getCompleteMessage( sqlState, args), getSQLStateFromIdentifier(sqlState), getSeverityFromIdentifier(sqlState), failedProperties, t); }
/** * <code>setClientInfo</code> will always throw a * <code>SQLClientInfoException</code> since GemFireXD does not support any * properties. */ @Override public void setClientInfo(String name, String value) throws SQLClientInfoException { if (name != null || value != null) { HashMap<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(1); if (name != null) { failedProperties.put(name, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } throw ThriftExceptionUtil.newSQLClientInfoException( SQLState.PROPERTY_UNSUPPORTED_CHANGE, failedProperties, null, name, value); } }
public void setClientInfo(Properties properties) throws SQLClientInfoException { if (properties == null || properties.size() == 0) return; Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); Iterator<String> i = properties.stringPropertyNames().iterator(); while (i.hasNext()) { failures.put(i.next(), ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } throw new SQLClientInfoException("ClientInfo property not supported.", failures); }
@Override public void setClientInfo(Properties properties) throws SQLClientInfoException { if (disabled) throw new SQLClientInfoException("This connection is disabled", new HashMap<String, ClientInfoStatus>()); con.setClientInfo(properties); }
/** * @tests java.sql.SQLClientInfoException#SQLClientInfoException(Map<String,ClientInfoStatus>,Throwable) */ public void test_Constructor_LMapLThrowable() { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( failedProperties, cause); assertNull("The SQLState of SQLClientInfoException should be null", sqlClientInfoException.getSQLState()); assertEquals( "The reason of SQLClientInfoException should be equals to cause.toString()", "java.lang.RuntimeException: Message", sqlClientInfoException .getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); assertEquals( "The cause of SQLClientInfoException set and get should be equivalent", cause, sqlClientInfoException.getCause()); sqlClientInfoException = new SQLClientInfoException(failedProperties, null); assertNull("The SQLState of SQLClientInfoException should be null", sqlClientInfoException.getSQLState()); assertNull("The reason of SQLClientInfoException should be null", sqlClientInfoException.getMessage()); assertEquals( "The FailedProperties of SQLClientInfoException set and get should be equivalent", failedProperties, sqlClientInfoException.getFailedProperties()); assertEquals("The error code of SQLClientInfoException should be 0", sqlClientInfoException.getErrorCode(), 0); }
/** * @tests serialization/deserialization. */ public void testSerializationSelf() throws Exception { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SQLClientInfoException sqlClientInfoException = new SQLClientInfoException( "Message", "State", 1, failedProperties, cause); SerializationTest.verifySelf(sqlClientInfoException, exComparator); }
/** * @tests serialization/deserialization compatibility with RI. */ public void testSerializationCompatibility() throws Exception { Map<String, ClientInfoStatus> failedProperties = new HashMap<String, ClientInfoStatus>(); failedProperties.put("String1", ClientInfoStatus.REASON_VALUE_INVALID); failedProperties .put("String2", ClientInfoStatus.REASON_VALUE_TRUNCATED); Throwable cause = new RuntimeException("Message"); SerializationTest.verifyGolden(this, new SQLClientInfoException( "Message", "State", 1, failedProperties, cause), exComparator); }
public SQLClientInfoExceptionTests() { map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY); map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY); }
public void setClientInfo(String name, String value) throws SQLClientInfoException { Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); failures.put(name, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); throw new SQLClientInfoException("ClientInfo property not supported.", failures); }
@Override public void setClientInfo(String name, String value) throws SQLClientInfoException { if (disabled) throw new SQLClientInfoException("This connection is disabled", new HashMap<String, ClientInfoStatus>()); con.setClientInfo(name, value); }
/** * Creates a {@code SQLClientInfoException} for the specified {@code number} * and the specified {@code parameter}. * * @param number * the number of the exception to be created * @param parameter * the parameters to be replaced within the exception * * @return the created exception */ public static SQLClientInfoException createClientInfoException( final int number, final String... parameter) { final String msg = "[" + number + "] " + createMessage(number, parameter); return new SQLClientInfoException(msg, null, number, Collections.<String, ClientInfoStatus> emptyMap()); }
/** * <code>getProperties</code> provides a * <code>Map<String,ClientInfoStatus></code> object describing the * failed properties (as specified in the javadoc for * java.sql.SQLClientInfoException). * * @return a <code>Map<String,ClientInfoStatus></code> object with * the failed property keys and the reason why each failed */ public Map<String,ClientInfoStatus> getProperties() { return failedProps_; }