Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/acs/damsel/srvr/asset/TestAsset.java


1   package org.acs.damsel.srvr.asset;
2   
3   import junit.framework.*;
4   import java.io.*;
5   import org.acs.damsel.srvr.Config;
6   import org.acs.damsel.srvr.db.AssetDB;
7   import java.sql.*;
8   
9   
10  public class TestAsset
11      extends TestCase {
12    private Asset asset = null;
13  
14  
15    public TestAsset(String name) {
16      super(name);
17    }
18  
19    protected void setUp() throws Exception {
20      super.setUp();
21      asset = new Asset();
22    }
23  
24  
25    /* Tests the toString method. */
26    public void testGetFileName() {
27      try {
28        Asset a = new Asset();
29        AssetDescriptor fileNameAD = new AssetDescriptor();
30        AssetDescriptor titleAD = new AssetDescriptor();
31        fileNameAD.setTag("FileName");
32        fileNameAD.setValue("testAsset.jpg");
33        titleAD.setTag("Title");
34        titleAD.setValue("testTitle");
35  
36        AssetDescriptorCollection adc = new AssetDescriptorCollection();
37        adc.addAssetDescriptor(fileNameAD);
38        adc.addAssetDescriptor(titleAD);
39        a.setAssetDescriptors(adc);
40  
41        AssetDB assetDB = AssetDB.instance();
42        assetDB.addAsset(a, "TestCol");
43  
44        Asset tempAsset = assetDB.getAsset("testAsset.jpg");
45        this.assertEquals("testAsset.jpg", tempAsset.getFileName());
46        assetDB.deleteAsset(a);
47        assetDB.removeAssetFromAllCollections(a);
48      }
49      catch (SQLException ex) {
50        this.fail("Caught unexpected SQL exception.");
51        ex.printStackTrace();
52      }
53    }
54  
55    protected void tearDown() throws Exception {
56      asset = null;
57      super.tearDown();
58    }
59  
60  }