diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-11-23 23:05:25 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-11-23 23:05:25 +0100 |
commit | ff2be3919b07bb27e5454edd0083d6fe61d1c67a (patch) | |
tree | cfe8c6dc5dc53b6a446082d17a10b75b0de2cee7 /sonar-core/src | |
parent | cac9a98f58d1a20026755c0131238bbe2c64f632 (diff) | |
download | sonarqube-ff2be3919b07bb27e5454edd0083d6fe61d1c67a.tar.gz sonarqube-ff2be3919b07bb27e5454edd0083d6fe61d1c67a.zip |
SONAR-5801 fix compatibility with all dbs
Diffstat (limited to 'sonar-core/src')
5 files changed, 20 insertions, 22 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java index 87452635ede..3659ff20569 100644 --- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java +++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java @@ -19,11 +19,8 @@ */ package org.sonar.core.source.db; -import com.google.common.base.Charsets; - import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.Date; public class FileSourceDto { @@ -32,7 +29,7 @@ public class FileSourceDto { private String fileUuid; private Date createdAt; private Date updatedAt; - private byte[] data; + private String data; private String dataHash; public Long getId() { @@ -63,24 +60,15 @@ public class FileSourceDto { } @CheckForNull - public byte[] getData() { + public String getData() { return data; } - @CheckForNull - public String getStringData() { - return data != null ? new String(data, Charsets.UTF_8) : null; - } - - public FileSourceDto setData(@Nullable byte[] data) { + public FileSourceDto setData(@Nullable String data) { this.data = data; return this; } - public FileSourceDto setStringData(@Nullable String data) { - return setData(data != null ? data.getBytes(Charsets.UTF_8) : null); - } - public String getDataHash() { return dataHash; } diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java index 0bae030da9f..04c3ec923b5 100644 --- a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java @@ -41,7 +41,7 @@ public class FileSourceDaoTest extends AbstractDaoTestCase { public void select() throws Exception { FileSourceDto fileSourceDto = dao.select("ab12"); - assertThat(fileSourceDto.getStringData()).isEqualTo("public class Foo {public Foo(){}}"); + assertThat(fileSourceDto.getData()).isEqualTo("aef12a,alice,2014-04-25T12:34:56+0100,,class Foo"); assertThat(fileSourceDto.getDataHash()).isEqualTo("hash"); assertThat(fileSourceDto.getProjectUuid()).isEqualTo("abcd"); assertThat(fileSourceDto.getFileUuid()).isEqualTo("ab12"); @@ -51,7 +51,7 @@ public class FileSourceDaoTest extends AbstractDaoTestCase { @Test public void insert() throws Exception { - dao.insert(new FileSourceDto().setProjectUuid("prj").setFileUuid("file").setStringData("bla bla").setDataHash("hash2") + dao.insert(new FileSourceDto().setProjectUuid("prj").setFileUuid("file").setData("bla bla").setDataHash("hash2") .setCreatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")) .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100"))); @@ -60,7 +60,7 @@ public class FileSourceDaoTest extends AbstractDaoTestCase { @Test public void update() throws Exception { - dao.update(new FileSourceDto().setId(101L).setProjectUuid("prj").setFileUuid("file").setStringData("bla bla").setDataHash("hash2") + dao.update(new FileSourceDto().setId(101L).setProjectUuid("prj").setFileUuid("file").setData("updated data").setDataHash("hash2") .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100"))); checkTable("update", "file_sources"); diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml index 0f06cc6efea..caa220868f4 100644 --- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml @@ -1,7 +1,12 @@ <dataset> - <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="7075626c696320636c61737320466f6f207b7075626c696320466f6f28297b7d7d" data_hash="hash" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" /> + <file_sources id="101" project_uuid="abcd" file_uuid="ab12" + data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash" + created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" /> - <file_sources id="102" project_uuid="prj" file_uuid="file" data="626c6120626c61" data_hash="hash2" created_at="2014-10-31 16:44:02.000" updated_at="2014-10-31 16:44:02.000" /> + + <file_sources id="102" project_uuid="prj" file_uuid="file" + data="bla bla" data_hash="hash2" + created_at="2014-10-31 16:44:02.000" updated_at="2014-10-31 16:44:02.000" /> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml index 19b2dec6896..080676c67f2 100644 --- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml @@ -1,5 +1,7 @@ <dataset> - <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="7075626c696320636c61737320466f6f207b7075626c696320466f6f28297b7d7d" data_hash="hash" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" /> + <file_sources id="101" project_uuid="abcd" file_uuid="ab12" + data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash" + created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" /> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml index 15e6bf6c0dc..aee5ffcf405 100644 --- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml @@ -1,5 +1,8 @@ <dataset> - <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="626c6120626c61" data_hash="hash2" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-31 16:44:02.000" /> + <file_sources id="101" project_uuid="abcd" file_uuid="ab12" + data="updated data" data_hash="hash2" + created_at="2014-10-29 16:44:02.000" updated_at="2014-10-31 16:44:02.000" /> + </dataset> |