@Test
    public void testBricklinkConnection() throws Exception {
        JdbcTemplate t;
        BasicCookieStore cookieStore = new BasicCookieStore();
        CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCookieStore(cookieStore)
                .setRedirectStrategy(new LaxRedirectStrategy())
                .build();
        try {
            HttpGet httpget = new HttpGet("https://www.bricklink.com/login.asp");
            CloseableHttpResponse response1 = httpclient.execute(httpget);
            try {
                HttpEntity entity = response1.getEntity();

                System.out.println("Login form get: " + response1.getStatusLine());
                EntityUtils.consume(entity);

                System.out.println("Initial set of cookies:");
                List<Cookie> cookies = cookieStore.getCookies();
                if (cookies.isEmpty()) {
                    System.out.println("None");
                } else {
                    for (int i = 0; i < cookies.size(); i++) {
                        System.out.println("- " + cookies.get(i).toString());
                    }
                }
            } finally {
                response1.close();
            }

            HttpUriRequest login = RequestBuilder.post()
                    .setUri(new URI("https://www.bricklink.com/login.asp"))
                    .addParameter("frmUsername", "tvattima")
                    .addParameter("frmPassword", "N1njago")
                    .addParameter("logInTo", "")
                    .addParameter("logFolder","p")
                    .addParameter("logSub", "w")
                    .addParameter("a", "a")
                    .build();
            CloseableHttpResponse response2 = httpclient.execute(login);
            try {
                HttpEntity entity = response2.getEntity();

                System.out.println("Login form get: " + response2.getStatusLine());
                System.out.println(IOUtils.toString(entity.getContent()));

                EntityUtils.consume(entity);
                System.out.println("Post logon cookies:");
                List<Cookie> cookies = cookieStore.getCookies();
                if (cookies.isEmpty()) {
                    System.out.println("None");
                } else {
                    for (int i = 0; i < cookies.size(); i++) {
                        System.out.println("- " + cookies.get(i).toString());
                    }
                }

            } finally {
                response2.close();
            }


            HttpGet viewWanted = new HttpGet("http://www.bricklink.com/orderPlaced.asp");

            System.out.println("Executing request " + viewWanted.getRequestLine());

            // Create a custom response handler
            ResponseHandler<String> responseHandler = new ResponseHandler<String>() {

                public String handleResponse(
                        final HttpResponse response) throws ClientProtocolException, IOException {
                    int status = response.getStatusLine().getStatusCode();
                    if (status >= 200 && status < 300) {
                        HttpEntity entity = response.getEntity();
                        return entity != null ? EntityUtils.toString(entity) : null;
                    } else {
                        throw new ClientProtocolException("Unexpected response status: " + status);
                    }
                }

            };
            String responseBody = httpclient.execute(viewWanted, responseHandler);
            System.out.println("----------------------------------------");
            Document doc = Jsoup.parse(responseBody);
            HtmlOrderRegexMarshaller marshaller = new HtmlOrderRegexMarshaller();
            marshaller.setPattern(Pattern.compile(".*?<td.*?>.*?<a.*?>(.*?)</a>.*?</td>.*?<td.*?>(.*?)</td>.*?<td.*?</td>.*?<td.*?</td>.*?<td.*?</td>.*?<td.*?</td>.*?<td.*?>.*?<a.*?>(.*?)</a>.*?<a.*?>\\((.*?)\\)</a>.*?</td>", Pattern.MULTILINE | Pattern.DOTALL));
            int row = 0;
            for (Element tr : doc.select("table.tableT1 > tbody > tr")) {
                if (row < 1) {
                    row++;
                    continue;
                }
                System.out.println(marshaller.marshal(tr.html()));

            }
            System.out.println();

        } finally {
            httpclient.close();
        }

    }