Skip to content

Commit 1b78916

Browse files
committed
#901 Fixed: FBServiceManager.getAuthPlugins() reported the dbCryptConfig value
+ Add test to verify property get/set pairs
1 parent af2f08b commit 1b78916

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

src/main/org/firebirdsql/management/FBServiceManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void setDbCryptConfig(String dbCryptConfig) {
199199

200200
@Override
201201
public String getAuthPlugins() {
202-
return ServiceManager.super.getDbCryptConfig();
202+
return ServiceManager.super.getAuthPlugins();
203203
}
204204

205205
@Override

src/test/org/firebirdsql/management/FBServiceManagerTest.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44

55
import org.firebirdsql.common.FBTestProperties;
66
import org.firebirdsql.gds.impl.GDSServerVersion;
7+
import org.firebirdsql.gds.ng.WireCrypt;
78
import org.firebirdsql.jaybird.props.PropertyConstants;
89
import org.firebirdsql.jaybird.props.PropertyNames;
910
import org.firebirdsql.util.FirebirdSupportInfo;
1011
import org.junit.jupiter.params.ParameterizedTest;
1112
import org.junit.jupiter.params.provider.Arguments;
1213
import org.junit.jupiter.params.provider.MethodSource;
1314

15+
import java.beans.BeanInfo;
16+
import java.beans.IntrospectionException;
17+
import java.beans.Introspector;
18+
import java.beans.PropertyDescriptor;
19+
import java.lang.reflect.Method;
1420
import java.util.ArrayList;
1521
import java.util.List;
1622
import java.util.Locale;
23+
import java.util.Set;
1724
import java.util.stream.Stream;
1825

1926
import static org.firebirdsql.common.FBTestProperties.DB_SERVER_PORT;
2027
import static org.firebirdsql.common.FBTestProperties.DB_SERVER_URL;
21-
import static org.firebirdsql.common.FBTestProperties.ENABLE_PROTOCOL;
2228
import static org.firebirdsql.common.FBTestProperties.GDS_TYPE;
2329
import static org.firebirdsql.common.FBTestProperties.configureServiceManager;
2430
import static org.firebirdsql.common.FBTestProperties.getDefaultSupportInfo;
@@ -31,6 +37,7 @@
3137
import static org.hamcrest.core.IsEqual.equalTo;
3238
import static org.hamcrest.core.IsNot.not;
3339
import static org.hamcrest.core.IsNull.notNullValue;
40+
import static org.junit.jupiter.api.Assertions.assertEquals;
3441

3542
/**
3643
* Tests for {@link org.firebirdsql.management.FBServiceManager}.
@@ -139,4 +146,44 @@ static Stream<Arguments> testGetServerVersion() {
139146
private static boolean isWindowsSystem() {
140147
return System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win");
141148
}
149+
150+
@ParameterizedTest
151+
@MethodSource
152+
void testBeanProperties(PropertyDescriptor beanProperty) throws Exception {
153+
var serviceManager = new FBServiceManager(FBTestProperties.getGdsType());
154+
Method readMethod = beanProperty.getReadMethod();
155+
final Object originalValue = readMethod.invoke(serviceManager);
156+
157+
final Object testValue = generateTestValue(beanProperty, originalValue);
158+
Method writeMethod = beanProperty.getWriteMethod();
159+
writeMethod.invoke(serviceManager, testValue);
160+
161+
assertEquals(testValue, readMethod.invoke(serviceManager),
162+
"Unexpected value read back from property " + beanProperty.getName());
163+
}
164+
165+
static Stream<Arguments> testBeanProperties() throws IntrospectionException {
166+
final var excludedProperties = Set.of("type", "logger", "serverVersion");
167+
BeanInfo serviceManagerBeanInfo = Introspector.getBeanInfo(FBServiceManager.class, Object.class);
168+
return Stream.of(serviceManagerBeanInfo.getPropertyDescriptors())
169+
.filter(property -> !excludedProperties.contains(property.getName()))
170+
.map(Arguments::of);
171+
}
172+
173+
private static Object generateTestValue(PropertyDescriptor beanProperty, Object originalValue) {
174+
String propertyName = beanProperty.getName();
175+
if ("wireCrypt".equals(propertyName)) {
176+
return "ENABLED".equals(originalValue) ? "DISABLED" : "ENABLED";
177+
}
178+
return switch (beanProperty.getPropertyType().getName()) {
179+
case "java.lang.String" -> "testValue " + propertyName;
180+
case "boolean", "java.lang.Boolean" -> originalValue == null || !((boolean) originalValue);
181+
case "int", "java.lang.Integer" -> originalValue == null ? 1 : ((int) originalValue) + 1;
182+
case "org.firebirdsql.gds.ng.WireCrypt" ->
183+
originalValue == WireCrypt.ENABLED ? WireCrypt.DISABLED : WireCrypt.ENABLED;
184+
default -> throw new IllegalStateException("Property: %s has unsupported type: %s"
185+
.formatted(propertyName, beanProperty.getPropertyType()));
186+
};
187+
}
188+
142189
}

0 commit comments

Comments
 (0)