summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/resources/NonExistingFileResource.java
blob: c102291b5021f2ff5e142911a25652d447a65773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.vaadin.tests.resources;

import java.io.File;

import com.vaadin.server.FileResource;
import com.vaadin.server.WrappedRequest;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.util.CurrentInstance;

public class NonExistingFileResource extends TestBase {

    @Override
    protected void setup() {
        Button existing = createButton("WEB-INF/web.xml");
        Button nonExisting = createButton("WEB-INF/web2.xml");
        addComponent(existing);
        addComponent(nonExisting);

    }

    private Button createButton(final String filename) {
        Button b = new Button("Download " + filename);
        b.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                FileResource res = new FileResource(new File(CurrentInstance
                        .get(WrappedRequest.class).getVaadinService()
                        .getBaseDirectory()
                        + "/" + filename));
                getMainWindow().open(res);

            }
        });
        return b;
    }

    @Override
    protected String getDescription() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    protected Integer getTicketNumber() {
        // TODO Auto-generated method stub
        return null;
    }

}