Java tutorial
/* * Digital Assets Management * ========================= * * Copyright 2009 Fundacin Iavante * * Authors: * Francisco Jos Moreno Llorca <packo@assamita.net> * Francisco Jess Gonzlez Mata <chuspb@gmail.com> * Juan Antonio Guzmn Hidalgo <juan@guzmanhidalgo.com> * Daniel de la Cuesta Navarrete <cues7a@gmail.com> * Manuel Jos Cobo Fernndez <ranrrias@gmail.com> * * Licensed under the EUPL, Version 1.1 or as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * http://ec.europa.eu/idabc/eupl * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * */ package org.iavante.sling.gad.downloader; import java.io.*; import java.util.Iterator; import java.util.Map; import java.util.Set; import junit.framework.TestCase; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.*; /** * Test content creation and schema association */ public class ProxyFileSystemIT extends TestCase { private final String DOWNLOADER_URL = "/system/proxy/"; private final String HOSTVAR = "SLINGHOST"; private final String HOSTPREDEF = "localhost:8888"; private String SLING_URL = "http://"; HttpClient client; @org.junit.Before protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true; } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); } @org.junit.After protected void tearDown() { } @org.junit.Test public void test_download_with_no_file() { // Get the content HttpMethod get_downloader = new GetMethod(SLING_URL + DOWNLOADER_URL); try { client.executeMethod(get_downloader); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } assertEquals(get_downloader.getStatusCode(), 500); } }