/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Szabados, Kristof *
 ******************************************************************************/
module XER_EncDec_15 {

type component Test_CT{};


type record of universal charstring any_elem_rec_of with {
  encode "XML";
  variant([-]) "anyElement except 'http://www.somewhere.com'";
}

external function ef_xer_enc(in any_elem_rec_of par) return octetstring 
  with { extension "prototype(convert) encode (XER:XER_EXTENDED) errorbehavior(ALL:ERROR)" }

testcase tc_any_elem() runs on Test_CT {
  var octetstring os_enc;    

  var any_elem_rec_of v_good := { "<xyz:color xmlns:xyz=""http://www.somewhereelse.com"">blue</xyz:color>" };
  os_enc := ef_xer_enc(v_good);

@try {
  var any_elem_rec_of v_bad := { "<xyz:color xmlns:xyz=""http://www.somewhere.com"">red</xyz:color>" };
  os_enc := ef_xer_enc(v_bad); 
} @catch (msg) {
  var template charstring msg_exp := pattern "*Dynamic test case error: While XER-encoding type '@XER_EncDec_15.any_elem_rec_of': Index 0: While checking anyElement: XML namespace ""http://www.somewhere.com"" is in the excluded namespace list*";
  if (not match(msg, msg_exp)) {
    setverdict(fail, "Invalid error message: ", msg);
  } else {
    setverdict(pass);
  }
}
  setverdict(pass);
}

control {
  execute(tc_any_elem());
}

}
