jaulib v1.3.0
Jau Support Library (C++, Java, ..)
TestUriQueryProps.java
Go to the documentation of this file.
1package jau.test.net;
2
3import static jau.test.net.URIDumpUtil.showUri;
4
5import java.io.IOException;
6import java.net.URISyntaxException;
7
8import org.jau.net.Uri;
9import org.jau.net.UriQueryProps;
10import org.junit.Assert;
11import org.junit.FixMethodOrder;
12import org.junit.Test;
13import org.junit.runners.MethodSorters;
14
15import jau.test.junit.util.JunitTracer;
16
17@FixMethodOrder(MethodSorters.NAME_ASCENDING)
18public class TestUriQueryProps extends JunitTracer {
19
20 @Test
21 public void test() throws IOException, URISyntaxException {
22 final String SCHEME = "camera";
23 final String HOST = "somewhere";
24 final String PATH = "0";
25 final String[] args = new String[] {
26 SCHEME+"://"+HOST+"/"+PATH,
27 SCHEME+"://"+HOST+"/"+PATH+"?p1=1",
28 };
29 for(int i=0; i<args.length-1; i+=2) {
30 final String uri_s0 = args[i];
31 final String uri_s1 = args[i+1];
32 final Uri uri0 = Uri.cast(uri_s0);
33 final Uri uri1 = Uri.cast(uri_s1);
34 showUri(uri0);
35 showUri(uri1);
36 final UriQueryProps data = UriQueryProps.create(uri1, ';');
37 if(null == data) {
38 System.err.println("Error: NULL: <"+uri_s1+"> -> "+uri1+" -> NULL");
39 } else {
40 final Uri uri1T = data.appendQuery(uri0);
41 showUri(uri1T);
42 Assert.assertEquals(uri1, uri1T);
43 }
44 }
45 }
46 public static void main(final String args[]) throws IOException {
47 final String tstname = TestUriQueryProps.class.getName();
48 org.junit.runner.JUnitCore.main(tstname);
49 }
50}
static void main(final String args[])
Helper class to process URI's query, handled as properties.
static final UriQueryProps create(final Uri uri, final char querySeparator)
final Uri.Encoded appendQuery(Uri.Encoded baseQuery)
This class implements an immutable Uri as defined by RFC 2396.
Definition: Uri.java:162
static Uri cast(final String encodedUri)
Casts the given encoded String to a new Encoded instance used to create the resulting Uri instance vi...
Definition: Uri.java:1073