Project

General

Profile

« Previous | Next » 

Revision 5348

Added by berkley almost 14 years ago

added exception testing to the crud test

View differences:

test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java
122 122
            SystemMetadata sm = getSystemMetadata(token, id);
123 123
            assertTrue(sm.getIdentifier().getValue().equals(id.getValue()));
124 124
            assertTrue(sm.getChecksum().getValue().equals(checksum(getTestDoc())));
125
            
126
            try
127
            {
128
                Identifier fakeid = new Identifier();
129
                fakeid.setValue("somethingfake.234234");
130
                getSystemMetadata(token, fakeid);
131
                fail("getSystemMetadata should have thrown an exception.");
132
            }
133
            catch(Exception e)
134
            {
135
                assertTrue(true);
136
            }
125 137
        }
126 138
        catch(Exception e)
127 139
        {
......
153 165
            System.out.println("got doc: " + gotDoc);
154 166
            //compare the docs
155 167
            assertTrue(gotDoc.trim().equals(getTestDoc().trim()));
168
            
169
            try
170
            {
171
                Identifier fakeid = new Identifier();
172
                fakeid.setValue("somethingfake.234234");
173
                getDoc(token, fakeid);
174
                fail("testCreateAndGet should have thrown an exception.");
175
            }
176
            catch(Exception e)
177
            {
178
                assertTrue(true);
179
            }
156 180
        }
157 181
        catch(Exception e)
158 182
        {
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
669 669
                    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
670 670
                    SystemMetadata m = (SystemMetadata) uctx.unmarshalDocument(sysmeta, null);
671 671

  
672
                    //CrudService cs = new CrudService(servletContext, request, response);
673 672
                    CrudService cs = CrudService.getInstance();
674 673
                    cs.setParamsFromRequest(request);
675 674
                    Identifier id = new Identifier();
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
367 367
            return sysmeta;
368 368
            
369 369
        } catch (McdbDocNotFoundException e) {
370
            e.printStackTrace();
370
            //e.printStackTrace();
371 371
            throw new NotFound(1000, e.getMessage());
372 372
        }                
373 373
    }

Also available in: Unified diff