-
Notifications
You must be signed in to change notification settings - Fork 9
Add ability to record spy; add type handling for record and replay #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…nor clean-up as well.
| ### Building | ||
|
|
||
| To build the project simply run | ||
| Works on JDK1.8. To build the project simply run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Various conflicts on higher versions of java
| */ | ||
| public class JdbcServiceVirtualizationFactory implements P6Factory { | ||
|
|
||
| @Getter @Setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw lombok was being used some places, so tidied up and started using it more.
| protected Object interceptPreparedStatementExecution(PreparedStatementInformation preparedStatementInformation, Object underlying, Method method, Object[] args) { | ||
| CloseableHttpClient httpclient = HttpClients.createDefault(); | ||
|
|
||
| HttpPost httpPost = prepareHttpCall(preparedStatementInformation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this is just refactoring so others can extend. When I made my changes originally, I had to copy/paste source files to get it to work, so in case others want to extend more easily.
| protected Object callUnderlyingMethod(Object underlying, Method method, Object[] args, PreparedStatementInformation preparedStatementInformation) { | ||
| Object actualResult = method.invoke(underlying, args); | ||
|
|
||
| if (recorder != null && actualResult instanceof ResultSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not recording anything for updates as didn't have the use case
| final List<String> colNames; | ||
| final Map<String, String> namedValues; | ||
| final String[] positionalValues; | ||
| final Map<String, Object> namedValues; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to migrate to Object type, but this doesn't change the behaviour for Strings
| } | ||
| else { | ||
| String type = col.getAttributeValue("type", nsXsi); | ||
| if (type != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaviour is on by default, which seems safe since it will only happen if xs:type is in the xml.
| private int statementInTest = 0; | ||
|
|
||
| @SneakyThrows | ||
| protected String getSybaseXMLFromDBResult(ResultSet resultSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fairly hacky, but just wanted something that works. Probably can make it a ton easier to read the files, but will leave that for a later exercise (if ever)
| } | ||
|
|
||
| @SneakyThrows | ||
| public void writeOutMapping(JdbcServiceVirtualizationFactory.PreparedStatementInformation preparedStatementInformation, ResultSet resultSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some terrible and lazy templating, but I didn't want to bring in a dependency or anything. I expect others using this functionality will want to roll their own from scratch anyway.
| public class XmlTypeRegistry { | ||
|
|
||
| private static final List<XmlTypeInfo<?>> DEFAULT_TYPES = new ArrayList<>(); | ||
| static { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added the ones we were using for now. It's easy to extend when using, but it would also be easy to add more defaults if someone were so inclined.
| .orElse(null); | ||
| } | ||
|
|
||
| public Object parseValue(String xmlType, String val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are probably XML libraries for this, but I just went super simple.
|
Hi @eeichinger can I get a review on this? |
|
|
Hi @eeichinger , just another ping on this one :) |
See also Does the library support recording or persisting the result set ? #14