private void setAttributes(Element classificationElement, Classification classificationObject) { /* * domain %string; #REQUIRED */ // List<Attribute> attributes = new ArrayList<Attribute>(); List attributes = new ArrayList(); attributes.add(new Attribute("domain", classificationObject.getDomain())); classificationElement.setAttributes(attributes); }
@Test public void testExecuteThrowsParseException1() throws Throwable { Element e = new Element("testBSHMethodName", Namespace.NO_NAMESPACE); e.addContent("XXXXXXX XXXXXXXXX XXXX"); e.setAttributes(new ArrayList()); try { BSHMethod.createBshMethod(e).execute(arguments, "testBSHMethodResultName"); fail("Expected ParseException to be thrown"); } catch (ParseException ex) { assertThat(ex.getMessage(), allOf(notNullValue(), containsString("line 1, column 19"))); } }
private void setAttributes(Element descriptionElement, Description descriptionObject) { /* * xml:lang %xmlLangCode; #REQUIRED */ // List<Attribute> attributes = new ArrayList<Attribute>(); List attributes = new ArrayList(); attributes.add( new Attribute( "lang", descriptionObject.getLang(), Namespace.getNamespace("xml", "http://www.w3.org/1999/xhtml"))); descriptionElement.setAttributes(attributes); }
@Test public void testInitInterpreterThrowsEvalError() throws Throwable { Element e = new Element("testBSHMethodName", Namespace.NO_NAMESPACE); e.addContent("testBSHMethod\rStr"); e.setAttributes(new ArrayList()); BSHMethod bshMethod = BSHMethod.createBshMethod(e); try { bshMethod.initInterpreter(arguments); fail("Expected EvalError to be thrown"); } catch (EvalError ex) { assertEquals( "ex.getMessage()", "Sourced file: inline evaluation of: ``testBSHMethod Str;'' : Typed variable declaration : Class: testBSHMethod not found in namespace", ex.getMessage()); assertEquals( "ex.getMessage()", "Sourced file: inline evaluation of: ``testBSHMethod Str;'' : Typed variable declaration : Class: testBSHMethod not found in namespace", ex.getMessage()); assertEquals("(HashMap) arguments.size()", 0, arguments.size()); } }
/** * Adds attributes from in element to out element. * * @param out out element * @param in in element */ private void addAttributes(Element out, Element in) { LinkedHashMap<String, Attribute> allAttributes = new LinkedHashMap<String, Attribute>(); List<Attribute> outAttributes = new ArrayList<Attribute>(out.getAttributes()); List<Attribute> inAttributes = new ArrayList<Attribute>(in.getAttributes()); for (Attribute attr : outAttributes) { attr.detach(); allAttributes.put(attr.getQualifiedName(), attr); logger.fine("adding attr from out:" + attr); } for (Attribute attr : inAttributes) { attr.detach(); allAttributes.put(attr.getQualifiedName(), attr); logger.fine("adding attr from in:" + attr); } out.setAttributes(new ArrayList<Attribute>(allAttributes.values())); }