1.1 --- a/mdr/test/unit/src/org/netbeans/mdr/test/InterceptionTest.java Tue Aug 06 10:09:45 2002 +0000
1.2 +++ b/mdr/test/unit/src/org/netbeans/mdr/test/InterceptionTest.java Tue Aug 06 10:13:38 2002 +0000
1.3 @@ -1,9 +1,15 @@
1.4 /*
1.5 - * FederationTest.java
1.6 + * Sun Public License Notice
1.7 *
1.8 - * Created on May 24, 2002, 8:05 PM
1.9 + * The contents of this file are subject to the Sun Public License
1.10 + * Version 1.0 (the "License"). You may not use this file except in
1.11 + * compliance with the License. A copy of the License is available at
1.12 + * http://www.sun.com/
1.13 + *
1.14 + * The Original Code is NetBeans. The Initial Developer of the Original
1.15 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
1.16 + * Microsystems, Inc. All Rights Reserved.
1.17 */
1.18 -
1.19 package org.netbeans.mdr.test;
1.20
1.21 import java.util.*;
1.22 @@ -20,7 +26,7 @@
1.23 */
1.24 public class InterceptionTest extends MDRTestCase {
1.25
1.26 - private static final String MODEL_XMI = "interception.xml";
1.27 + private static final String MODEL_XMI = "component.xml";
1.28 private static final String MODEL_PKG_NAME = "InterceptionTest";
1.29 private static final String PKG_ELEMENT = "Test";
1.30 private static final String PKG_NAME = "InterceptionExtent";
1.31 @@ -63,47 +69,41 @@
1.32 if (testPkg == null)
1.33 fail("Extent creation failed.");
1.34
1.35 - // Create objects
1.36 test.ComponentClass cClass = testPkg.getComponent();
1.37 - test.ServiceClass sClass = testPkg.getService();
1.38 - test.Component comp = cClass.createComponent("aComponent", 1);
1.39 - test.Service serv = sClass.createService("aService");
1.40 + test.Component comp = cClass.createComponent("A", 1);
1.41
1.42 - if (comp == null || serv == null)
1.43 + if (comp == null)
1.44 fail("Object creation failed.");
1.45 -
1.46 +
1.47 + test.Component testComp = cClass.createComponent("A", 2);
1.48 + if (testComp != null)
1.49 + fail("Component creation interception failed.");
1.50 +
1.51 // Attribute test
1.52 comp.setName("X");
1.53 - comp.setVersion(2);
1.54 - serv.setName("Y");
1.55 if (! comp.getName().equals("X"))
1.56 fail("Invalid attribute value");
1.57 - if (comp.getVersion() != 2)
1.58 - fail("Invalid attribute value");
1.59 - if (componentPreSet != 2)
1.60 - fail("_interceptPreSet(...) not called (Component)");
1.61 - if (componentPostSet != 2)
1.62 - fail("_interceptPostSet(...) not called (Component)");
1.63 - if (!componentPreSetVersion)
1.64 - fail("_preSetVersion(...) not called");
1.65 - if (!serv.getName().equals("Y"))
1.66 - fail("Invalid attribute value");
1.67 - if (servicePreSet != 1)
1.68 - fail("_interceptPreSet(...) not called (Service)");
1.69 - if (servicePostSet != 1)
1.70 - fail("_interceptPostSet(...) not called (Service)");
1.71 -
1.72 + comp.setName("TestObjectInterceptor");
1.73 + if (! comp.getName().equals("X"))
1.74 + fail("Setting component attribute interception failed.");
1.75 +
1.76 // Association test
1.77 + test.ServiceClass sClass = testPkg.getService();
1.78 + test.Service serv = sClass.createService("TestAssociationInterceptor");
1.79 + testPkg.getProvides().add(serv, comp);
1.80 + Collection c = comp.getProvidedService();
1.81 + if (c.size() != 0)
1.82 + fail("Association interceptor failed (C->S)");
1.83 + c = serv.getProvider();
1.84 + if (c.size() != 0)
1.85 + fail("Association interceptor failed (S->C)");
1.86 comp.getProvidedService().add(serv);
1.87 - Collection c = comp.getProvidedService();
1.88 + c = comp.getProvidedService();
1.89 if (c.size() != 1)
1.90 fail("Adding association failed (C->S)");
1.91 c = serv.getProvider();
1.92 if (c.size() != 1)
1.93 fail("Adding association failed (S->C)");
1.94 - if (!providesPreAdd)
1.95 - fail("_interceptPreAdd(...) not called (Provides)");
1.96 - if (!providesPostAdd)
1.97 - fail("_interceptPostAdd(...) not called (Provides)");
1.98 +
1.99 }
1.100 }