summaryrefslogtreecommitdiffstats
blob: 14ea5f01cec0cf5d50e828df927b04e8adfb55f8 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.resource.management.test.util;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.util.Resource;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
/**
 * Test Cases for {@link Resource}
 * 
 * @author Roberto E. Escobar
 */
public class ResourceTest {

   private IResource resource;
   private final String expectedName;
   private final boolean expectedCompressed;
   private final String rawPath;

   public ResourceTest(String rawPath, String expectedName, boolean expectedCompressed) {
      this.rawPath = rawPath;
      this.expectedName = expectedName;
      this.expectedCompressed = expectedCompressed;
      construct();
   }

   private void construct() {
      try {
         this.resource = new Resource(new URI(rawPath), expectedCompressed);
      } catch (Exception ex) {
         Assert.fail("Failed Resource creation");
      }
      Assert.assertNotNull(resource);
   }

   @Test
   public void testIsCompressed() {
      Assert.assertEquals(expectedCompressed, resource.isCompressed());
   }

   @Test
   public void testGetName() {
      Assert.assertEquals(expectedName, resource.getName());
   }

   @Test
   public void testGetLocation() {
      Assert.assertEquals(rawPath, resource.getLocation().toASCIIString());
   }

   @Parameters
   public static Collection<Object[]> data() {
      List<Object[]> data = new ArrayList<Object[]>();
      data.add(new Object[] {"file://1/sample.file", "sample.file", true});
      data.add(new Object[] {"http://www.url.com", "www.url.com", false,});
      data.add(new Object[] {"http://www.url.com/hello", "hello", false,});

      return data;
   }
}