TodoListMemberFilePersister.java

1
/* $Id: TodoListMemberFilePersister.java 19614 2011-07-20 12:10:13Z linus $
2
 *****************************************************************************
3
 * Copyright (c) 2009 Contributors - see below
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    tfmorris
11
 *****************************************************************************
12
 *
13
 * Some portions of this file was previously release using the BSD License:
14
 */
15
16
// Copyright (c) 1996-2009 The Regents of the University of California. All
17
// Rights Reserved. Permission to use, copy, modify, and distribute this
18
// software and its documentation without fee, and without a written
19
// agreement is hereby granted, provided that the above copyright notice
20
// and this paragraph appear in all copies.  This software program and
21
// documentation are copyrighted by The Regents of the University of
22
// California. The software program and documentation are supplied "AS
23
// IS", without any accompanying services from The Regents. The Regents
24
// does not warrant that the operation of the program will be
25
// uninterrupted or error-free. The end-user understands that the program
26
// was developed for research purposes and is advised not to rely
27
// exclusively on the program for any reason.  IN NO EVENT SHALL THE
28
// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
29
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
30
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
31
// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
32
// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
33
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
35
// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
36
// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
37
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
38
39
package org.argouml.persistence;
40
41
import java.io.InputStream;
42
import java.io.InputStreamReader;
43
import java.io.OutputStream;
44
import java.io.OutputStreamWriter;
45
import java.io.PrintWriter;
46
import java.io.UnsupportedEncodingException;
47
import java.net.URL;
48
49
import org.argouml.application.api.Argo;
50
import org.argouml.cognitive.Designer;
51
import org.argouml.kernel.Project;
52
import org.argouml.kernel.ProjectMember;
53
import org.argouml.ocl.OCLExpander;
54
import org.argouml.uml.cognitive.ProjectMemberTodoList;
55
import org.tigris.gef.ocl.ExpansionException;
56
import org.tigris.gef.ocl.TemplateReader;
57
import org.xml.sax.InputSource;
58
59
/**
60
 * The file persister for the Todo members.
61
 * @author Bob Tarling
62
 */
63
class TodoListMemberFilePersister extends MemberFilePersister {
64
65
    private static final String TO_DO_TEE = "/org/argouml/persistence/todo.tee";
66
67
68
    public void load(Project project, InputStream inputStream)
69
        throws OpenException {
70
        try {
71 1 1. load : removed call to org/argouml/persistence/TodoListMemberFilePersister::load → NO_COVERAGE
            load(project, new InputSource(new InputStreamReader(inputStream,
72
                    Argo.getEncoding())));
73
        } catch (UnsupportedEncodingException e) {
74
            throw new OpenException(e);
75
        }
76
    }
77
    
78
79
    public void load(Project project, InputSource inputSource)
80
        throws OpenException {
81
82
        try {
83
            TodoParser parser = new TodoParser();
84 1 1. load : removed call to org/argouml/persistence/TodoParser::readTodoList → NO_COVERAGE
            parser.readTodoList(inputSource);
85
            ProjectMemberTodoList pm = new ProjectMemberTodoList("", project);
86 1 1. load : removed call to org/argouml/kernel/Project::addMember → NO_COVERAGE
            project.addMember(pm);
87
        } catch (Exception e) {
88 1 1. load : negated conditional → NO_COVERAGE
            if (e instanceof OpenException) {
89
                throw (OpenException) e;
90
            }
91
            throw new OpenException(e);
92
        }
93
    }
94
    
95
    @Override
96
    public void load(Project project, URL url) throws OpenException {   
97 1 1. load : removed call to org/argouml/persistence/TodoListMemberFilePersister::load → NO_COVERAGE
        load(project, new InputSource(url.toExternalForm()));
98
    }
99
100
    /*
101
     * @see org.argouml.persistence.MemberFilePersister#getMainTag()
102
     */
103
    public final String getMainTag() {
104 1 1. getMainTag : mutated return of Object value for org/argouml/persistence/TodoListMemberFilePersister::getMainTag to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return "todo";
105
    }
106
107
108
    public void save(ProjectMember member, OutputStream outStream)
109
        throws SaveException {
110
111
        OCLExpander expander;
112
        try {
113
            expander =
114
                    new OCLExpander(TemplateReader.getInstance()
115
                            .read(TO_DO_TEE));
116
        } catch (ExpansionException e) {
117
            throw new SaveException(e);
118
        }
119
120
        PrintWriter pw;
121
        try {
122
            pw = new PrintWriter(new OutputStreamWriter(outStream, "UTF-8"));
123
        } catch (UnsupportedEncodingException e1) {
124
            throw new SaveException("UTF-8 encoding not supported on platform", 
125
                    e1);
126
        }
127
        
128
        try {
129 1 1. save : removed call to org/argouml/cognitive/Designer::disableCritiquing → NO_COVERAGE
            Designer.disableCritiquing();
130
            // WARNING: The GEF implementation of the OutputStream version of 
131
            // this method doesn't work - tfm - 20070531
132 1 1. save : removed call to org/argouml/ocl/OCLExpander::expand → NO_COVERAGE
            expander.expand(pw, member);
133
        } catch (ExpansionException e) {
134
            throw new SaveException(e);
135
        } finally {
136 2 1. save : removed call to java/io/PrintWriter::flush → NO_COVERAGE
2. save : removed call to java/io/PrintWriter::flush → NO_COVERAGE
            pw.flush();
137
//            pw.close();
138 2 1. save : removed call to org/argouml/cognitive/Designer::enableCritiquing → NO_COVERAGE
2. save : removed call to org/argouml/cognitive/Designer::enableCritiquing → NO_COVERAGE
            Designer.enableCritiquing();
139
        }
140
141
    }
142
143
}

Mutations

71

1.1
Location : load
Killed by : none
removed call to org/argouml/persistence/TodoListMemberFilePersister::load → NO_COVERAGE

84

1.1
Location : load
Killed by : none
removed call to org/argouml/persistence/TodoParser::readTodoList → NO_COVERAGE

86

1.1
Location : load
Killed by : none
removed call to org/argouml/kernel/Project::addMember → NO_COVERAGE

88

1.1
Location : load
Killed by : none
negated conditional → NO_COVERAGE

97

1.1
Location : load
Killed by : none
removed call to org/argouml/persistence/TodoListMemberFilePersister::load → NO_COVERAGE

104

1.1
Location : getMainTag
Killed by : none
mutated return of Object value for org/argouml/persistence/TodoListMemberFilePersister::getMainTag to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

129

1.1
Location : save
Killed by : none
removed call to org/argouml/cognitive/Designer::disableCritiquing → NO_COVERAGE

132

1.1
Location : save
Killed by : none
removed call to org/argouml/ocl/OCLExpander::expand → NO_COVERAGE

136

1.1
Location : save
Killed by : none
removed call to java/io/PrintWriter::flush → NO_COVERAGE

2.2
Location : save
Killed by : none
removed call to java/io/PrintWriter::flush → NO_COVERAGE

138

1.1
Location : save
Killed by : none
removed call to org/argouml/cognitive/Designer::enableCritiquing → NO_COVERAGE

2.2
Location : save
Killed by : none
removed call to org/argouml/cognitive/Designer::enableCritiquing → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.32