[easytag/wip/musicbrainz-support-merge: 15/75] Added Test for MusicBrainz Search
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 15/75] Added Test for MusicBrainz Search
- Date: Sat, 30 Aug 2014 07:47:15 +0000 (UTC)
commit f69a087f9c40ada7e859d64583ad0cb5efa1a754
Author: Abhinav <abhijangda hotmail com>
Date: Sun Jun 15 15:22:19 2014 +0530
Added Test for MusicBrainz Search
Added "make test" in Makefile.am
Added tests cases for MusicBrainz search in test-musicbrainz.c
Added a test soup-server in test-musicbrainz_server.c
Added different xml files containing MusicBrainz retrieved data for server
Makefile.am | 34 +++
po/POTFILES.in | 1 +
src/mb_search.c | 25 ++-
src/mb_search.h | 2 +
tests/album-i_still_info.xml | 128 +++++++++
tests/album-never_gone.xml | 1 +
tests/album-never_gone_info.xml | 33 +++
tests/album-never_gone_recordings.xml | 41 +++
tests/artist-westlife.xml | 44 +++
tests/artist-westlife_release_info.xml | 1 +
tests/artist-westlife_releases.xml | 58 ++++
tests/discid.xml | 470 ++++++++++++++++++++++++++++++++
tests/error.xml | 1 +
tests/recordings-i_still.xml | 236 ++++++++++++++++
tests/test-musicbrainz.c | 153 +++++++++++
tests/test-musicbrainz_server.c | 245 +++++++++++++++++
16 files changed, 1466 insertions(+), 7 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 5b49365..a807319 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -416,6 +416,8 @@ test-report perf-report full-report: $(check_PROGRAMS)
check_PROGRAMS = \
tests/test-scan
+ tests/test-musicbrainz
+ tests/test-musicbrainz_server
tests_test_scan_CPPFLAGS = \
-I$(top_srcdir)/src \
@@ -433,6 +435,38 @@ tests_test_scan_SOURCES = \
tests_test_scan_LDADD = \
$(EASYTAG_LIBS)
+tests_test_musicbrainz_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir) \
+ $(DEPRECATED_CPPFLAGS)
+
+tests_test_musicbrainz_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(EASYTAG_CFLAGS)
+
+tests_test_musicbrainz_SOURCES = \
+ tests/test-musibrainz.c \
+ src/mb_search.c
+# src/musicbrainz_dialog.c
+
+tests_test_musicbrainz_LDADD = \
+ $(EASYTAG_LIBS)
+
+tests_test_musicbrainz_server_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir) \
+ $(DEPRECATED_CPPFLAGS)
+
+tests_test_musicbrainz_server_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(EASYTAG_CFLAGS)
+
+tests_test_musicbrainz_server_SOURCES = \
+ tests/test-musibrainz_server.c
+
+tests_test_musicbrainz_server_LDADD = \
+ $(EASYTAG_LIBS)
+
check_SCRIPTS = \
tests/test-desktop-file-validate.sh
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fd7bf25..18b2aff 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -47,3 +47,4 @@ src/tags/vcedit.c
src/tags/wavpack_header.c
src/tags/wavpack_tag.c
src/win32/win32dep.c
+src/musicbrainz_dialog.c
diff --git a/src/mb_search.c b/src/mb_search.c
index 03a5ae1..958bce7 100644
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -21,6 +21,9 @@
#include "mb_search.h"
#include "musicbrainz_dialog.h"
+static gchar *server = NULL;
+static int port = 0;
+
/*
* et_mb5_search_error_quark:
*
@@ -34,6 +37,18 @@ et_mb5_search_error_quark (void)
return g_quark_from_static_string ("et-mb5-search-error-quark");
}
+void
+et_musicbrainz_search_set_server_port (gchar *_server, int _port)
+{
+ if (server)
+ {
+ g_free (server);
+ }
+
+ server = g_strdup (_server);
+ port = _port;
+}
+
/*
* et_musicbrainz_search_in_entity:
* @child_type: Type of the children to get.
@@ -44,7 +59,7 @@ et_mb5_search_error_quark (void)
*
* To retrieve children entities of a parent entity.
*
- * Returns: TRUE if successfull, FALSE if not.
+ * Returns: TRUE if successful, FALSE if not.
*/
gboolean
et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
@@ -69,7 +84,7 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
}
param_names [0] = "inc";
- query = mb5_query_new ("easytag", NULL, 0);
+ query = mb5_query_new ("easytag", server, port);
if (child_type == MB_ENTITY_TYPE_ALBUM &&
parent_type == MB_ENTITY_TYPE_ARTIST)
@@ -128,10 +143,6 @@ et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
g_assert (error == NULL || *error != NULL);
return FALSE;
}
- else
- {
- printf ("not cancelled\n");
- }
size = mb5_release_get_title ((Mb5Release)release, buf,
sizeof (buf));
@@ -336,7 +347,7 @@ et_musicbrainz_search (gchar *string, enum MB_ENTITY_TYPE type, GNode *root,
param_names [0] = "query";
param_names [1] = "limit";
param_values [1] = SEARCH_LIMIT_STR;
- query = mb5_query_new ("easytag", NULL, 0);
+ query = mb5_query_new ("easytag", server, port);
if (g_cancellable_is_cancelled (cancellable))
{
diff --git a/src/mb_search.h b/src/mb_search.h
index a69b30e..2e0ef49 100644
--- a/src/mb_search.h
+++ b/src/mb_search.h
@@ -86,6 +86,8 @@ typedef struct
* Prototypes *
**************/
+void
+et_musicbrainz_search_set_server_port (gchar *server, int port);
gboolean
et_musicbrainz_search_in_entity (enum MB_ENTITY_TYPE child_type,
enum MB_ENTITY_TYPE parent_type,
diff --git a/tests/album-i_still_info.xml b/tests/album-i_still_info.xml
new file mode 100644
index 0000000..d1f55f4
--- /dev/null
+++ b/tests/album-i_still_info.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata>
+<recording id="ddc5fc5c-8a83-4d20-a711-313797030da6">
+<title>I Still...</title>
+<length>229000</length>
+<artist-credit>
+<name-credit>
+<artist id="2f569e60-0a1b-4fb9-95a4-3dc1525d1aad">
+<name>Backstreet Boys</name>
+<sort-name>Backstreet Boys</sort-name>
+</artist>
+</name-credit>
+</artist-credit>
+<release-list count="5">
+<release id="8403e2ec-f09e-43c7-997b-1e650cae139a">
+<title>Now That's What I Call Music! 42</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>2006</date>
+<country>ZA</country>
+<release-event-list count="1">
+<release-event>
+<date>2006</date>
+<area id="50cc7852-862e-30ae-aa82-385fe7135b7f">
+<name>South Africa</name>
+<sort-name>South Africa</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>ZA</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>6007124463630</barcode>
+</release>
+<release id="9d3942e9-45a7-4958-8df0-8065b4a14880">
+<title>Absolute Hits 2006</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>mul</language>
+<script>Latn</script>
+</text-representation>
+<date>2006-11-15</date>
+<country>SE</country>
+<release-event-list count="1">
+<release-event>
+<date>2006-11-15</date>
+<area id="23d10872-f5ae-3f0c-bf55-332788a16ecb">
+<name>Sweden</name>
+<sort-name>Sweden</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>SE</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>0094638008323</barcode>
+</release>
+<release id="a3e87183-5536-35a4-ad96-1925d73360aa">
+<title>Never Gone</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>2005</date>
+<country>CA</country>
+<release-event-list count="1">
+<release-event>
+<date>2005</date>
+<area id="71bbafaa-e825-3e15-8ca9-017dcad1748b">
+<name>Canada</name>
+<sort-name>Canada</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>CA</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>828766961126</barcode>
+</release>
+<release id="f278b617-b8f6-4b4e-bcd9-cf0af410d2d9">
+<title>Never Gone</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>2005</date>
+<country>JP</country>
+<release-event-list count="1">
+<release-event>
+<date>2005</date>
+<area id="2db42837-c832-3c27-b4a3-08198f75693c">
+<name>Japan</name>
+<sort-name>Japan</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>JP</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+</release>
+<release id="fd77296e-86f0-436e-8ea2-b657151f2167">
+<title>Never Gone</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>2005</date>
+<release-event-list count="1">
+<release-event>
+<date>2005</date>
+</release-event>
+</release-event-list>
+<barcode>828767589626</barcode>
+</release>
+</release-list>
+</recording>
+</metadata>
diff --git a/tests/album-never_gone.xml b/tests/album-never_gone.xml
new file mode 100644
index 0000000..aa08d39
--- /dev/null
+++ b/tests/album-never_gone.xml
@@ -0,0 +1 @@
+<?xml version="1.0" standalone="yes"?><metadata created="2014-06-14T09:40:02.821Z"
xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0"><release-list
count="4074" offset="0"><release id="fd77296e-86f0-436e-8ea2-b657151f2167" ext:score="100"><title>Never
Gone</title><status>Official</status><text-representation><language>eng</language><script>Latn</script></text-representation><artist-credit><name-credit><artist
id="2f569e60-0a1b-4fb9-95a4-3dc1525d1aad"><name>Backstreet Boys</name><sort-name>Backstreet
Boys</sort-name><alias-list><alias sort-name="Bachstreet Boys" type="Search hint">Bachstreet
Boys</alias><alias sort-name="Back Street Boys" type="Search hint">Back Street Boys</alias><alias
sort-name="Backstret Boys" type="Search hint">Backstret Boys</alias><alias sort-name="backtreet boy"
type="Search hint">backtreet boy</alias><alias sort-name="Bckstreet Boys" type="Search hint">Bckstreet
Boys</alias><alias sort-name="Bsb">Bsb</alias><ali
as sort-name="The Backstreet Boys">The Backstreet
Boys</alias></alias-list></artist></name-credit></artist-credit><release-group
id="acbabee9-5c0e-3dc6-837c-7ed7d63d02f7"
type="Album"><primary-type>Album</primary-type></release-group><date>2005</date><release-event-list><release-event><date>2005</date></release-event></release-event-list><barcode>828767589626</barcode><medium-list
count="2"><track-count>16</track-count><medium><format>CD</format><disc-list count="0"/><track-list
count="15"/></medium><medium><format>DVD-Audio</format><disc-list count="0"/><track-list
count="1"/></medium></medium-list></release></release-list></metadata>
diff --git a/tests/album-never_gone_info.xml b/tests/album-never_gone_info.xml
new file mode 100644
index 0000000..57c152c
--- /dev/null
+++ b/tests/album-never_gone_info.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata>
+<release id="fd77296e-86f0-436e-8ea2-b657151f2167">
+<title>Never Gone</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<artist-credit>
+<name-credit>
+<artist id="2f569e60-0a1b-4fb9-95a4-3dc1525d1aad">
+<name>Backstreet Boys</name>
+<sort-name>Backstreet Boys</sort-name>
+</artist>
+</name-credit>
+</artist-credit>
+<date>2005</date>
+<release-event-list count="1">
+<release-event>
+<date>2005</date>
+</release-event>
+</release-event-list>
+<barcode>828767589626</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+</release>
+</metadata>
diff --git a/tests/album-never_gone_recordings.xml b/tests/album-never_gone_recordings.xml
new file mode 100644
index 0000000..a0228cc
--- /dev/null
+++ b/tests/album-never_gone_recordings.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata>
+ <release id="fd77296e-86f0-436e-8ea2-b657151f2167">
+ <title>Never Gone</title>
+ <status>Official</status>
+ <quality>normal</quality>
+ <text-representation>
+ <language>eng</language>
+ <script>Latn</script>
+ </text-representation>
+ <date>2005</date>
+ <release-event-list count="1">
+ <release-event>
+ <date>2005</date>
+ </release-event>
+ </release-event-list>
+ <barcode>828767589626</barcode>
+ <cover-art-archive>
+ <artwork>false</artwork>
+ <count>0</count>
+ <front>false</front>
+ <back>false</back>
+ </cover-art-archive>
+ <medium-list count="1">
+ <medium>
+ <position>1</position>
+ <track-list count="1" offset="0">
+ <track id="0044d842-64c2-3b7a-a175-eef552261621">
+ <position>1</position>
+ <number>1</number>
+ <length>229000</length>
+ <recording id="ddc5fc5c-8a83-4d20-a711-313797030da6">
+ <title>I Still...</title>
+ <length>229000</length>
+ </recording>
+ </track>
+ </track-list>
+ </medium>
+ </medium-list>
+ </release>
+ </metadata>
diff --git a/tests/artist-westlife.xml b/tests/artist-westlife.xml
new file mode 100644
index 0000000..6b1f934
--- /dev/null
+++ b/tests/artist-westlife.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata created="2014-06-13T12:59:33.332Z">
+<artist-list count="1" offset="0">
+<artist id="5f000e69-3cfd-4871-8f1b-faa7f0d4bcbc" type="Group" ext:score="100">
+<name>Westlife</name>
+<sort-name>Westlife</sort-name>
+<country>IE</country>
+<area id="390b05d4-11ec-3bce-a343-703a366b34a5">
+<name>Ireland</name>
+<sort-name>Ireland</sort-name>
+</area>
+<begin-area id="a580da6b-ff88-4b8a-85fc-0271ce976260">
+<name>Sligo</name>
+<sort-name>Sligo</sort-name>
+</begin-area>
+<end-area id="462e7952-4fa9-43cd-bc24-2c5c9cd5dd47">
+<name>Dublin</name>
+<sort-name>Dublin</sort-name>
+</end-area>
+<life-span>
+<begin>1998-07-03</begin>
+<end>2012-06</end>
+<ended>true</ended>
+</life-span>
+<alias-list>
+<alias sort-name="West Live">West Live</alias>
+</alias-list>
+<tag-list>
+<tag count="2">
+<name>irish</name>
+</tag>
+<tag count="1">
+<name>adult contemporary</name>
+</tag>
+<tag count="1">
+<name>pop</name>
+</tag>
+<tag count="1">
+<name>pop and chart</name>
+</tag>
+</tag-list>
+</artist>
+</artist-list>
+</metadata>
diff --git a/tests/artist-westlife_release_info.xml b/tests/artist-westlife_release_info.xml
new file mode 100644
index 0000000..f8aaf56
--- /dev/null
+++ b/tests/artist-westlife_release_info.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><release
id="182fbd5e-5f3e-413a-9ff1-8a9a81d052c0"><title>Unbreakable: The Greatest Hits, Volume
1</title><status>Official</status><quality>normal</quality><packaging>Jewel
Case</packaging><text-representation><language>eng</language><script>Latn</script></text-representation><artist-credit><name-credit><artist
id="5f000e69-3cfd-4871-8f1b-faa7f0d4bcbc"><name>Westlife</name><sort-name>Westlife</sort-name></artist></name-credit></artist-credit><date>2002-11-11</date><country>MX</country><release-event-list
count="1"><release-event><date>2002-11-11</date><area
id="3e08b2cd-69f3-317c-b1e4-e71be581839e"><name>Mexico</name><sort-name>Mexico</sort-name><iso-3166-1-code-list><iso-3166-1-code>MX</iso-3166-1-code></iso-3166-1-code-list></area></release-event></release-event-list><barcode>743219753328</barcode><cover-art-archive><artwork>true</artwork><count>1</count><front>true</front><back>fals
e</back></cover-art-archive></release></metadata>
diff --git a/tests/artist-westlife_releases.xml b/tests/artist-westlife_releases.xml
new file mode 100644
index 0000000..e700944
--- /dev/null
+++ b/tests/artist-westlife_releases.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata>
+ <artist type="Group" id="5f000e69-3cfd-4871-8f1b-faa7f0d4bcbc">
+ <name>Westlife</name>
+ <sort-name>Westlife</sort-name>
+ <isni-list>
+ <isni>0000000110883140</isni>
+ </isni-list>
+ <country>IE</country>
+ <area id="390b05d4-11ec-3bce-a343-703a366b34a5">
+ <name>Ireland</name>
+ <sort-name>Ireland</sort-name>
+ <iso-3166-1-code-list>
+ <iso-3166-1-code>IE</iso-3166-1-code>
+ </iso-3166-1-code-list>
+ </area>
+ <begin-area id="a580da6b-ff88-4b8a-85fc-0271ce976260">
+ <name>Sligo</name>
+ <sort-name>Sligo</sort-name>
+ </begin-area>
+ <end-area id="462e7952-4fa9-43cd-bc24-2c5c9cd5dd47">
+ <name>Dublin</name>
+ <sort-name>Dublin</sort-name>
+ </end-area>
+ <life-span>
+ <begin>1998-07-03</begin>
+ <end>2012-06</end>
+ <ended>true</ended>
+ </life-span>
+ <release-list count="1">
+ <release id="182fbd5e-5f3e-413a-9ff1-8a9a81d052c0">
+ <title>Unbreakable: The Greatest Hits, Volume 1</title>
+ <status>Official</status>
+ <quality>normal</quality>
+ <packaging>Jewel Case</packaging>
+ <text-representation>
+ <language>eng</language>
+ <script>Latn</script>
+ </text-representation>
+ <date>2002-11-11</date>
+ <country>MX</country>
+ <release-event-list count="1">
+ <release-event>
+ <date>2002-11-11</date>
+ <area id="3e08b2cd-69f3-317c-b1e4-e71be581839e">
+ <name>Mexico</name>
+ <sort-name>Mexico</sort-name>
+ <iso-3166-1-code-list>
+ <iso-3166-1-code>MX</iso-3166-1-code>
+ </iso-3166-1-code-list>
+ </area>
+ </release-event>
+ </release-event-list>
+ <barcode>743219753328</barcode>
+ </release>
+ </release-list>
+ </artist>
+ </metadata>
diff --git a/tests/discid.xml b/tests/discid.xml
new file mode 100644
index 0000000..30b41e0
--- /dev/null
+++ b/tests/discid.xml
@@ -0,0 +1,470 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata>
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+<release-list count="11">
+<release id="30ac9626-4dac-457c-88be-11d0b7d2f5a4">
+<title>Praat geen poep</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1994</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1994</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>042285543223</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="31f77e60-ad1b-4d06-bf15-813a0efcf5ab">
+<title>Sex met die blonde</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1996</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1996</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>8711211961623</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="5424c204-d61b-4941-ab9a-9305b9b6ff1e">
+<title>Koningin van de zigeuners (La Mama)</title>
+<status>Promotion</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1999</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1999</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>724388655521</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="62d472eb-f875-478e-8ee0-4715813357aa">
+<title>Back to the Shore</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>1994</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1994</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>743212118322</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="6433ccd9-d814-4c74-b51d-2ca38fa5e1bb">
+<title>HOEST</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1998</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1998</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>8712705038258</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="6f55b84c-6e58-4111-ba91-fb485f5c7ca4">
+<title>Congo</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>1997</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1997</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>724389452327</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="95d33f06-b356-44ae-b290-0a7819e028c1">
+<title>Godver godver</title>
+<status>Promotion</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1996</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1996</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>8712195732124</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="9b48ce52-3354-43b4-94a2-d71c75353520">
+<title>Contract</title>
+<status>Promotion</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1998</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1998</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="9fbe550b-f98b-496d-88e8-0d9f45813ac9">
+<title>Da Jonguh</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>nld</language>
+<script>Latn</script>
+</text-representation>
+<date>1997</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1997</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>8712944083774</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="b13fde0c-b3a6-4aae-a6aa-20f07ff29265">
+<title>Three Sisters</title>
+<status>Promotion</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>1998</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1998</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>5099766554815</barcode>
+<cover-art-archive>
+<artwork>false</artwork>
+<count>0</count>
+<front>false</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+<release id="b4f38dad-faed-41f4-9e15-c78383ed42de">
+<title>Eye of Heaven</title>
+<status>Official</status>
+<quality>normal</quality>
+<text-representation>
+<language>eng</language>
+<script>Latn</script>
+</text-representation>
+<date>1991</date>
+<country>NL</country>
+<release-event-list count="1">
+<release-event>
+<date>1991</date>
+<area id="ef1b7cc0-cd26-36f4-8ea0-04d9623786c7">
+<name>Netherlands</name>
+<sort-name>Netherlands</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>NL</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<barcode>5012394525521</barcode>
+<asin>B003BMES70</asin>
+<cover-art-archive>
+<artwork>true</artwork>
+<count>1</count>
+<front>true</front>
+<back>false</back>
+</cover-art-archive>
+<medium-list count="1">
+<medium>
+<position>1</position>
+<format>CD</format>
+<disc-list count="1">
+<disc id="lwHl8fGzJyLXQR33ug60E8jhf4k-">
+<sectors>37890</sectors>
+</disc>
+</disc-list>
+<track-list count="2"/>
+</medium>
+</medium-list>
+</release>
+</release-list>
+</disc>
+</metadata>
diff --git a/tests/error.xml b/tests/error.xml
new file mode 100644
index 0000000..c04a5cb
--- /dev/null
+++ b/tests/error.xml
@@ -0,0 +1 @@
+<?xml version="1.0" standalone="yes"?>
diff --git a/tests/recordings-i_still.xml b/tests/recordings-i_still.xml
new file mode 100644
index 0000000..d5ed17e
--- /dev/null
+++ b/tests/recordings-i_still.xml
@@ -0,0 +1,236 @@
+<?xml version="1.0" standalone="yes"?>
+<metadata created="2014-06-13T04:29:19.114Z">
+<recording-list count="517884" offset="0">
+<recording id="ddc5fc5c-8a83-4d20-a711-313797030da6" ext:score="100">
+<title>I Still...</title>
+<length>229000</length>
+<artist-credit>
+<name-credit>
+<artist id="2f569e60-0a1b-4fb9-95a4-3dc1525d1aad">
+<name>Backstreet Boys</name>
+<sort-name>Backstreet Boys</sort-name>
+<alias-list>
+<alias sort-name="Bachstreet Boys" type="Search hint">Bachstreet Boys</alias>
+<alias sort-name="Back Street Boys" type="Search hint">Back Street Boys</alias>
+<alias sort-name="Backstret Boys" type="Search hint">Backstret Boys</alias>
+<alias sort-name="backtreet boy" type="Search hint">backtreet boy</alias>
+<alias sort-name="Bckstreet Boys" type="Search hint">Bckstreet Boys</alias>
+<alias sort-name="Bsb">Bsb</alias>
+<alias sort-name="The Backstreet Boys">The Backstreet Boys</alias>
+</alias-list>
+</artist>
+</name-credit>
+</artist-credit>
+<release-list>
+<release id="f278b617-b8f6-4b4e-bcd9-cf0af410d2d9">
+<title>Never Gone</title>
+<status>Official</status>
+<release-group id="acbabee9-5c0e-3dc6-837c-7ed7d63d02f7" type="Album">
+<primary-type>Album</primary-type>
+</release-group>
+<date>2005</date>
+<country>JP</country>
+<release-event-list>
+<release-event>
+<date>2005</date>
+<area id="2db42837-c832-3c27-b4a3-08198f75693c">
+<name>Japan</name>
+<sort-name>Japan</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>JP</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<medium-list>
+<track-count>15</track-count>
+<medium>
+<position>1</position>
+<track-list count="15" offset="4">
+<track id="02c728ac-37ab-357b-9811-73629b71d481">
+<number>5</number>
+<title>I Still...</title>
+<length>229000</length>
+</track>
+</track-list>
+</medium>
+</medium-list>
+</release>
+<release id="9d3942e9-45a7-4958-8df0-8065b4a14880">
+<title>Absolute Hits 2006</title>
+<status>Official</status>
+<artist-credit>
+<name-credit>
+<artist id="89ad4ac3-39f7-470e-963a-56509c546377">
+<name>Various Artists</name>
+<sort-name>Various Artists</sort-name>
+</artist>
+</name-credit>
+</artist-credit>
+<release-group id="9e47f663-1e0c-39d5-9a28-16751763233f" type="Compilation">
+<primary-type>Album</primary-type>
+<secondary-type-list>
+<secondary-type>Compilation</secondary-type>
+</secondary-type-list>
+</release-group>
+<date>2006-11-15</date>
+<country>SE</country>
+<release-event-list>
+<release-event>
+<date>2006-11-15</date>
+<area id="23d10872-f5ae-3f0c-bf55-332788a16ecb">
+<name>Sweden</name>
+<sort-name>Sweden</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>SE</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<medium-list>
+<track-count>40</track-count>
+<medium>
+<position>1</position>
+<format>CD</format>
+<track-list count="20" offset="16">
+<track id="04b0f01d-3912-36a8-a309-0553268b0865">
+<number>17</number>
+<title>I Still</title>
+<length>226000</length>
+</track>
+</track-list>
+</medium>
+</medium-list>
+</release>
+<release id="a3e87183-5536-35a4-ad96-1925d73360aa">
+<title>Never Gone</title>
+<status>Official</status>
+<release-group id="acbabee9-5c0e-3dc6-837c-7ed7d63d02f7" type="Album">
+<primary-type>Album</primary-type>
+</release-group>
+<date>2005</date>
+<country>CA</country>
+<release-event-list>
+<release-event>
+<date>2005</date>
+<area id="71bbafaa-e825-3e15-8ca9-017dcad1748b">
+<name>Canada</name>
+<sort-name>Canada</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>CA</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<medium-list>
+<track-count>15</track-count>
+<medium>
+<position>1</position>
+<format>CD</format>
+<track-list count="15" offset="4">
+<track id="80f99d1a-8022-34e4-9d99-b0729be8f91d">
+<number>5</number>
+<title>I Still...</title>
+<length>229000</length>
+</track>
+</track-list>
+</medium>
+</medium-list>
+</release>
+<release id="8403e2ec-f09e-43c7-997b-1e650cae139a">
+<title>Now That's What I Call Music! 42</title>
+<status>Official</status>
+<artist-credit>
+<name-credit>
+<artist id="89ad4ac3-39f7-470e-963a-56509c546377">
+<name>Various Artists</name>
+<sort-name>Various Artists</sort-name>
+</artist>
+</name-credit>
+</artist-credit>
+<release-group id="003a2031-f840-4ab9-b293-635b26d2ead7" type="Compilation">
+<primary-type>Album</primary-type>
+<secondary-type-list>
+<secondary-type>Compilation</secondary-type>
+</secondary-type-list>
+</release-group>
+<date>2006</date>
+<country>ZA</country>
+<release-event-list>
+<release-event>
+<date>2006</date>
+<area id="50cc7852-862e-30ae-aa82-385fe7135b7f">
+<name>South Africa</name>
+<sort-name>South Africa</sort-name>
+<iso-3166-1-code-list>
+<iso-3166-1-code>ZA</iso-3166-1-code>
+</iso-3166-1-code-list>
+</area>
+</release-event>
+</release-event-list>
+<medium-list>
+<track-count>21</track-count>
+<medium>
+<position>1</position>
+<format>CD</format>
+<track-list count="21" offset="6">
+<track id="8c5844c4-2496-35c7-a41b-4a5decf86b1f">
+<number>7</number>
+<title>I Still</title>
+<length>227400</length>
+</track>
+</track-list>
+</medium>
+</medium-list>
+</release>
+<release id="fd77296e-86f0-436e-8ea2-b657151f2167">
+<title>Never Gone</title>
+<status>Official</status>
+<release-group id="acbabee9-5c0e-3dc6-837c-7ed7d63d02f7" type="Album">
+<primary-type>Album</primary-type>
+</release-group>
+<date>2005</date>
+<release-event-list>
+<release-event>
+<date>2005</date>
+</release-event>
+</release-event-list>
+<medium-list>
+<track-count>16</track-count>
+<medium>
+<position>1</position>
+<format>CD</format>
+<track-list count="15" offset="4">
+<track id="0044d842-64c2-3b7a-a175-eef552261621">
+<number>5</number>
+<title>I Still...</title>
+<length>229000</length>
+</track>
+</track-list>
+</medium>
+</medium-list>
+</release>
+</release-list>
+<tag-list>
+<tag count="1">
+<name>pop</name>
+</tag>
+<tag count="2">
+<name>dance-pop</name>
+</tag>
+<tag count="1">
+<name>adult contemporary</name>
+</tag>
+<tag count="1">
+<name>teen pop</name>
+</tag>
+<tag count="1">
+<name>euro-dance</name>
+</tag>
+<tag count="1">
+<name>pop/rock</name>
+</tag>
+</tag-list>
+</recording>
+</recording-list>
+</metadata>
diff --git a/tests/test-musicbrainz.c b/tests/test-musicbrainz.c
new file mode 100644
index 0000000..6da895d
--- /dev/null
+++ b/tests/test-musicbrainz.c
@@ -0,0 +1,153 @@
+#include <glib.h>
+
+#include "mb_search.h"
+
+static gchar name[NAME_MAX_SIZE];
+static gchar mbid[NAME_MAX_SIZE];
+void
+mb_search_test ()
+{
+ GNode *mbTreeNode;
+ GError *err;
+
+ err = NULL;
+ mbTreeNode = g_node_new (NULL);
+ if (et_musicbrainz_search ("Westlife", MB_ENTITY_TYPE_ARTIST, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (mbTreeNode)->data);
+ mb5_artist_get_name (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "Westlife");
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
+
+ mbTreeNode = g_node_new (NULL);
+
+ if (et_musicbrainz_search ("Never Gone", MB_ENTITY_TYPE_ALBUM, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (mbTreeNode)->data);
+ mb5_release_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "Never Gone");
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
+
+ mbTreeNode = g_node_new (NULL);
+
+ if (et_musicbrainz_search ("I Still", MB_ENTITY_TYPE_TRACK, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (mbTreeNode)->data);
+ mb5_recording_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "I Still...");
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
+}
+
+void
+mb_search_in_test ()
+{
+ GNode *mbTreeNode;
+ GError *err;
+
+ err = NULL;
+ mbTreeNode = g_node_new (NULL);
+
+ if (et_musicbrainz_search ("Westlife", MB_ENTITY_TYPE_ARTIST, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+ GNode *westlife_node;
+
+ westlife_node = g_node_first_child (mbTreeNode);
+ etentity = (EtMbEntity *)(westlife_node->data);
+ mb5_artist_get_name (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "Westlife");
+
+ mb5_artist_get_id (etentity->entity, mbid, NAME_MAX_SIZE);
+
+ if (et_musicbrainz_search_in_entity (MB_ENTITY_TYPE_ALBUM,
+ MB_ENTITY_TYPE_ARTIST, mbid,
+ westlife_node, &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (westlife_node)->data);
+ mb5_release_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==,
+ "Unbreakable: The Greatest Hits, Volume 1");
+ }
+
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
+
+ mbTreeNode = g_node_new (NULL);
+
+ if (et_musicbrainz_search ("Never Gone", MB_ENTITY_TYPE_ALBUM, mbTreeNode,
+ &err, NULL))
+ {
+ EtMbEntity *etentity;
+ GNode *never_gone_node;
+
+ never_gone_node = g_node_first_child (mbTreeNode);
+ etentity = (EtMbEntity *)(g_node_first_child (mbTreeNode)->data);
+ mb5_release_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "Never Gone");
+ mb5_release_get_id (etentity->entity, mbid, NAME_MAX_SIZE);
+
+ if (et_musicbrainz_search_in_entity (MB_ENTITY_TYPE_TRACK,
+ MB_ENTITY_TYPE_ALBUM, mbid,
+ never_gone_node, &err, NULL))
+ {
+ EtMbEntity *etentity;
+
+ etentity = (EtMbEntity *)(g_node_first_child (never_gone_node)->data);
+ mb5_release_get_title (etentity->entity, name, NAME_MAX_SIZE);
+ g_assert_cmpstr (name, ==, "I Still...");
+ }
+
+ free_mb_tree (mbTreeNode);
+ }
+ else
+ {
+ free_mb_tree (mbTreeNode);
+ return;
+ }
+}
+
+int
+main(int argc, char** argv)
+{
+ g_test_init(&argc, &argv, NULL);
+ et_musicbrainz_search_set_server_port ("localhost", 8088);
+ g_test_add_func("/musicbrainz/mb_search", mb_search_test);
+ g_test_add_func("/musicbrainz/mb_search_in", mb_search_in_test);
+
+ return g_test_run();
+}
\ No newline at end of file
diff --git a/tests/test-musicbrainz_server.c b/tests/test-musicbrainz_server.c
new file mode 100644
index 0000000..c1a1133
--- /dev/null
+++ b/tests/test-musicbrainz_server.c
@@ -0,0 +1,245 @@
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <string.h>
+
+static void
+default_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ g_file_get_contents ("./error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ "error", strlen ("error"));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+westlife_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ printf ("dsfsdfsdf\n");
+ if (g_file_get_contents ("./artist-westlife_releases.xml", &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+
+static void
+westlife_release_info_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ if (g_file_get_contents ("./artist-westlife_release_info.xml", &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+static void
+i_still_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ if (g_file_get_contents ("./album-i_still_info.xml", &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+}
+
+static void
+never_gone_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "inc");
+ //printf ("sssss\n");
+ //printf ("%s\n", value);
+ if (value && !g_strcmp0 (value, "artists release-groups"))
+ {
+ if (g_file_get_contents ("./album-never_gone_info.xml", &response_text,
+ &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+ }
+
+ else if (value && !g_strcmp0 (value, "recordings"))
+ {
+ if (g_file_get_contents ("./album-never_gone_recordings.xml",
+ &response_text, &length, NULL))
+ {
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+ }
+ }
+}
+
+static void
+artist_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+ printf ("ddd %s\n", path);
+ if (value && !strcmp ((gchar *)value, "artist:Westlife"))
+ {
+ if (g_file_get_contents ("./artist-westlife.xml", &response_text,
+ &length, NULL))
+ {
+ //printf ("sending message %s\n", response_text);
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+release_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+
+ if (value && !strcmp ((gchar *)value, "release:Never Gone"))
+ {
+ if (g_file_get_contents ("./album-never_gone.xml", &response_text,
+ &length, NULL))
+ {//printf ("sending message %s\n", response_text);
+
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+recording_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+ gpointer value;
+
+ value = g_hash_table_lookup (query, "query");
+ printf ("%s\n", value);
+ if (value && !strcmp ((gchar *)value, "recordings:I Still"))
+ {
+ if (g_file_get_contents ("./recordings-i_still.xml", &response_text,
+ &length, NULL))
+ {printf ("sending message %s\n", response_text);
+
+ soup_message_set_response (msg, "application/xml",
+ SOUP_MEMORY_TAKE, response_text,
+ strlen (response_text));
+ soup_message_set_status (msg, 200);
+ return;
+ }
+ }
+
+ g_file_get_contents ("./error.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+static void
+discid_handler (SoupServer *server, SoupMessage *msg, const char *path,
+ GHashTable *query, SoupClientContext *client,
+ gpointer user_data)
+{
+ gchar *response_text;
+ gsize length;
+
+ g_file_get_contents ("./metadata.xml", &response_text, &length, NULL);
+ soup_message_set_response (msg, "application/xml", SOUP_MEMORY_TAKE,
+ response_text, strlen (response_text));
+ soup_message_set_status (msg, 200);
+}
+
+void
+main ()
+{
+ SoupServer *server;
+
+ g_type_init ();
+ server = soup_server_new (SOUP_SERVER_PORT, 8088, NULL);
+ soup_server_add_handler (server, "/", (SoupServerCallback)default_handler,
+ NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/artist",
+ (SoupServerCallback)artist_handler, NULL, NULL);
+ soup_server_add_handler (server,
+ "/ws/2/artist/5f000e69-3cfd-4871-8f1b-faa7f0d4bcbc",
+ (SoupServerCallback)westlife_handler, NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/release",
+ (SoupServerCallback)release_handler, NULL, NULL);
+ soup_server_add_handler (server,
+ "/ws/2/release/fd77296e-86f0-436e-8ea2-b657151f2167",
+ (SoupServerCallback)never_gone_handler, NULL, NULL);
+ soup_server_add_handler (server,
+ "/ws/2/release/182fbd5e-5f3e-413a-9ff1-8a9a81d052c0",
+ (SoupServerCallback)westlife_release_info_handler, NULL, NULL);
+ soup_server_add_handler (server, "/ws/2/recording",
+ (SoupServerCallback)recording_handler, NULL,
+ NULL);
+ soup_server_add_handler (server,
+ "/ws/2/recording/ddc5fc5c-8a83-4d20-a711-313797030da6",
+ (SoupServerCallback)i_still_handler, NULL,
+ NULL);
+ soup_server_add_handler (server, "/ws/2/discid",
+ (SoupServerCallback)discid_handler, NULL, NULL);
+ soup_server_run (server);
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]